All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] genhd: incrase size of disk stat counters
       [not found] <CGME20180730114602eucas1p14b7cd9e90df341d88fa5d97ec74f005a@eucas1p1.samsung.com>
@ 2018-07-30 11:43 ` Huijin Park
  2018-07-31 10:54   ` kbuild test robot
  2018-07-31 12:12   ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Huijin Park @ 2018-07-30 11:43 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-kernel, Huijin Park, js07.lee, bbanghj.park

From: "huijin.park" <huijin.park@samsung.com>

The kernel's representation of the disk statistics uses different size
on 32b and 64b platforms. But the data size of io is not different
between 32b and 64b platforms. So in the 32b platform, it might happen
overflow earlier than 64b platform. Therefore, it seems like a better
approach would be to extend the length of the disk_stats structure on
32b architectures to 64b.

Signed-off-by: huijin.park <huijin.park@samsung.com>
---
 block/genhd.c             |   28 +++++++++++++++++++---------
 block/partition-generic.c |   31 +++++++++++++++++++------------
 include/linux/genhd.h     |   12 ++++++------
 3 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 8cc719a3..3e6d0c2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1334,27 +1334,37 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 		part_stat_unlock();
 		part_in_flight(gp->queue, hd, inflight);
 		seq_printf(seqf, "%4d %7d %s "
-			   "%lu %lu %lu %u "
-			   "%lu %lu %lu %u "
-			   "%u %u %u "
-			   "%lu %lu %lu %u\n",
+			   "%llu %llu %llu %llu "
+			   "%llu %llu %llu %llu "
+			   "%u %llu %llu "
+			   "%llu %llu %llu %llu\n",
 			   MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
 			   disk_name(gp, hd->partno, buf),
 			   part_stat_read(hd, ios[STAT_READ]),
 			   part_stat_read(hd, merges[STAT_READ]),
 			   part_stat_read(hd, sectors[STAT_READ]),
-			   jiffies_to_msecs(part_stat_read(hd, ticks[STAT_READ])),
+			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
+							ticks[STAT_READ])),
+				   NSEC_PER_MSEC),
 			   part_stat_read(hd, ios[STAT_WRITE]),
 			   part_stat_read(hd, merges[STAT_WRITE]),
 			   part_stat_read(hd, sectors[STAT_WRITE]),
-			   jiffies_to_msecs(part_stat_read(hd, ticks[STAT_WRITE])),
+			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
+							ticks[STAT_WRITE])),
+				   NSEC_PER_MSEC),
 			   inflight[0],
-			   jiffies_to_msecs(part_stat_read(hd, io_ticks)),
-			   jiffies_to_msecs(part_stat_read(hd, time_in_queue)),
+			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
+							io_ticks)),
+				   NSEC_PER_MSEC),
+			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
+							time_in_queue)),
+				   NSEC_PER_MSEC),
 			   part_stat_read(hd, ios[STAT_DISCARD]),
 			   part_stat_read(hd, merges[STAT_DISCARD]),
 			   part_stat_read(hd, sectors[STAT_DISCARD]),
-			   jiffies_to_msecs(part_stat_read(hd, ticks[STAT_DISCARD]))
+			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
+							ticks[STAT_DISCARD])),
+				   NSEC_PER_MSEC)
 			);
 	}
 	disk_part_iter_exit(&piter);
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 5a8975a..108b473 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -128,26 +128,33 @@ ssize_t part_stat_show(struct device *dev,
 	part_stat_unlock();
 	part_in_flight(q, p, inflight);
 	return sprintf(buf,
-		"%8lu %8lu %8llu %8u "
-		"%8lu %8lu %8llu %8u "
-		"%8u %8u %8u "
-		"%8lu %8lu %8llu %8u"
+		"%8llu %8llu %8llu %8llu "
+		"%8llu %8llu %8llu %8llu "
+		"%8u %8llu %8llu "
+		"%8llu %8llu %8llu %8llu"
 		"\n",
 		part_stat_read(p, ios[STAT_READ]),
 		part_stat_read(p, merges[STAT_READ]),
-		(unsigned long long)part_stat_read(p, sectors[STAT_READ]),
-		jiffies_to_msecs(part_stat_read(p, ticks[STAT_READ])),
+		part_stat_read(p, sectors[STAT_READ]),
+		div_u64(jiffies64_to_nsecs(part_stat_read(p, ticks[STAT_READ])),
+			NSEC_PER_MSEC),
 		part_stat_read(p, ios[STAT_WRITE]),
 		part_stat_read(p, merges[STAT_WRITE]),
-		(unsigned long long)part_stat_read(p, sectors[STAT_WRITE]),
-		jiffies_to_msecs(part_stat_read(p, ticks[STAT_WRITE])),
+		part_stat_read(p, sectors[STAT_WRITE]),
+		div_u64(jiffies64_to_nsecs(part_stat_read(p,
+							  ticks[STAT_WRITE])),
+			NSEC_PER_MSEC),
 		inflight[0],
-		jiffies_to_msecs(part_stat_read(p, io_ticks)),
-		jiffies_to_msecs(part_stat_read(p, time_in_queue)),
+		div_u64(jiffies64_to_nsecs(part_stat_read(p, io_ticks)),
+			NSEC_PER_MSEC),
+		div_u64(jiffies64_to_nsecs(part_stat_read(p, time_in_queue)),
+			NSEC_PER_MSEC),
 		part_stat_read(p, ios[STAT_DISCARD]),
 		part_stat_read(p, merges[STAT_DISCARD]),
-		(unsigned long long)part_stat_read(p, sectors[STAT_DISCARD]),
-		jiffies_to_msecs(part_stat_read(p, ticks[STAT_DISCARD])));
+		part_stat_read(p, sectors[STAT_DISCARD]),
+		div_u64(jiffies64_to_nsecs(part_stat_read(p,
+							  ticks[STAT_DISCARD])),
+			NSEC_PER_MSEC));
 }
 
 ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr,
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 5786442..d4cb798 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -83,12 +83,12 @@ struct partition {
 } __attribute__((packed));
 
 struct disk_stats {
-	unsigned long sectors[NR_STAT_GROUPS];
-	unsigned long ios[NR_STAT_GROUPS];
-	unsigned long merges[NR_STAT_GROUPS];
-	unsigned long ticks[NR_STAT_GROUPS];
-	unsigned long io_ticks;
-	unsigned long time_in_queue;
+	unsigned long long sectors[NR_STAT_GROUPS];
+	unsigned long long ios[NR_STAT_GROUPS];
+	unsigned long long merges[NR_STAT_GROUPS];
+	unsigned long long ticks[NR_STAT_GROUPS];
+	unsigned long long io_ticks;
+	unsigned long long time_in_queue;
 };
 
 #define PARTITION_META_INFO_VOLNAMELTH	64
-- 
1.7.9.5

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

* Re: [PATCH] genhd: incrase size of disk stat counters
  2018-07-30 11:43 ` [PATCH] genhd: incrase size of disk stat counters Huijin Park
@ 2018-07-31 10:54   ` kbuild test robot
  2018-07-31 12:12   ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-07-31 10:54 UTC (permalink / raw)
  To: Huijin Park
  Cc: kbuild-all, Jens Axboe, linux-block, linux-kernel, Huijin Park,
	js07.lee, bbanghj.park

[-- Attachment #1: Type: text/plain, Size: 8250 bytes --]

Hi huijin.park,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on block/for-next]
[cannot apply to v4.18-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Huijin-Park/genhd-incrase-size-of-disk-stat-counters/20180731-173548
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=parisc 

All warnings (new ones prefixed by >>):

   block/genhd.c: In function 'diskstats_show':
>> block/genhd.c:1373:1: warning: the frame size of 1584 bytes is larger than 1280 bytes [-Wframe-larger-than=]
    }
    ^

vim +1373 block/genhd.c

^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1304  
a6e2ba88 block/genhd.c         Randy Dunlap     2008-05-23  1305  #ifdef CONFIG_PROC_FS
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1306  /*
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1307   * aggregate disk stat collector.  Uses the same stats that the sysfs
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1308   * entries do, above, but makes them available through one seq_file.
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1309   *
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1310   * The output looks suspiciously like /proc/partitions with a bunch of
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1311   * extra fields.
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1312   */
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1313  static int diskstats_show(struct seq_file *seqf, void *v)
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1314  {
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1315  	struct gendisk *gp = v;
e71bf0d0 block/genhd.c         Tejun Heo        2008-09-03  1316  	struct disk_part_iter piter;
e71bf0d0 block/genhd.c         Tejun Heo        2008-09-03  1317  	struct hd_struct *hd;
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1318  	char buf[BDEVNAME_SIZE];
0609e0ef block/genhd.c         Jens Axboe       2017-08-08  1319  	unsigned int inflight[2];
c9959059 block/genhd.c         Tejun Heo        2008-08-25  1320  	int cpu;
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1321  
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1322  	/*
ed9e1982 block/genhd.c         Tejun Heo        2008-08-25  1323  	if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next)
cf771cb5 block/genhd.c         Tejun Heo        2008-09-03  1324  		seq_puts(seqf,	"major minor name"
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1325  				"     rio rmerge rsect ruse wio wmerge "
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1326  				"wsect wuse running use aveq"
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1327  				"\n\n");
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1328  	*/
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1329  
71982a40 block/genhd.c         Tejun Heo        2009-04-17  1330  	disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
e71bf0d0 block/genhd.c         Tejun Heo        2008-09-03  1331  	while ((hd = disk_part_iter_next(&piter))) {
074a7aca block/genhd.c         Tejun Heo        2008-08-25  1332  		cpu = part_stat_lock();
d62e26b3 block/genhd.c         Jens Axboe       2017-06-30  1333  		part_round_stats(gp->queue, cpu, hd);
074a7aca block/genhd.c         Tejun Heo        2008-08-25  1334  		part_stat_unlock();
0609e0ef block/genhd.c         Jens Axboe       2017-08-08  1335  		part_in_flight(gp->queue, hd, inflight);
bdca3c87 block/genhd.c         Michael Callahan 2018-07-18  1336  		seq_printf(seqf, "%4d %7d %s "
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1337  			   "%llu %llu %llu %llu "
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1338  			   "%llu %llu %llu %llu "
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1339  			   "%u %llu %llu "
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1340  			   "%llu %llu %llu %llu\n",
f331c029 block/genhd.c         Tejun Heo        2008-09-03  1341  			   MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
f331c029 block/genhd.c         Tejun Heo        2008-09-03  1342  			   disk_name(gp, hd->partno, buf),
dbae2c55 block/genhd.c         Michael Callahan 2018-07-18  1343  			   part_stat_read(hd, ios[STAT_READ]),
dbae2c55 block/genhd.c         Michael Callahan 2018-07-18  1344  			   part_stat_read(hd, merges[STAT_READ]),
dbae2c55 block/genhd.c         Michael Callahan 2018-07-18  1345  			   part_stat_read(hd, sectors[STAT_READ]),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1346  			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1347  							ticks[STAT_READ])),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1348  				   NSEC_PER_MSEC),
dbae2c55 block/genhd.c         Michael Callahan 2018-07-18  1349  			   part_stat_read(hd, ios[STAT_WRITE]),
dbae2c55 block/genhd.c         Michael Callahan 2018-07-18  1350  			   part_stat_read(hd, merges[STAT_WRITE]),
dbae2c55 block/genhd.c         Michael Callahan 2018-07-18  1351  			   part_stat_read(hd, sectors[STAT_WRITE]),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1352  			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1353  							ticks[STAT_WRITE])),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1354  				   NSEC_PER_MSEC),
0609e0ef block/genhd.c         Jens Axboe       2017-08-08  1355  			   inflight[0],
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1356  			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1357  							io_ticks)),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1358  				   NSEC_PER_MSEC),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1359  			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1360  							time_in_queue)),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1361  				   NSEC_PER_MSEC),
bdca3c87 block/genhd.c         Michael Callahan 2018-07-18  1362  			   part_stat_read(hd, ios[STAT_DISCARD]),
bdca3c87 block/genhd.c         Michael Callahan 2018-07-18  1363  			   part_stat_read(hd, merges[STAT_DISCARD]),
bdca3c87 block/genhd.c         Michael Callahan 2018-07-18  1364  			   part_stat_read(hd, sectors[STAT_DISCARD]),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1365  			   div_u64(jiffies64_to_nsecs(part_stat_read(hd,
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1366  							ticks[STAT_DISCARD])),
0d71c7ce block/genhd.c         huijin.park      2018-07-30  1367  				   NSEC_PER_MSEC)
28f39d55 block/genhd.c         Jerome Marchand  2008-02-08  1368  			);
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1369  	}
e71bf0d0 block/genhd.c         Tejun Heo        2008-09-03  1370  	disk_part_iter_exit(&piter);
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1371  
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1372  	return 0;
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16 @1373  }
^1da177e drivers/block/genhd.c Linus Torvalds   2005-04-16  1374  

:::::: The code at line 1373 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 53540 bytes --]

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

* Re: [PATCH] genhd: incrase size of disk stat counters
  2018-07-30 11:43 ` [PATCH] genhd: incrase size of disk stat counters Huijin Park
  2018-07-31 10:54   ` kbuild test robot
@ 2018-07-31 12:12   ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-07-31 12:12 UTC (permalink / raw)
  To: Huijin Park
  Cc: kbuild-all, Jens Axboe, linux-block, linux-kernel, Huijin Park,
	js07.lee, bbanghj.park

[-- Attachment #1: Type: text/plain, Size: 2659 bytes --]

Hi huijin.park,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on block/for-next]
[also build test WARNING on next-20180727]
[cannot apply to v4.18-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Huijin-Park/genhd-incrase-size-of-disk-stat-counters/20180731-173548
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: um-x86_64_defconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=um SUBARCH=x86_64

All warnings (new ones prefixed by >>):

   fs/ext4/sysfs.c: In function 'session_write_kbytes_show':
>> fs/ext4/sysfs.c:58:37: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat=]
     return snprintf(buf, PAGE_SIZE, "%lu\n",
                                      ~~^
                                      %llu
       (part_stat_read(sb->s_bdev->bd_part,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         sectors[STAT_WRITE]) -
         ~~~~~~~~~~~~~~~~~~~~~~          
        sbi->s_sectors_written_start) >> 1);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +58 fs/ext4/sysfs.c

b5799018 Theodore Ts'o    2015-09-23  51  
6ca06829 Tyson Nottingham 2018-03-30  52  static ssize_t session_write_kbytes_show(struct ext4_sb_info *sbi, char *buf)
b5799018 Theodore Ts'o    2015-09-23  53  {
b5799018 Theodore Ts'o    2015-09-23  54  	struct super_block *sb = sbi->s_buddy_cache->i_sb;
b5799018 Theodore Ts'o    2015-09-23  55  
b5799018 Theodore Ts'o    2015-09-23  56  	if (!sb->s_bdev->bd_part)
b5799018 Theodore Ts'o    2015-09-23  57  		return snprintf(buf, PAGE_SIZE, "0\n");
b5799018 Theodore Ts'o    2015-09-23 @58  	return snprintf(buf, PAGE_SIZE, "%lu\n",
dbae2c55 Michael Callahan 2018-07-18  59  			(part_stat_read(sb->s_bdev->bd_part,
dbae2c55 Michael Callahan 2018-07-18  60  					sectors[STAT_WRITE]) -
b5799018 Theodore Ts'o    2015-09-23  61  			 sbi->s_sectors_written_start) >> 1);
b5799018 Theodore Ts'o    2015-09-23  62  }
b5799018 Theodore Ts'o    2015-09-23  63  

:::::: The code at line 58 was first introduced by commit
:::::: b5799018827e67867fda77c3cde10fc080606fe2 ext4: move sysfs code from super.c to fs/ext4/sysfs.c

:::::: TO: Theodore Ts'o <tytso@mit.edu>
:::::: CC: Theodore Ts'o <tytso@mit.edu>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 7568 bytes --]

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

end of thread, other threads:[~2018-07-31 12:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180730114602eucas1p14b7cd9e90df341d88fa5d97ec74f005a@eucas1p1.samsung.com>
2018-07-30 11:43 ` [PATCH] genhd: incrase size of disk stat counters Huijin Park
2018-07-31 10:54   ` kbuild test robot
2018-07-31 12:12   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.