linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc
@ 2021-07-04 12:48 Abd-Alrhman Masalkhi
  2021-07-06  7:54 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2021-07-04 12:48 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Abd-Alrhman Masalkhi

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 <abd.masalkhi@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc
  2021-07-04 12:48 [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc Abd-Alrhman Masalkhi
@ 2021-07-06  7:54 ` Dan Carpenter
  2021-07-06 11:33   ` Abd-Alrhman Masalkhi
  2021-07-06 11:41   ` Abd-Alrhman Masalkhi
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-07-06  7:54 UTC (permalink / raw)
  To: kbuild, Abd-Alrhman Masalkhi, axboe
  Cc: lkp, kbuild-all, linux-block, linux-kernel, Abd-Alrhman Masalkhi

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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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  
7fae67cc9c0e06 block/genhd.c         Christoph Hellwig     2021-04-06  1137  	rcu_read_lock();
7fae67cc9c0e06 block/genhd.c         Christoph Hellwig     2021-04-06  1138  	xa_for_each(&gp->part_tbl, idx, hd) {
7fae67cc9c0e06 block/genhd.c         Christoph Hellwig     2021-04-06  1139  		if (bdev_is_partition(hd) && !bdev_nr_sectors(hd))
7fae67cc9c0e06 block/genhd.c         Christoph Hellwig     2021-04-06  1140  			continue;
0d02129e76edf9 block/genhd.c         Christoph Hellwig     2020-11-27  1141  		part_stat_read_all(hd, &stat);
b2f609e191edc9 block/genhd.c         Christoph Hellwig     2020-05-13  1142  		if (queue_is_mq(gp->queue))
ad1eaa5344b293 block/genhd.c         Christoph Hellwig     2020-11-24  1143  			inflight = blk_mq_in_flight(gp->queue, hd);
b2f609e191edc9 block/genhd.c         Christoph Hellwig     2020-05-13  1144  		else
ad1eaa5344b293 block/genhd.c         Christoph Hellwig     2020-11-24  1145  			inflight = part_in_flight(hd);
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1146  
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04 @1147  		seq_printf(seqf, "%4d %7d %pg "
                                                                                                                  ^^^

bdca3c87fb7ad1 block/genhd.c         Michael Callahan      2018-07-18  1148  			   "%lu %lu %lu %u "
bdca3c87fb7ad1 block/genhd.c         Michael Callahan      2018-07-18  1149  			   "%lu %lu %lu %u "
bdca3c87fb7ad1 block/genhd.c         Michael Callahan      2018-07-18  1150  			   "%u %u %u "
b6866318657717 block/genhd.c         Konstantin Khlebnikov 2019-11-21  1151  			   "%lu %lu %lu %u "
b6866318657717 block/genhd.c         Konstantin Khlebnikov 2019-11-21  1152  			   "%lu %u"
b6866318657717 block/genhd.c         Konstantin Khlebnikov 2019-11-21  1153  			   "\n",
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1154  			   MAJOR(hd->bd_dev), MINOR(hd->bd_dev), gp,
                                                                                                                                         ^^

ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1155  			   stat.ios[STAT_READ],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1156  			   stat.merges[STAT_READ],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1157  			   stat.sectors[STAT_READ],
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1158  			   (unsigned int)call_div_u64(stat.nsecs[STAT_READ],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1159  						      NSEC_PER_MSEC),
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1160  			   stat.ios[STAT_WRITE],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1161  			   stat.merges[STAT_WRITE],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1162  			   stat.sectors[STAT_WRITE],
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1163  			   (unsigned int)call_div_u64(stat.nsecs[STAT_WRITE],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1164  						      NSEC_PER_MSEC),
e016b78201a2d9 block/genhd.c         Mikulas Patocka       2018-12-06  1165  			   inflight,
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1166  			   jiffies_to_msecs(stat.io_ticks),
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1167  			   (unsigned int)call_div_u64(stat.nsecs[STAT_READ] +
8cd5b8fc00716f block/genhd.c         Konstantin Khlebnikov 2020-03-25  1168  						      stat.nsecs[STAT_WRITE] +
8cd5b8fc00716f block/genhd.c         Konstantin Khlebnikov 2020-03-25  1169  						      stat.nsecs[STAT_DISCARD] +
8cd5b8fc00716f block/genhd.c         Konstantin Khlebnikov 2020-03-25  1170  						      stat.nsecs[STAT_FLUSH],
8cd5b8fc00716f block/genhd.c         Konstantin Khlebnikov 2020-03-25  1171  						      NSEC_PER_MSEC),
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1172  			   stat.ios[STAT_DISCARD],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1173  			   stat.merges[STAT_DISCARD],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1174  			   stat.sectors[STAT_DISCARD],
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1175  			   (unsigned int)call_div_u64(stat.nsecs[STAT_DISCARD],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1176  						      NSEC_PER_MSEC),
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1177  			   stat.ios[STAT_FLUSH],
acc384f7df09a5 block/genhd.c         Abd-Alrhman Masalkhi  2021-07-04  1178  			   (unsigned int)call_div_u64(stat.nsecs[STAT_FLUSH],
ea18e0f0a63af9 block/genhd.c         Konstantin Khlebnikov 2020-03-25  1179  						      NSEC_PER_MSEC)
28f39d553ee242 block/genhd.c         Jerome Marchand       2008-02-08  1180  			);
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1181  	}
7fae67cc9c0e06 block/genhd.c         Christoph Hellwig     2021-04-06  1182  	rcu_read_unlock();
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1183  
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1184  	return 0;
^1da177e4c3f41 drivers/block/genhd.c Linus Torvalds        2005-04-16  1185  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc
  2021-07-06  7:54 ` Dan Carpenter
@ 2021-07-06 11:33   ` Abd-Alrhman Masalkhi
  2021-07-06 11:41   ` Abd-Alrhman Masalkhi
  1 sibling, 0 replies; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2021-07-06 11:33 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, dan.carpenter, kbuild, lkp, kbuild-all

Hello Dan,

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc
  2021-07-06  7:54 ` Dan Carpenter
  2021-07-06 11:33   ` Abd-Alrhman Masalkhi
@ 2021-07-06 11:41   ` Abd-Alrhman Masalkhi
  1 sibling, 0 replies; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2021-07-06 11:41 UTC (permalink / raw)
  To: linux-block; +Cc: linux-kernel, kbuild, lkp, kbuild-all

Hello Dan,

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-06 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 12:48 [PATCH v2] block: Removed a warning while compiling with a cross compiler for parisc Abd-Alrhman Masalkhi
2021-07-06  7:54 ` Dan Carpenter
2021-07-06 11:33   ` Abd-Alrhman Masalkhi
2021-07-06 11:41   ` Abd-Alrhman Masalkhi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).