block: Removed a warning while compiling with a cross compiler for parisc

Started by Abd-Alrhman Masalkhi on Jul 4, 2021 · 4 messages from 2 authors · Last reply Jul 6, 2021

Subsystems (2)

Maintainers (2)

STALE1944d

open the first message on its own page

  1. [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc
    Related patches
I have compiled the kernel with a cross compiler "hppa-linux-gnu-" v9.3.0
on x86-64 host machine. I got the following warning:

block/genhd.c: In function ‘diskstats_show’:
block/genhd.c:1227:1: warning: the frame size of 1688 bytes is larger
than 1280 bytes [-Wframe-larger-than=]
 1227  |  }

by Reduced the stack footprint, using new printf specifier to print the
bdevname and wrapping div_u64 function with non-inline wrapper function,
the warning was not omitted anymore.

Signed-off-by: Abd-Alrhman Masalkhi <redacted>
---
 block/genhd.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 9f8cb7beaad1..6d22b84b182b 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1151,6 +1151,11 @@ const struct device_type disk_type = {
 };
 
 #ifdef CONFIG_PROC_FS
+static noinline u64 call_div_u64(u64 dividend, u32 divisor)
+{
+	return div_u64(dividend, divisor);
+}
+
 /*
  * aggregate disk stat collector.  Uses the same stats that the sysfs
  * entries do, above, but makes them available through one seq_file.
@@ -1162,7 +1167,6 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 {
 	struct gendisk *gp = v;
 	struct block_device *hd;
-	char buf[BDEVNAME_SIZE];
 	unsigned int inflight;
 	struct disk_stats stat;
 	unsigned long idx;
@@ -1185,40 +1189,39 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 		else
 			inflight = part_in_flight(hd);
 
-		seq_printf(seqf, "%4d %7d %s "
+		seq_printf(seqf, "%4d %7d %pg "
 			   "%lu %lu %lu %u "
 			   "%lu %lu %lu %u "
 			   "%u %u %u "
 			   "%lu %lu %lu %u "
 			   "%lu %u"
 			   "\n",
-			   MAJOR(hd->bd_dev), MINOR(hd->bd_dev),
-			   disk_name(gp, hd->bd_partno, buf),
+			   MAJOR(hd->bd_dev), MINOR(hd->bd_dev), gp,
 			   stat.ios[STAT_READ],
 			   stat.merges[STAT_READ],
 			   stat.sectors[STAT_READ],
-			   (unsigned int)div_u64(stat.nsecs[STAT_READ],
-							NSEC_PER_MSEC),
+			   (unsigned int)call_div_u64(stat.nsecs[STAT_READ],
+						      NSEC_PER_MSEC),
 			   stat.ios[STAT_WRITE],
 			   stat.merges[STAT_WRITE],
 			   stat.sectors[STAT_WRITE],
-			   (unsigned int)div_u64(stat.nsecs[STAT_WRITE],
-							NSEC_PER_MSEC),
+			   (unsigned int)call_div_u64(stat.nsecs[STAT_WRITE],
+						      NSEC_PER_MSEC),
 			   inflight,
 			   jiffies_to_msecs(stat.io_ticks),
-			   (unsigned int)div_u64(stat.nsecs[STAT_READ] +
-						 stat.nsecs[STAT_WRITE] +
-						 stat.nsecs[STAT_DISCARD] +
-						 stat.nsecs[STAT_FLUSH],
-							NSEC_PER_MSEC),
+			   (unsigned int)call_div_u64(stat.nsecs[STAT_READ] +
+						      stat.nsecs[STAT_WRITE] +
+						      stat.nsecs[STAT_DISCARD] +
+						      stat.nsecs[STAT_FLUSH],
+						      NSEC_PER_MSEC),
 			   stat.ios[STAT_DISCARD],
 			   stat.merges[STAT_DISCARD],
 			   stat.sectors[STAT_DISCARD],
-			   (unsigned int)div_u64(stat.nsecs[STAT_DISCARD],
-						 NSEC_PER_MSEC),
+			   (unsigned int)call_div_u64(stat.nsecs[STAT_DISCARD],
+						      NSEC_PER_MSEC),
 			   stat.ios[STAT_FLUSH],
-			   (unsigned int)div_u64(stat.nsecs[STAT_FLUSH],
-						 NSEC_PER_MSEC)
+			   (unsigned int)call_div_u64(stat.nsecs[STAT_FLUSH],
+						      NSEC_PER_MSEC)
 			);
 	}
 	rcu_read_unlock();
-- 
2.29.0.rc1.dirty
Hi Abd-Alrhman,

url:    https://github.com/0day-ci/linux/commits/Abd-Alrhman-Masalkhi/block-Removed-a-warning-while-compiling-with-a-cross-compiler-for-parisc/20210704-205212
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: i386-randconfig-m021-20210705 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>
Reported-by: Dan Carpenter <redacted>

smatch warnings:
block/genhd.c:1147 diskstats_show() error: '%pg' expects argument of type struct 'block_device*', argument 5 has type 'struct gendisk*'

vim +1147 block/genhd.c

acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1113  
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1114  /*
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1115   * aggregate disk stat collector.  Uses the same stats that the sysfs
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1116   * entries do, above, but makes them available through one seq_file.
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1117   *
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1118   * The output looks suspiciously like /proc/partitions with a bunch of
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1119   * extra fields.
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1120   */
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1121  static int diskstats_show(struct seq_file *seqf, void *v)
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1122  {
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1123  	struct gendisk *gp = v;
ad1eaa5344b293 block/genhd.c         Christoph Hellwig     2020-11-24  1124  	struct block_device *hd;
e016b78201a2d9 block/genhd.c         Mikulas Patocka       2018-12-06  1125  	unsigned int inflight;
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1126  	struct disk_stats stat;
7fae67cc9c0e06 block/genhd.c         Christoph Hellwig     2021-04-06  1127  	unsigned long idx;
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1128  
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1129  	/*
ed9e1982347b36 block/genhd.c         Tejun Heo             2008-08-25  1130  	if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next)
cf771cb5a7b716 block/genhd.c         Tejun Heo             2008-09-03  1131  		seq_puts(seqf,	"major minor name"
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1132  				"     rio rmerge rsect ruse wio wmerge "
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1133  				"wsect wuse running use aveq"
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1134  				"\n\n");
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1135  	*/
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1136  

58 more lines

Hello Dan,

Thank you for your comment, I have fixed the issue, added the discussed tags, and sent a new version of the patch.
Hello Dan,

Thank you for your comment, I have fixed the issue, added the discussed tags, and sent a new version of the patch.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help