All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] block: fix inflight statistics of part0
@ 2020-12-02 11:11 Jeffle Xu
  2020-12-02 11:17 ` JeffleXu
  0 siblings, 1 reply; 6+ messages in thread
From: Jeffle Xu @ 2020-12-02 11:11 UTC (permalink / raw)
  To: axboe; +Cc: joseph.qi, hch, linux-block

The inflight of partition 0 doesn't include inflight IOs to all
sub-partitions, since currently mq calculates inflight of specific
partition by simply camparing the value of the partition pointer.

Thus the following case is possible:

$ cat /sys/block/vda/inflight
       0        0
$ cat /sys/block/vda/vda1/inflight
       0      128

While single queue device (on a previous version, e.g. v3.10) has no
this issue:

$cat /sys/block/sda/sda3/inflight
       0       33
$cat /sys/block/sda/inflight
       0       33

Partition 0 should be specially handled since it represents the whole
disk. This issue is introduced since commit bf0ddaba65dd ("blk-mq: fix
sysfs inflight counter").

Besides, this patch can also fix the inflight statistics of part 0 in
/proc/diskstats. Before this patch, the inflight statistics of part 0
doesn't include that of sub partitions. (I have marked the 'inflight'
field with asterisk.)

$cat /proc/diskstats
 259       0 nvme0n1 45974469 0 367814768 6445794 1 0 1 0 *0* 111062 6445794 0 0 0 0 0 0
 259       2 nvme0n1p1 45974058 0 367797952 6445727 0 0 0 0 *33* 111001 6445727 0 0 0 0 0 0

This is introduced since commit f299b7c7a9de ("blk-mq: provide internal
in-flight variant").

Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
v2: update the commit log, adding 'Fixes' tag
---
 block/blk-mq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 55bcee5dc032..04b6b4d21ce6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -105,7 +105,8 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
 {
 	struct mq_inflight *mi = priv;
 
-	if (rq->part == mi->part && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
+	if ((!mi->part->partno || rq->part == mi->part) &&
+	    blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
 		mi->inflight[rq_data_dir(rq)]++;
 
 	return true;
-- 
2.27.0


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

* Re: [PATCH v2] block: fix inflight statistics of part0
  2020-12-02 11:11 [PATCH v2] block: fix inflight statistics of part0 Jeffle Xu
@ 2020-12-02 11:17 ` JeffleXu
  2020-12-02 11:20   ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: JeffleXu @ 2020-12-02 11:17 UTC (permalink / raw)
  To: axboe; +Cc: joseph.qi, hch, linux-block



On 12/2/20 7:11 PM, Jeffle Xu wrote:
> The inflight of partition 0 doesn't include inflight IOs to all
> sub-partitions, since currently mq calculates inflight of specific
> partition by simply camparing the value of the partition pointer.
> 
> Thus the following case is possible:
> 
> $ cat /sys/block/vda/inflight
>        0        0
> $ cat /sys/block/vda/vda1/inflight
>        0      128
> 
> While single queue device (on a previous version, e.g. v3.10) has no
> this issue:
> 
> $cat /sys/block/sda/sda3/inflight
>        0       33
> $cat /sys/block/sda/inflight
>        0       33
> 
> Partition 0 should be specially handled since it represents the whole
> disk. This issue is introduced since commit bf0ddaba65dd ("blk-mq: fix
> sysfs inflight counter").
> 
> Besides, this patch can also fix the inflight statistics of part 0 in
> /proc/diskstats. Before this patch, the inflight statistics of part 0
> doesn't include that of sub partitions. (I have marked the 'inflight'
> field with asterisk.)
> 
> $cat /proc/diskstats
>  259       0 nvme0n1 45974469 0 367814768 6445794 1 0 1 0 *0* 111062 6445794 0 0 0 0 0 0
>  259       2 nvme0n1p1 45974058 0 367797952 6445727 0 0 0 0 *33* 111001 6445727 0 0 0 0 0 0
> 
> This is introduced since commit f299b7c7a9de ("blk-mq: provide internal
> in-flight variant").
> 
> Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
> Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> ---
> v2: update the commit log, adding 'Fixes' tag

Forgot to add 'stable' tag.

> ---
>  block/blk-mq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 55bcee5dc032..04b6b4d21ce6 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -105,7 +105,8 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
>  {
>  	struct mq_inflight *mi = priv;
>  
> -	if (rq->part == mi->part && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
> +	if ((!mi->part->partno || rq->part == mi->part) &&
> +	    blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
>  		mi->inflight[rq_data_dir(rq)]++;
>  
>  	return true;
> 

-- 
Thanks,
Jeffle

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

* Re: [PATCH v2] block: fix inflight statistics of part0
  2020-12-02 11:17 ` JeffleXu
@ 2020-12-02 11:20   ` Christoph Hellwig
  2020-12-02 16:48     ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2020-12-02 11:20 UTC (permalink / raw)
  To: JeffleXu; +Cc: axboe, joseph.qi, hch, linux-block

On Wed, Dec 02, 2020 at 07:17:55PM +0800, JeffleXu wrote:
> > Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
> > Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> > ---
> > v2: update the commit log, adding 'Fixes' tag
> 
> Forgot to add 'stable' tag.

The fixes tags take care of that automatically.

Note that this patch will cause a merge conflict with my work in
linux-next, but the resolution is pretty trivial.

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

* Re: [PATCH v2] block: fix inflight statistics of part0
  2020-12-02 11:20   ` Christoph Hellwig
@ 2020-12-02 16:48     ` Jens Axboe
  2020-12-02 19:05       ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2020-12-02 16:48 UTC (permalink / raw)
  To: Christoph Hellwig, JeffleXu; +Cc: joseph.qi, linux-block

On 12/2/20 4:20 AM, Christoph Hellwig wrote:
> On Wed, Dec 02, 2020 at 07:17:55PM +0800, JeffleXu wrote:
>>> Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
>>> Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
>>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>>> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
>>> ---
>>> v2: update the commit log, adding 'Fixes' tag
>>
>> Forgot to add 'stable' tag.
> 
> The fixes tags take care of that automatically.
> 
> Note that this patch will cause a merge conflict with my work in
> linux-next, but the resolution is pretty trivial.

Might be better to handle on the stable side, and just apply this to
5.11. It's not a new regression.

-- 
Jens Axboe


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

* Re: [PATCH v2] block: fix inflight statistics of part0
  2020-12-02 16:48     ` Jens Axboe
@ 2020-12-02 19:05       ` Christoph Hellwig
  2020-12-03  1:46         ` JeffleXu
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2020-12-02 19:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Christoph Hellwig, JeffleXu, joseph.qi, linux-block

On Wed, Dec 02, 2020 at 09:48:03AM -0700, Jens Axboe wrote:
> On 12/2/20 4:20 AM, Christoph Hellwig wrote:
> > On Wed, Dec 02, 2020 at 07:17:55PM +0800, JeffleXu wrote:
> >>> Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
> >>> Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
> >>> Reviewed-by: Christoph Hellwig <hch@lst.de>
> >>> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> >>> ---
> >>> v2: update the commit log, adding 'Fixes' tag
> >>
> >> Forgot to add 'stable' tag.
> > 
> > The fixes tags take care of that automatically.
> > 
> > Note that this patch will cause a merge conflict with my work in
> > linux-next, but the resolution is pretty trivial.
> 
> Might be better to handle on the stable side, and just apply this to
> 5.11. It's not a new regression.

If you apply it to for-5.11/block it won't compile.  It'll need a quick
s/partno/bd_partno/ there.

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

* Re: [PATCH v2] block: fix inflight statistics of part0
  2020-12-02 19:05       ` Christoph Hellwig
@ 2020-12-03  1:46         ` JeffleXu
  0 siblings, 0 replies; 6+ messages in thread
From: JeffleXu @ 2020-12-03  1:46 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: joseph.qi, linux-block



On 12/3/20 3:05 AM, Christoph Hellwig wrote:
> On Wed, Dec 02, 2020 at 09:48:03AM -0700, Jens Axboe wrote:
>> On 12/2/20 4:20 AM, Christoph Hellwig wrote:
>>> On Wed, Dec 02, 2020 at 07:17:55PM +0800, JeffleXu wrote:
>>>>> Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
>>>>> Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
>>>>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>>>>> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
>>>>> ---
>>>>> v2: update the commit log, adding 'Fixes' tag
>>>>
>>>> Forgot to add 'stable' tag.
>>>
>>> The fixes tags take care of that automatically.
>>>
>>> Note that this patch will cause a merge conflict with my work in
>>> linux-next, but the resolution is pretty trivial.
>>
>> Might be better to handle on the stable side, and just apply this to
>> 5.11. It's not a new regression.
> 
> If you apply it to for-5.11/block it won't compile.  It'll need a quick
> s/partno/bd_partno/ there.
> 

Fine. I will resend a new version later on the code base of for-5.11/block.

-- 
Thanks,
Jeffle

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

end of thread, other threads:[~2020-12-03  1:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 11:11 [PATCH v2] block: fix inflight statistics of part0 Jeffle Xu
2020-12-02 11:17 ` JeffleXu
2020-12-02 11:20   ` Christoph Hellwig
2020-12-02 16:48     ` Jens Axboe
2020-12-02 19:05       ` Christoph Hellwig
2020-12-03  1:46         ` JeffleXu

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.