All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mdraid: fix read/write bytes accounting
@ 2020-06-05 20:19 jeffm
  2020-06-08  7:13 ` Artur Paszkiewicz
  2020-06-09  6:37   ` kernel test robot
  0 siblings, 2 replies; 8+ messages in thread
From: jeffm @ 2020-06-05 20:19 UTC (permalink / raw)
  To: linux-raid, song; +Cc: nfbrown, colyli, Jeff Mahoney

From: Jeff Mahoney <jeffm@suse.com>

The i/o accounting published in /proc/diskstats for mdraid is currently
broken.  md_make_request does the accounting for every bio passed but
when a bio needs to be split, all the split bios are also submitted
through md_make_request, resulting in multiple accounting.

As a result, a quick test on a RAID6 volume displayed the following
behavior:

131072+0 records in
131072+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 13.9227 s, 4.8 MB/s

... shows 131072 sectors read -- 64 MiB.  Correct.

512+0 records in
512+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 0.287365 s, 234 MB/s

... shows 196608 sectors read -- 96 MiB.  With a 64k stripe size, we're
seeing some splitting.

512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 0.705004 s, 762 MB/s

... shows 4718624 sectors read -- 2.25 GiB transferred.  Lots of splitting
and a stats explosion.

The fix is to push the accounting into the personality make_request
callbacks so that only the bios actually submitted for I/O will be
accounted.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 drivers/md/md-faulty.c    |  1 +
 drivers/md/md-linear.c    |  1 +
 drivers/md/md-multipath.c |  1 +
 drivers/md/md.c           | 21 +++++++++++++++------
 drivers/md/md.h           |  1 +
 drivers/md/raid0.c        |  1 +
 drivers/md/raid1.c        |  3 +++
 drivers/md/raid10.c       |  3 +++
 drivers/md/raid5.c        |  3 +++
 9 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/md/md-faulty.c b/drivers/md/md-faulty.c
index 50ad4ba86f0e..25e2c72ef920 100644
--- a/drivers/md/md-faulty.c
+++ b/drivers/md/md-faulty.c
@@ -214,6 +214,7 @@ static bool faulty_make_request(struct mddev *mddev, struct bio *bio)
 	} else
 		bio_set_dev(bio, conf->rdev->bdev);
 
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
 	generic_make_request(bio);
 	return true;
 }
diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index 26c75c0199fa..ec0dbc0f1d76 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -271,6 +271,7 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 		bio = split;
 	}
 
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
 	bio_set_dev(bio, tmp_dev->rdev->bdev);
 	bio->bi_iter.bi_sector = bio->bi_iter.bi_sector -
 		start_sector + data_offset;
diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c
index 152f9e65a226..c3afe3f62a88 100644
--- a/drivers/md/md-multipath.c
+++ b/drivers/md/md-multipath.c
@@ -131,6 +131,7 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio)
 	mp_bh->bio.bi_private = mp_bh;
 	mddev_check_writesame(mddev, &mp_bh->bio);
 	mddev_check_write_zeroes(mddev, &mp_bh->bio);
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
 	generic_make_request(&mp_bh->bio);
 	return true;
 }
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f567f536b529..e8078a16419b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -463,10 +463,24 @@ void md_handle_request(struct mddev *mddev, struct bio *bio)
 }
 EXPORT_SYMBOL(md_handle_request);
 
+/*
+ * This is generic_start_io_acct without the inflight tracking.  Since
+ * we can't reliably call generic_end_io_acct, the inflight counter
+ * would also be unreliable and it's better to keep it at 0.
+ */
+void md_io_acct(struct mddev *mddev, int sgrp, unsigned int sectors)
+{
+	part_stat_lock();
+	part_stat_inc(&mddev->gendisk->part0, ios[sgrp]);
+	part_stat_add(&mddev->gendisk->part0, sectors[sgrp], sectors);
+	part_stat_unlock();
+
+}
+EXPORT_SYMBOL_GPL(md_io_acct);
+
 static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
 {
 	const int rw = bio_data_dir(bio);
-	const int sgrp = op_stat_group(bio_op(bio));
 	struct mddev *mddev = bio->bi_disk->private_data;
 	unsigned int sectors;
 
@@ -498,11 +512,6 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
 
 	md_handle_request(mddev, bio);
 
-	part_stat_lock();
-	part_stat_inc(&mddev->gendisk->part0, ios[sgrp]);
-	part_stat_add(&mddev->gendisk->part0, sectors[sgrp], sectors);
-	part_stat_unlock();
-
 	return BLK_QC_T_NONE;
 }
 
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 612814d07d35..5834427f7557 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -741,6 +741,7 @@ extern void mddev_suspend(struct mddev *mddev);
 extern void mddev_resume(struct mddev *mddev);
 extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,
 				   struct mddev *mddev);
+extern void md_io_acct(struct mddev *mddev, int sgrp, unsigned int sectors);
 
 extern void md_reload_sb(struct mddev *mddev, int raid_disk);
 extern void md_update_sb(struct mddev *mddev, int force);
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 322386ff5d22..ac1109d1d48d 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -633,6 +633,7 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)
 				disk_devt(mddev->gendisk), bio_sector);
 	mddev_check_writesame(mddev, bio);
 	mddev_check_write_zeroes(mddev, bio);
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
 	generic_make_request(bio);
 	return true;
 }
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index dcd27f3da84e..f0d620e2b90f 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1318,6 +1318,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
 		r1_bio->sectors = max_sectors;
 	}
 
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
 	r1_bio->read_disk = rdisk;
 
 	read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);
@@ -1489,6 +1490,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 		r1_bio->sectors = max_sectors;
 	}
 
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
+
 	atomic_set(&r1_bio->remaining, 1);
 	atomic_set(&r1_bio->behind_remaining, 0);
 
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index ec136e44aef7..b8e8d7f67f65 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1202,6 +1202,8 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
 	}
 	slot = r10_bio->read_slot;
 
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
+
 	read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);
 
 	r10_bio->devs[slot].bio = read_bio;
@@ -1485,6 +1487,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
 		r10_bio->master_bio = bio;
 	}
 
+	md_io_acct(mddev, bio_op(bio), bio_sectors(bio));
 	atomic_set(&r10_bio->remaining, 1);
 	md_bitmap_startwrite(mddev->bitmap, r10_bio->sector, r10_bio->sectors, 0);
 
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ab8067f9ce8c..e57109e39fcd 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5316,6 +5316,7 @@ static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio)
 	if (!raid5_read_one_chunk(mddev, raid_bio))
 		return raid_bio;
 
+	md_io_acct(mddev, bio_op(raid_bio), bio_sectors(raid_bio));
 	return NULL;
 }
 
@@ -5634,6 +5635,8 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
 	last_sector = bio_end_sector(bi);
 	bi->bi_next = NULL;
 
+	md_io_acct(mddev, bio_op(bi), bio_sectors(bi));
+
 	prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
 	for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
 		int previous;
-- 
2.16.4

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
  2020-06-05 20:19 [PATCH] mdraid: fix read/write bytes accounting jeffm
@ 2020-06-08  7:13 ` Artur Paszkiewicz
  2020-06-23 14:21   ` Guoqing Jiang
  2020-06-23 14:24   ` Jeff Mahoney
  2020-06-09  6:37   ` kernel test robot
  1 sibling, 2 replies; 8+ messages in thread
From: Artur Paszkiewicz @ 2020-06-08  7:13 UTC (permalink / raw)
  To: jeffm, linux-raid, song; +Cc: nfbrown, colyli

On 6/5/20 10:19 PM, jeffm@suse.com wrote:
> The i/o accounting published in /proc/diskstats for mdraid is currently
> broken.  md_make_request does the accounting for every bio passed but
> when a bio needs to be split, all the split bios are also submitted
> through md_make_request, resulting in multiple accounting.

Hi Jeff,

I sent a patch a few days ago which should fix this issue. Can you check
it out?

https://marc.info/?l=linux-raid&m=159102814820539

Thanks,
Artur

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
  2020-06-05 20:19 [PATCH] mdraid: fix read/write bytes accounting jeffm
@ 2020-06-09  6:37   ` kernel test robot
  2020-06-09  6:37   ` kernel test robot
  1 sibling, 0 replies; 8+ messages in thread
From: kernel test robot @ 2020-06-09  6:37 UTC (permalink / raw)
  To: linux-raid, song; +Cc: kbuild-all, nfbrown, colyli, Jeff Mahoney

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

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on next-20200608]
[cannot apply to v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/jeffm-suse-com/mdraid-fix-read-write-bytes-accounting/20200607-085457
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b170290c2836c40ab565736ba37681eb3dfd79b8
config: m68k-randconfig-r011-20200607 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        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
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

drivers/md/md.c: In function 'md_make_request':
>> drivers/md/md.c:485:15: warning: variable 'sectors' set but not used [-Wunused-but-set-variable]
485 |  unsigned int sectors;
|               ^~~~~~~
drivers/md/md.c: In function 'bind_rdev_to_array':
drivers/md/md.c:2454:27: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
2454 |   /* failure here is OK */;
|                           ^
drivers/md/md.c: In function 'slot_store':
drivers/md/md.c:3215:28: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
3215 |    /* failure here is OK */;
|                            ^
drivers/md/md.c: In function 'remove_and_add_spares':
drivers/md/md.c:9073:29: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
9073 |     /* failure here is OK */;
|                             ^

vim +/sectors +485 drivers/md/md.c

eb17e42dfd959c Jeff Mahoney         2020-06-05  480  
dece16353ef47d Jens Axboe           2015-11-05  481  static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
^1da177e4c3f41 Linus Torvalds       2005-04-16  482  {
490773268cf64f NeilBrown            2010-03-25  483  	const int rw = bio_data_dir(bio);
e4fc5a74293fbe Christoph Hellwig    2020-05-08  484  	struct mddev *mddev = bio->bi_disk->private_data;
e91ece5590b3c7 Chris Mason          2011-02-07 @485  	unsigned int sectors;
490773268cf64f NeilBrown            2010-03-25  486  
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  487  	if (unlikely(test_bit(MD_BROKEN, &mddev->flags)) && (rw == WRITE)) {
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  488  		bio_io_error(bio);
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  489  		return BLK_QC_T_NONE;
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  490  	}
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  491  
af67c31fba3b87 NeilBrown            2017-06-18  492  	blk_queue_split(q, &bio);
54efd50bfd873e Kent Overstreet      2015-04-23  493  
274d8cbde1bc3b NeilBrown            2016-01-04  494  	if (mddev == NULL || mddev->pers == NULL) {
6712ecf8f64811 NeilBrown            2007-09-27  495  		bio_io_error(bio);
dece16353ef47d Jens Axboe           2015-11-05  496  		return BLK_QC_T_NONE;
^1da177e4c3f41 Linus Torvalds       2005-04-16  497  	}
bbfa57c0f2243a Sebastian Riemer     2013-02-21  498  	if (mddev->ro == 1 && unlikely(rw == WRITE)) {
4246a0b63bd8f5 Christoph Hellwig    2015-07-20  499  		if (bio_sectors(bio) != 0)
4e4cbee93d5613 Christoph Hellwig    2017-06-03  500  			bio->bi_status = BLK_STS_IOERR;
4246a0b63bd8f5 Christoph Hellwig    2015-07-20  501  		bio_endio(bio);
dece16353ef47d Jens Axboe           2015-11-05  502  		return BLK_QC_T_NONE;
bbfa57c0f2243a Sebastian Riemer     2013-02-21  503  	}
490773268cf64f NeilBrown            2010-03-25  504  
e91ece5590b3c7 Chris Mason          2011-02-07  505  	/*
e91ece5590b3c7 Chris Mason          2011-02-07  506  	 * save the sectors now since our bio can
e91ece5590b3c7 Chris Mason          2011-02-07  507  	 * go away inside make_request
e91ece5590b3c7 Chris Mason          2011-02-07  508  	 */
e91ece5590b3c7 Chris Mason          2011-02-07  509  	sectors = bio_sectors(bio);
9c573de3283af0 Shaohua Li           2016-04-25  510  	/* bio could be mergeable after passing to underlayer */
1eff9d322a4442 Jens Axboe           2016-08-05  511  	bio->bi_opf &= ~REQ_NOMERGE;
393debc23c7820 Shaohua Li           2017-09-21  512  
393debc23c7820 Shaohua Li           2017-09-21  513  	md_handle_request(mddev, bio);
490773268cf64f NeilBrown            2010-03-25  514  
dece16353ef47d Jens Axboe           2015-11-05  515  	return BLK_QC_T_NONE;
409c57f3801701 NeilBrown            2009-03-31  516  }
409c57f3801701 NeilBrown            2009-03-31  517  

:::::: The code at line 485 was first introduced by commit
:::::: e91ece5590b3c728624ab57043fc7a05069c604a md_make_request: don't touch the bio after calling make_request

:::::: TO: Chris Mason <chris.mason@oracle.com>
:::::: CC: NeilBrown <neilb@suse.de>

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

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

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
@ 2020-06-09  6:37   ` kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2020-06-09  6:37 UTC (permalink / raw)
  To: kbuild-all

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

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on next-20200608]
[cannot apply to v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/jeffm-suse-com/mdraid-fix-read-write-bytes-accounting/20200607-085457
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b170290c2836c40ab565736ba37681eb3dfd79b8
config: m68k-randconfig-r011-20200607 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        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
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

drivers/md/md.c: In function 'md_make_request':
>> drivers/md/md.c:485:15: warning: variable 'sectors' set but not used [-Wunused-but-set-variable]
485 |  unsigned int sectors;
|               ^~~~~~~
drivers/md/md.c: In function 'bind_rdev_to_array':
drivers/md/md.c:2454:27: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
2454 |   /* failure here is OK */;
|                           ^
drivers/md/md.c: In function 'slot_store':
drivers/md/md.c:3215:28: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
3215 |    /* failure here is OK */;
|                            ^
drivers/md/md.c: In function 'remove_and_add_spares':
drivers/md/md.c:9073:29: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
9073 |     /* failure here is OK */;
|                             ^

vim +/sectors +485 drivers/md/md.c

eb17e42dfd959c Jeff Mahoney         2020-06-05  480  
dece16353ef47d Jens Axboe           2015-11-05  481  static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
^1da177e4c3f41 Linus Torvalds       2005-04-16  482  {
490773268cf64f NeilBrown            2010-03-25  483  	const int rw = bio_data_dir(bio);
e4fc5a74293fbe Christoph Hellwig    2020-05-08  484  	struct mddev *mddev = bio->bi_disk->private_data;
e91ece5590b3c7 Chris Mason          2011-02-07 @485  	unsigned int sectors;
490773268cf64f NeilBrown            2010-03-25  486  
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  487  	if (unlikely(test_bit(MD_BROKEN, &mddev->flags)) && (rw == WRITE)) {
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  488  		bio_io_error(bio);
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  489  		return BLK_QC_T_NONE;
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  490  	}
62f7b1989c02fe Guilherme G. Piccoli 2019-09-03  491  
af67c31fba3b87 NeilBrown            2017-06-18  492  	blk_queue_split(q, &bio);
54efd50bfd873e Kent Overstreet      2015-04-23  493  
274d8cbde1bc3b NeilBrown            2016-01-04  494  	if (mddev == NULL || mddev->pers == NULL) {
6712ecf8f64811 NeilBrown            2007-09-27  495  		bio_io_error(bio);
dece16353ef47d Jens Axboe           2015-11-05  496  		return BLK_QC_T_NONE;
^1da177e4c3f41 Linus Torvalds       2005-04-16  497  	}
bbfa57c0f2243a Sebastian Riemer     2013-02-21  498  	if (mddev->ro == 1 && unlikely(rw == WRITE)) {
4246a0b63bd8f5 Christoph Hellwig    2015-07-20  499  		if (bio_sectors(bio) != 0)
4e4cbee93d5613 Christoph Hellwig    2017-06-03  500  			bio->bi_status = BLK_STS_IOERR;
4246a0b63bd8f5 Christoph Hellwig    2015-07-20  501  		bio_endio(bio);
dece16353ef47d Jens Axboe           2015-11-05  502  		return BLK_QC_T_NONE;
bbfa57c0f2243a Sebastian Riemer     2013-02-21  503  	}
490773268cf64f NeilBrown            2010-03-25  504  
e91ece5590b3c7 Chris Mason          2011-02-07  505  	/*
e91ece5590b3c7 Chris Mason          2011-02-07  506  	 * save the sectors now since our bio can
e91ece5590b3c7 Chris Mason          2011-02-07  507  	 * go away inside make_request
e91ece5590b3c7 Chris Mason          2011-02-07  508  	 */
e91ece5590b3c7 Chris Mason          2011-02-07  509  	sectors = bio_sectors(bio);
9c573de3283af0 Shaohua Li           2016-04-25  510  	/* bio could be mergeable after passing to underlayer */
1eff9d322a4442 Jens Axboe           2016-08-05  511  	bio->bi_opf &= ~REQ_NOMERGE;
393debc23c7820 Shaohua Li           2017-09-21  512  
393debc23c7820 Shaohua Li           2017-09-21  513  	md_handle_request(mddev, bio);
490773268cf64f NeilBrown            2010-03-25  514  
dece16353ef47d Jens Axboe           2015-11-05  515  	return BLK_QC_T_NONE;
409c57f3801701 NeilBrown            2009-03-31  516  }
409c57f3801701 NeilBrown            2009-03-31  517  

:::::: The code at line 485 was first introduced by commit
:::::: e91ece5590b3c728624ab57043fc7a05069c604a md_make_request: don't touch the bio after calling make_request

:::::: TO: Chris Mason <chris.mason@oracle.com>
:::::: CC: NeilBrown <neilb@suse.de>

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

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

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
  2020-06-08  7:13 ` Artur Paszkiewicz
@ 2020-06-23 14:21   ` Guoqing Jiang
  2020-06-23 16:48     ` Artur Paszkiewicz
  2020-06-23 14:24   ` Jeff Mahoney
  1 sibling, 1 reply; 8+ messages in thread
From: Guoqing Jiang @ 2020-06-23 14:21 UTC (permalink / raw)
  To: Artur Paszkiewicz, jeffm, linux-raid, song; +Cc: nfbrown, colyli

Hi Artur,

On 6/8/20 9:13 AM, Artur Paszkiewicz wrote:
> On 6/5/20 10:19 PM, jeffm@suse.com wrote:
>> The i/o accounting published in /proc/diskstats for mdraid is currently
>> broken.  md_make_request does the accounting for every bio passed but
>> when a bio needs to be split, all the split bios are also submitted
>> through md_make_request, resulting in multiple accounting.
> Hi Jeff,
>
> I sent a patch a few days ago which should fix this issue. Can you check
> it out?
>
> https://marc.info/?l=linux-raid&m=159102814820539

I need to account some extra statistics for bio such as latency and size,
so it is kind of relies on your patch, then I read the code again.

And besides my previous comment. I think you don't need clone bio for all
personalities. For md-multipath, raid1 and raid10, you can track the start
time by add it to those structures (multipath_bh, r1bio and r10bio), then
one extra copy could be avoided.

What do you think?

Thanks,
Guoqing

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
  2020-06-08  7:13 ` Artur Paszkiewicz
  2020-06-23 14:21   ` Guoqing Jiang
@ 2020-06-23 14:24   ` Jeff Mahoney
  1 sibling, 0 replies; 8+ messages in thread
From: Jeff Mahoney @ 2020-06-23 14:24 UTC (permalink / raw)
  To: Artur Paszkiewicz, linux-raid, song; +Cc: nfbrown, colyli


[-- Attachment #1.1.1: Type: text/plain, Size: 700 bytes --]

On 6/8/20 3:13 AM, Artur Paszkiewicz wrote:
> On 6/5/20 10:19 PM, jeffm@suse.com wrote:
>> The i/o accounting published in /proc/diskstats for mdraid is currently
>> broken.  md_make_request does the accounting for every bio passed but
>> when a bio needs to be split, all the split bios are also submitted
>> through md_make_request, resulting in multiple accounting.
> 
> Hi Jeff,
> 
> I sent a patch a few days ago which should fix this issue. Can you check
> it out?
> 
> https://marc.info/?l=linux-raid&m=159102814820539

It scratches the same itch.  I just didn't want to clone every bio just 
to get stats.

-Jeff

-- 
Jeff Mahoney
Director, SUSE Labs Data & Performance

[-- Attachment #1.1.2: OpenPGP_0x1E7B4B632179E5B2.asc --]
[-- Type: application/pgp-keys, Size: 80367 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
  2020-06-23 14:21   ` Guoqing Jiang
@ 2020-06-23 16:48     ` Artur Paszkiewicz
  2020-06-25  9:13       ` Guoqing Jiang
  0 siblings, 1 reply; 8+ messages in thread
From: Artur Paszkiewicz @ 2020-06-23 16:48 UTC (permalink / raw)
  To: Guoqing Jiang, jeffm, linux-raid, song; +Cc: nfbrown, colyli

On 6/23/20 4:21 PM, Guoqing Jiang wrote:
> Hi Artur,
> 
> On 6/8/20 9:13 AM, Artur Paszkiewicz wrote:
>> On 6/5/20 10:19 PM, jeffm@suse.com wrote:
>>> The i/o accounting published in /proc/diskstats for mdraid is currently
>>> broken.  md_make_request does the accounting for every bio passed but
>>> when a bio needs to be split, all the split bios are also submitted
>>> through md_make_request, resulting in multiple accounting.
>> Hi Jeff,
>>
>> I sent a patch a few days ago which should fix this issue. Can you check
>> it out?
>>
>> https://marc.info/?l=linux-raid&m=159102814820539
> 
> I need to account some extra statistics for bio such as latency and size,
> so it is kind of relies on your patch, then I read the code again.
> 
> And besides my previous comment. I think you don't need clone bio for all
> personalities. For md-multipath, raid1 and raid10, you can track the start
> time by add it to those structures (multipath_bh, r1bio and r10bio), then
> one extra copy could be avoided.
> 
> What do you think?

You're right, cloning can be avoided for those personalities. I wanted
to keep it clean and centralized in the generic md code. I think we
should have a common completion callback and some common request
structure for all md personalities, like struct md_io which I'm using in
my patch. How about we add it to the existing stucts like r1bio etc. and
use that for io accounting, and clone the bio with the struct otherwise?
Or maybe remove the cloning from the personalities and instead make the
bio cloned in md_make_request available to them? Does this make sense?

Thanks,
Artur

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

* Re: [PATCH] mdraid: fix read/write bytes accounting
  2020-06-23 16:48     ` Artur Paszkiewicz
@ 2020-06-25  9:13       ` Guoqing Jiang
  0 siblings, 0 replies; 8+ messages in thread
From: Guoqing Jiang @ 2020-06-25  9:13 UTC (permalink / raw)
  To: Artur Paszkiewicz, jeffm, linux-raid, song; +Cc: nfbrown, colyli



On 6/23/20 6:48 PM, Artur Paszkiewicz wrote:
> On 6/23/20 4:21 PM, Guoqing Jiang wrote:
>> Hi Artur,
>>
>> On 6/8/20 9:13 AM, Artur Paszkiewicz wrote:
>>> On 6/5/20 10:19 PM, jeffm@suse.com wrote:
>>>> The i/o accounting published in /proc/diskstats for mdraid is currently
>>>> broken.  md_make_request does the accounting for every bio passed but
>>>> when a bio needs to be split, all the split bios are also submitted
>>>> through md_make_request, resulting in multiple accounting.
>>> Hi Jeff,
>>>
>>> I sent a patch a few days ago which should fix this issue. Can you check
>>> it out?
>>>
>>> https://marc.info/?l=linux-raid&m=159102814820539
>> I need to account some extra statistics for bio such as latency and size,
>> so it is kind of relies on your patch, then I read the code again.
>>
>> And besides my previous comment. I think you don't need clone bio for all
>> personalities. For md-multipath, raid1 and raid10, you can track the start
>> time by add it to those structures (multipath_bh, r1bio and r10bio), then
>> one extra copy could be avoided.
>>
>> What do you think?
> You're right, cloning can be avoided for those personalities. I wanted
> to keep it clean and centralized in the generic md code. I think we
> should have a common completion callback and some common request
> structure for all md personalities, like struct md_io which I'm using in
> my patch.How about we add it to the existing stucts like r1bio etc. and
> use that for io accounting, and clone the bio with the struct otherwise?
> Or maybe remove the cloning from the personalities and instead make the
> bio cloned in md_make_request available to them? Does this make sense?

Centralization definitely has it's advantage, but given the difference
among personalities, not sure it is possible or make sense to clone bio
in common md layer.

For raid1/10, we at least need to care about barrier and read balance
before clone bio, and I would prefer to not change current mechanism
since it is really a big modification from my understanding.

Thanks,
Guoqing

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

end of thread, other threads:[~2020-06-25  9:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 20:19 [PATCH] mdraid: fix read/write bytes accounting jeffm
2020-06-08  7:13 ` Artur Paszkiewicz
2020-06-23 14:21   ` Guoqing Jiang
2020-06-23 16:48     ` Artur Paszkiewicz
2020-06-25  9:13       ` Guoqing Jiang
2020-06-23 14:24   ` Jeff Mahoney
2020-06-09  6:37 ` kernel test robot
2020-06-09  6:37   ` kernel 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.