All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
@ 2018-10-04 17:35 Bart Van Assche
  2018-10-05  5:48 ` Hannes Reinecke
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Bart Van Assche @ 2018-10-04 17:35 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Ming Lei,
	Hannes Reinecke, Johannes Thumshirn, Martin K . Petersen

When debugging e.g. the SCSI timeout handler it is important that
requests that have not yet been started or that already have
completed are also reported through debugfs.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
---
 block/blk-mq-debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index a5ea86835fcb..41b86f50d126 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -431,8 +431,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
 {
 	const struct show_busy_params *params = data;
 
-	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
-	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
+	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx)
 		__blk_mq_debugfs_rq_show(params->m,
 					 list_entry_rq(&rq->queuelist));
 }
-- 
2.19.0.605.g01d371f741-goog

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-04 17:35 [PATCH] blk-mq-debugfs: Also show requests that have not yet been started Bart Van Assche
@ 2018-10-05  5:48 ` Hannes Reinecke
  2018-10-05  7:06 ` Johannes Thumshirn
  2018-10-05 14:18 ` Jens Axboe
  2 siblings, 0 replies; 17+ messages in thread
From: Hannes Reinecke @ 2018-10-05  5:48 UTC (permalink / raw)
  To: Bart Van Assche, Jens Axboe
  Cc: linux-block, Christoph Hellwig, Ming Lei, Hannes Reinecke,
	Johannes Thumshirn, Martin K . Petersen

On 10/4/18 7:35 PM, Bart Van Assche wrote:
> When debugging e.g. the SCSI timeout handler it is important that
> requests that have not yet been started or that already have
> completed are also reported through debugfs.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> ---
>   block/blk-mq-debugfs.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
> index a5ea86835fcb..41b86f50d126 100644
> --- a/block/blk-mq-debugfs.c
> +++ b/block/blk-mq-debugfs.c
> @@ -431,8 +431,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
>   {
>   	const struct show_busy_params *params = data;
>   
> -	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
> -	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
> +	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx)
>   		__blk_mq_debugfs_rq_show(params->m,
>   					 list_entry_rq(&rq->queuelist));
>   }
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-04 17:35 [PATCH] blk-mq-debugfs: Also show requests that have not yet been started Bart Van Assche
  2018-10-05  5:48 ` Hannes Reinecke
@ 2018-10-05  7:06 ` Johannes Thumshirn
  2018-10-05 14:18 ` Jens Axboe
  2 siblings, 0 replies; 17+ messages in thread
From: Johannes Thumshirn @ 2018-10-05  7:06 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Jens Axboe, linux-block, Christoph Hellwig, Ming Lei,
	Hannes Reinecke, Martin K . Petersen

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-04 17:35 [PATCH] blk-mq-debugfs: Also show requests that have not yet been started Bart Van Assche
  2018-10-05  5:48 ` Hannes Reinecke
  2018-10-05  7:06 ` Johannes Thumshirn
@ 2018-10-05 14:18 ` Jens Axboe
  2018-10-05 22:37   ` Omar Sandoval
  2 siblings, 1 reply; 17+ messages in thread
From: Jens Axboe @ 2018-10-05 14:18 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-block, Christoph Hellwig, Ming Lei, Hannes Reinecke,
	Johannes Thumshirn, Martin K . Petersen

On 10/4/18 11:35 AM, Bart Van Assche wrote:
> When debugging e.g. the SCSI timeout handler it is important that
> requests that have not yet been started or that already have
> completed are also reported through debugfs.

Thanks, I like this better - applied. BTW, what's up with the
reverse ordering on this:

> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>

For some reason that really annoys me, and I see it in various
patches these days. IMHO the SOB should be last, with whatever
acks, reviews, CC, before that.

-- 
Jens Axboe

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-05 14:18 ` Jens Axboe
@ 2018-10-05 22:37   ` Omar Sandoval
  2018-10-06  1:13     ` Jens Axboe
  0 siblings, 1 reply; 17+ messages in thread
From: Omar Sandoval @ 2018-10-05 22:37 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Bart Van Assche, linux-block, Christoph Hellwig, Ming Lei,
	Hannes Reinecke, Johannes Thumshirn, Martin K . Petersen

On Fri, Oct 05, 2018 at 08:18:00AM -0600, Jens Axboe wrote:
> On 10/4/18 11:35 AM, Bart Van Assche wrote:
> > When debugging e.g. the SCSI timeout handler it is important that
> > requests that have not yet been started or that already have
> > completed are also reported through debugfs.
> 
> Thanks, I like this better - applied. BTW, what's up with the
> reverse ordering on this:
> 
> > Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Ming Lei <ming.lei@redhat.com>
> > Cc: Hannes Reinecke <hare@suse.com>
> > Cc: Johannes Thumshirn <jthumshirn@suse.de>
> > Cc: Martin K. Petersen <martin.petersen@oracle.com>
> 
> For some reason that really annoys me, and I see it in various
> patches these days. IMHO the SOB should be last, with whatever
> acks, reviews, CC, before that.

I could've sworn that this guideline was even documented somewhere, but
I can't find it now ¯\_(ツ)_/¯

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-05 22:37   ` Omar Sandoval
@ 2018-10-06  1:13     ` Jens Axboe
  2018-10-08  9:15       ` Johannes Thumshirn
  0 siblings, 1 reply; 17+ messages in thread
From: Jens Axboe @ 2018-10-06  1:13 UTC (permalink / raw)
  To: Omar Sandoval
  Cc: Bart Van Assche, linux-block, Christoph Hellwig, Ming Lei,
	Hannes Reinecke, Johannes Thumshirn, Martin K . Petersen

On 10/5/18 4:37 PM, Omar Sandoval wrote:
> On Fri, Oct 05, 2018 at 08:18:00AM -0600, Jens Axboe wrote:
>> On 10/4/18 11:35 AM, Bart Van Assche wrote:
>>> When debugging e.g. the SCSI timeout handler it is important that
>>> requests that have not yet been started or that already have
>>> completed are also reported through debugfs.
>>
>> Thanks, I like this better - applied. BTW, what's up with the
>> reverse ordering on this:
>>
>>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>>> Cc: Christoph Hellwig <hch@lst.de>
>>> Cc: Ming Lei <ming.lei@redhat.com>
>>> Cc: Hannes Reinecke <hare@suse.com>
>>> Cc: Johannes Thumshirn <jthumshirn@suse.de>
>>> Cc: Martin K. Petersen <martin.petersen@oracle.com>
>>
>> For some reason that really annoys me, and I see it in various
>> patches these days. IMHO the SOB should be last, with whatever
>> acks, reviews, CC, before that.
> 
> I could've sworn that this guideline was even documented somewhere, but
> I can't find it now ¯\_(ツ)_/¯

My guess is that it's some newer git thing - but if it is, it's really
annoying and should be reverted. I end up fixing these up by hand.

-- 
Jens Axboe

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-06  1:13     ` Jens Axboe
@ 2018-10-08  9:15       ` Johannes Thumshirn
  0 siblings, 0 replies; 17+ messages in thread
From: Johannes Thumshirn @ 2018-10-08  9:15 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Omar Sandoval, Bart Van Assche, linux-block, Christoph Hellwig,
	Ming Lei, Hannes Reinecke, Martin K . Petersen

On Fri, Oct 05, 2018 at 07:13:32PM -0600, Jens Axboe wrote:
> On 10/5/18 4:37 PM, Omar Sandoval wrote:
> > On Fri, Oct 05, 2018 at 08:18:00AM -0600, Jens Axboe wrote:
> >> On 10/4/18 11:35 AM, Bart Van Assche wrote:
> >>> When debugging e.g. the SCSI timeout handler it is important that
> >>> requests that have not yet been started or that already have
> >>> completed are also reported through debugfs.
> >>
> >> Thanks, I like this better - applied. BTW, what's up with the
> >> reverse ordering on this:
> >>
> >>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> >>> Cc: Christoph Hellwig <hch@lst.de>
> >>> Cc: Ming Lei <ming.lei@redhat.com>
> >>> Cc: Hannes Reinecke <hare@suse.com>
> >>> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> >>> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> >>
> >> For some reason that really annoys me, and I see it in various
> >> patches these days. IMHO the SOB should be last, with whatever
> >> acks, reviews, CC, before that.
> > 
> > I could've sworn that this guideline was even documented somewhere, but
> > I can't find it now ¯\_(ツ)_/¯
> 
> My guess is that it's some newer git thing - but if it is, it's really
> annoying and should be reverted. I end up fixing these up by hand.

Isn't it the way patchwork adds the tags? And yes I also thought this is the
correct way of adding the Ccs, etc..

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-03 22:51             ` Bart Van Assche
@ 2018-10-03 23:52               ` Jens Axboe
  0 siblings, 0 replies; 17+ messages in thread
From: Jens Axboe @ 2018-10-03 23:52 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: hch, jthumshirn, linux-block, martin.petersen, hare, ming.lei

On 10/3/18 4:51 PM, Bart Van Assche wrote:
> On Wed, 2018-10-03 at 16:12 -0600, Jens Axboe wrote:
>> On 10/3/18 3:42 PM, Bart Van Assche wrote:
>>> On Fri, 2018-01-12 at 22:11 +0000, Bart Van Assche wrote:
>>>>  /*
>>>> + * Show "busy" requests - these are the requests owned by the block driver.
>>>> + * The test list_empty(&rq->queuelist) is used to figure out whether or not
>>>> + * a request is owned by the block driver. That test works because the block
>>>> + * layer core uses list_del_init() consistently to remove a request from one
>>>> + * of the request lists.
>>>> + *
>>>>   * Note: the state of a request may change while this function is in progress,
>>>>   * e.g. due to a concurrent blk_mq_finish_request() call.
>>>>   */
>>>> @@ -402,7 +408,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
>>>>  	const struct show_busy_params *params = data;
>>>>  
>>>>  	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
>>>> -	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
>>>> +	    list_empty(&rq->queuelist))
>>>>  		__blk_mq_debugfs_rq_show(params->m,
>>>>  					 list_entry_rq(&rq->queuelist));
>>>>  }
>>>
>>> Hello Jens,
>>>
>>> Can you share your opinion about the above patch?
>>
>> I just convince myself that the list check is super useful. The request
>> could be on any number of lists, either not yet seen by the driver, or
>> maybe sitting in dispatch. You're only going to be finding these
>> requests if the tag is allocated, which means that it's already in some
>> sort of non-idle state.
>>
>> So enlighten me why we need the list check at all? Wouldn't it be better
>> to simply remove it, and ensure that the debug print includes things
>> like list state, rq state, etc?
> 
> Hello Jens,
> 
> I have tried to leave the list_empty() check out but if I do that then
> requests that have the state "idle" (allocated but not yet started) also
> show up. I think these should be left out from the output produced by
> reading the "busy" attribute because such requests are not interesting
> when analyzing an I/O lockup:
> 
> nullb0/hctx1/busy:00000000abe67123 {.op=READ, .cmd_flags=, .rq_flags=IO_STAT|STATS, .s
> tate=idle, .tag=63, .internal_tag=-1}

They might be, if we have allocated tags that aren't going anywhere.
Like in a tag leak, or something. Besides, requests should exist in that
state very shortly, so it's not like it should cloud the output that
much.

-- 
Jens Axboe

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-03 22:12           ` Jens Axboe
@ 2018-10-03 22:51             ` Bart Van Assche
  2018-10-03 23:52               ` Jens Axboe
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Van Assche @ 2018-10-03 22:51 UTC (permalink / raw)
  To: Jens Axboe; +Cc: hch, jthumshirn, linux-block, martin.petersen, hare, ming.lei

On Wed, 2018-10-03 at 16:12 -0600, Jens Axboe wrote:
> On 10/3/18 3:42 PM, Bart Van Assche wrote:
> > On Fri, 2018-01-12 at 22:11 +0000, Bart Van Assche wrote:
> > >  /*
> > > + * Show "busy" requests - these are the requests owned by the block driver.
> > > + * The test list_empty(&rq->queuelist) is used to figure out whether or not
> > > + * a request is owned by the block driver. That test works because the block
> > > + * layer core uses list_del_init() consistently to remove a request from one
> > > + * of the request lists.
> > > + *
> > >   * Note: the state of a request may change while this function is in progress,
> > >   * e.g. due to a concurrent blk_mq_finish_request() call.
> > >   */
> > > @@ -402,7 +408,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
> > >  	const struct show_busy_params *params = data;
> > >  
> > >  	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
> > > -	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
> > > +	    list_empty(&rq->queuelist))
> > >  		__blk_mq_debugfs_rq_show(params->m,
> > >  					 list_entry_rq(&rq->queuelist));
> > >  }
> > 
> > Hello Jens,
> > 
> > Can you share your opinion about the above patch?
> 
> I just convince myself that the list check is super useful. The request
> could be on any number of lists, either not yet seen by the driver, or
> maybe sitting in dispatch. You're only going to be finding these
> requests if the tag is allocated, which means that it's already in some
> sort of non-idle state.
> 
> So enlighten me why we need the list check at all? Wouldn't it be better
> to simply remove it, and ensure that the debug print includes things
> like list state, rq state, etc?

Hello Jens,

I have tried to leave the list_empty() check out but if I do that then
requests that have the state "idle" (allocated but not yet started) also
show up. I think these should be left out from the output produced by
reading the "busy" attribute because such requests are not interesting
when analyzing an I/O lockup:

nullb0/hctx1/busy:00000000abe67123 {.op=READ, .cmd_flags=, .rq_flags=IO_STAT|STATS, .s
tate=idle, .tag=63, .internal_tag=-1}

Thanks,

Bart.

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-10-03 21:42         ` Bart Van Assche
@ 2018-10-03 22:12           ` Jens Axboe
  2018-10-03 22:51             ` Bart Van Assche
  0 siblings, 1 reply; 17+ messages in thread
From: Jens Axboe @ 2018-10-03 22:12 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: hch, jthumshirn, linux-block, martin.petersen, hare, ming.lei

On 10/3/18 3:42 PM, Bart Van Assche wrote:
> On Fri, 2018-01-12 at 22:11 +0000, Bart Van Assche wrote:
>> On Fri, 2018-01-12 at 15:05 -0700, Jens Axboe wrote:
>>> On 1/12/18 3:00 PM, Bart Van Assche wrote:
>>>> On Fri, 2018-01-12 at 14:55 -0700, Jens Axboe wrote:
>>>>> On 1/12/18 2:52 PM, Bart Van Assche wrote:
>>>>>> When debugging e.g. the SCSI timeout handler it is important that
>>>>>> requests that have not yet been started or that already have
>>>>>> completed are also reported through debugfs.
>>>>>>
>>>>>> This patch depends on a patch that went upstream recently, namely
>>>>>> commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL pointer
>>>>>> dereference").
>>>>>
>>>>> Why don't we just kill the check, and dump any request that has a
>>>>> matching hctx? We already know the bit was set, so just print
>>>>> all of them.
>>>>
>>>> It is very helpful during debugging that requests owned by a block driver and
>>>> requests owned by the block layer core show up in different debugfs files.
>>>> Removing the check completely would cause all requests to show up in the same
>>>> debugfs file and would make interpreting the contents of these debugfs files
>>>> much harder.
>>>
>>> Yeah, we'd have to make it just one file at that point. I'm not hugely
>>> against the queuelist check, but probably warrants a comment as it's not
>>> immediately clear (as opposed to the idle check, or the previous START
>>> bit check).
>>
>> How about the below?
>>
>> diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
>> index 19db3f583bf1..da859dac442b 100644
>> --- a/block/blk-mq-debugfs.c
>> +++ b/block/blk-mq-debugfs.c
>> @@ -394,6 +394,12 @@ struct show_busy_params {
>>  };
>>  
>>  /*
>> + * Show "busy" requests - these are the requests owned by the block driver.
>> + * The test list_empty(&rq->queuelist) is used to figure out whether or not
>> + * a request is owned by the block driver. That test works because the block
>> + * layer core uses list_del_init() consistently to remove a request from one
>> + * of the request lists.
>> + *
>>   * Note: the state of a request may change while this function is in progress,
>>   * e.g. due to a concurrent blk_mq_finish_request() call.
>>   */
>> @@ -402,7 +408,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
>>  	const struct show_busy_params *params = data;
>>  
>>  	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
>> -	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
>> +	    list_empty(&rq->queuelist))
>>  		__blk_mq_debugfs_rq_show(params->m,
>>  					 list_entry_rq(&rq->queuelist));
>>  }
> 
> Hello Jens,
> 
> Can you share your opinion about the above patch?

I just convince myself that the list check is super useful. The request
could be on any number of lists, either not yet seen by the driver, or
maybe sitting in dispatch. You're only going to be finding these
requests if the tag is allocated, which means that it's already in some
sort of non-idle state.

So enlighten me why we need the list check at all? Wouldn't it be better
to simply remove it, and ensure that the debug print includes things
like list state, rq state, etc?

-- 
Jens Axboe

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-01-12 22:11       ` Bart Van Assche
@ 2018-10-03 21:42         ` Bart Van Assche
  2018-10-03 22:12           ` Jens Axboe
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Van Assche @ 2018-10-03 21:42 UTC (permalink / raw)
  To: axboe; +Cc: hch, jthumshirn, linux-block, martin.petersen, hare, ming.lei

On Fri, 2018-01-12 at 22:11 +0000, Bart Van Assche wrote:
> On Fri, 2018-01-12 at 15:05 -0700, Jens Axboe wrote:
> > On 1/12/18 3:00 PM, Bart Van Assche wrote:
> > > On Fri, 2018-01-12 at 14:55 -0700, Jens Axboe wrote:
> > > > On 1/12/18 2:52 PM, Bart Van Assche wrote:
> > > > > When debugging e.g. the SCSI timeout handler it is important that
> > > > > requests that have not yet been started or that already have
> > > > > completed are also reported through debugfs.
> > > > > 
> > > > > This patch depends on a patch that went upstream recently, namely
> > > > > commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL pointer
> > > > > dereference").
> > > > 
> > > > Why don't we just kill the check, and dump any request that has a
> > > > matching hctx? We already know the bit was set, so just print
> > > > all of them.
> > > 
> > > It is very helpful during debugging that requests owned by a block driver and
> > > requests owned by the block layer core show up in different debugfs files.
> > > Removing the check completely would cause all requests to show up in the same
> > > debugfs file and would make interpreting the contents of these debugfs files
> > > much harder.
> > 
> > Yeah, we'd have to make it just one file at that point. I'm not hugely
> > against the queuelist check, but probably warrants a comment as it's not
> > immediately clear (as opposed to the idle check, or the previous START
> > bit check).
> 
> How about the below?
> 
> diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
> index 19db3f583bf1..da859dac442b 100644
> --- a/block/blk-mq-debugfs.c
> +++ b/block/blk-mq-debugfs.c
> @@ -394,6 +394,12 @@ struct show_busy_params {
>  };
>  
>  /*
> + * Show "busy" requests - these are the requests owned by the block driver.
> + * The test list_empty(&rq->queuelist) is used to figure out whether or not
> + * a request is owned by the block driver. That test works because the block
> + * layer core uses list_del_init() consistently to remove a request from one
> + * of the request lists.
> + *
>   * Note: the state of a request may change while this function is in progress,
>   * e.g. due to a concurrent blk_mq_finish_request() call.
>   */
> @@ -402,7 +408,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
>  	const struct show_busy_params *params = data;
>  
>  	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
> -	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
> +	    list_empty(&rq->queuelist))
>  		__blk_mq_debugfs_rq_show(params->m,
>  					 list_entry_rq(&rq->queuelist));
>  }

Hello Jens,

Can you share your opinion about the above patch?

Thanks,

Bart.

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

* [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
@ 2018-02-12 17:02 Bart Van Assche
  0 siblings, 0 replies; 17+ messages in thread
From: Bart Van Assche @ 2018-02-12 17:02 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Ming Lei,
	Hannes Reinecke, Johannes Thumshirn, Martin K . Petersen

When debugging e.g. the SCSI timeout handler it is important that
requests that have not yet been started or that already have
completed are also reported through debugfs.

This patch depends on a patch that went upstream in kernel v4.15,
namely commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL
pointer dereference").

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
---
 block/blk-mq-debugfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index c62a3704515b..bcb64b2f8090 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -401,6 +401,12 @@ struct show_busy_params {
 };
 
 /*
+ * Show "busy" requests - these are the requests owned by the block driver.
+ * The test list_empty(&rq->queuelist) is used to figure out whether or not
+ * a request is owned by the block driver. That test works because the block
+ * layer core uses list_del_init() consistently to remove a request from one
+ * of the request lists.
+ *
  * Note: the state of a request may change while this function is in progress,
  * e.g. due to a concurrent blk_mq_finish_request() call.
  */
@@ -409,7 +415,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
 	const struct show_busy_params *params = data;
 
 	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
-	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
+	    list_empty(&rq->queuelist))
 		__blk_mq_debugfs_rq_show(params->m,
 					 list_entry_rq(&rq->queuelist));
 }
-- 
2.16.1

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-01-12 22:05     ` Jens Axboe
@ 2018-01-12 22:11       ` Bart Van Assche
  2018-10-03 21:42         ` Bart Van Assche
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Van Assche @ 2018-01-12 22:11 UTC (permalink / raw)
  To: axboe; +Cc: hch, jthumshirn, linux-block, martin.petersen, hare, ming.lei

T24gRnJpLCAyMDE4LTAxLTEyIGF0IDE1OjA1IC0wNzAwLCBKZW5zIEF4Ym9lIHdyb3RlOg0KPiBP
biAxLzEyLzE4IDM6MDAgUE0sIEJhcnQgVmFuIEFzc2NoZSB3cm90ZToNCj4gPiBPbiBGcmksIDIw
MTgtMDEtMTIgYXQgMTQ6NTUgLTA3MDAsIEplbnMgQXhib2Ugd3JvdGU6DQo+ID4gPiBPbiAxLzEy
LzE4IDI6NTIgUE0sIEJhcnQgVmFuIEFzc2NoZSB3cm90ZToNCj4gPiA+ID4gV2hlbiBkZWJ1Z2dp
bmcgZS5nLiB0aGUgU0NTSSB0aW1lb3V0IGhhbmRsZXIgaXQgaXMgaW1wb3J0YW50IHRoYXQNCj4g
PiA+ID4gcmVxdWVzdHMgdGhhdCBoYXZlIG5vdCB5ZXQgYmVlbiBzdGFydGVkIG9yIHRoYXQgYWxy
ZWFkeSBoYXZlDQo+ID4gPiA+IGNvbXBsZXRlZCBhcmUgYWxzbyByZXBvcnRlZCB0aHJvdWdoIGRl
YnVnZnMuDQo+ID4gPiA+IA0KPiA+ID4gPiBUaGlzIHBhdGNoIGRlcGVuZHMgb24gYSBwYXRjaCB0
aGF0IHdlbnQgdXBzdHJlYW0gcmVjZW50bHksIG5hbWVseQ0KPiA+ID4gPiBjb21taXQgMTRlMzA2
MmZiMTg1ICgic2NzaTogY29yZTogRml4IGEgc2NzaV9zaG93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NCkBAIC00MDIs
NyArNDA4LDcgQEAgc3RhdGljIHZvaWQgaGN0eF9zaG93X2J1c3lfcnEoc3RydWN0IHJlcXVlc3Qg
KnJxLCB2b2lkICpkYXRhLCBib29sIHJlc2VydmVkKQ0KIAljb25zdCBzdHJ1Y3Qgc2hvd19idXN5
X3BhcmFtcyAqcGFyYW1zID0gZGF0YTsNCiANCiAJaWYgKGJsa19tcV9tYXBfcXVldWUocnEtPnEs
IHJxLT5tcV9jdHgtPmNwdSkgPT0gcGFyYW1zLT5oY3R4ICYmDQotCSAgICBibGtfbXFfcnFfc3Rh
dGUocnEpICE9IE1RX1JRX0lETEUpDQorCSAgICBsaXN0X2VtcHR5KCZycS0+cXVldWVsaXN0KSkN
CiAJCV9fYmxrX21xX2RlYnVnZnNfcnFfc2hvdyhwYXJhbXMtPm0sDQogCQkJCQkgbGlzdF9lbnRy
eV9ycSgmcnEtPnF1ZXVlbGlzdCkpOw0KIH0NCg0KVGhhbmtzLA0KDQpCYXJ0Lg==

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-01-12 22:00   ` Bart Van Assche
@ 2018-01-12 22:05     ` Jens Axboe
  2018-01-12 22:11       ` Bart Van Assche
  0 siblings, 1 reply; 17+ messages in thread
From: Jens Axboe @ 2018-01-12 22:05 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: hch, jthumshirn, linux-block, hare, martin.petersen, ming.lei

On 1/12/18 3:00 PM, Bart Van Assche wrote:
> On Fri, 2018-01-12 at 14:55 -0700, Jens Axboe wrote:
>> On 1/12/18 2:52 PM, Bart Van Assche wrote:
>>> When debugging e.g. the SCSI timeout handler it is important that
>>> requests that have not yet been started or that already have
>>> completed are also reported through debugfs.
>>>
>>> This patch depends on a patch that went upstream recently, namely
>>> commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL pointer
>>> dereference").
>>
>> Why don't we just kill the check, and dump any request that has a
>> matching hctx? We already know the bit was set, so just print
>> all of them.
> 
> It is very helpful during debugging that requests owned by a block driver and
> requests owned by the block layer core show up in different debugfs files.
> Removing the check completely would cause all requests to show up in the same
> debugfs file and would make interpreting the contents of these debugfs files
> much harder.

Yeah, we'd have to make it just one file at that point. I'm not hugely
against the queuelist check, but probably warrants a comment as it's not
immediately clear (as opposed to the idle check, or the previous START
bit check).

-- 
Jens Axboe

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-01-12 21:55 ` Jens Axboe
@ 2018-01-12 22:00   ` Bart Van Assche
  2018-01-12 22:05     ` Jens Axboe
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Van Assche @ 2018-01-12 22:00 UTC (permalink / raw)
  To: axboe; +Cc: hch, jthumshirn, linux-block, hare, martin.petersen, ming.lei

T24gRnJpLCAyMDE4LTAxLTEyIGF0IDE0OjU1IC0wNzAwLCBKZW5zIEF4Ym9lIHdyb3RlOg0KPiBP
biAxLzEyLzE4IDI6NTIgUE0sIEJhcnQgVmFuIEFzc2NoZSB3cm90ZToNCj4gPiBXaGVuIGRlYnVn
Z2luZyBlLmcuIHRoZSBTQ1NJIHRpbWVvdXQgaGFuZGxlciBpdCBpcyBpbXBvcnRhbnQgdGhhdA0K
PiA+IHJlcXVlc3RzIHRoYXQgaGF2ZSBub3QgeWV0IGJlZW4gc3RhcnRlZCBvciB0aGF0IGFscmVh
ZHkgaGF2ZQ0KPiA+IGNvbXBsZXRlZCBhcmUgYWxzbyByZXBvcnRlZCB0aHJvdWdoIGRlYnVnZnMu
DQo+ID4gDQo+ID4gVGhpcyBwYXRjaCBkZXBlbmRzIG9uIGEgcGF0Y2ggdGhhdCB3ZW50IHVwc3Ry
ZWFtIHJlY2VudGx5LCBuYW1lbHkNCj4gPiBjb21taXQgMTRlMzA2MmZiMTg1ICgic2NzaTogY29y
ZTogRml4IGEgc2NzaV9zaG93X3JxKCkgTlVMTCBwb2ludGVyDQo+ID4gZGVyZWZlcmVuY2UiKS4N
Cj4gDQo+IFdoeSBkb24ndCB3ZSBqdXN0IGtpbGwgdGhlIGNoZWNrLCBhbmQgZHVtcCBhbnkgcmVx
dWVzdCB0aGF0IGhhcyBhDQo+IG1hdGNoaW5nIGhjdHg/IFdlIGFscmVhZHkga25vdyB0aGUgYml0
IHdhcyBzZXQsIHNvIGp1c3QgcHJpbnQNCj4gYWxsIG9mIHRoZW0uDQoNCkl0IGlzIHZlcnkgaGVs
cGZ1bCBkdXJpbmcgZGVidWdnaW5nIHRoYXQgcmVxdWVzdHMgb3duZWQgYnkgYSBibG9jayBkcml2
ZXIgYW5kDQpyZXF1ZXN0cyBvd25lZCBieSB0aGUgYmxvY2sgbGF5ZXIgY29yZSBzaG93IHVwIGlu
IGRpZmZlcmVudCBkZWJ1Z2ZzIGZpbGVzLg0KUmVtb3ZpbmcgdGhlIGNoZWNrIGNvbXBsZXRlbHkg
d291bGQgY2F1c2UgYWxsIHJlcXVlc3RzIHRvIHNob3cgdXAgaW4gdGhlIHNhbWUNCmRlYnVnZnMg
ZmlsZSBhbmQgd291bGQgbWFrZSBpbnRlcnByZXRpbmcgdGhlIGNvbnRlbnRzIG9mIHRoZXNlIGRl
YnVnZnMgZmlsZXMNCm11Y2ggaGFyZGVyLg0KDQpUaGFua3MsDQoNCkJhcnQu

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

* Re: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
  2018-01-12 21:52 Bart Van Assche
@ 2018-01-12 21:55 ` Jens Axboe
  2018-01-12 22:00   ` Bart Van Assche
  0 siblings, 1 reply; 17+ messages in thread
From: Jens Axboe @ 2018-01-12 21:55 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-block, Christoph Hellwig, Ming Lei, Hannes Reinecke,
	Johannes Thumshirn, Martin K . Petersen

On 1/12/18 2:52 PM, Bart Van Assche wrote:
> When debugging e.g. the SCSI timeout handler it is important that
> requests that have not yet been started or that already have
> completed are also reported through debugfs.
> 
> This patch depends on a patch that went upstream recently, namely
> commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL pointer
> dereference").

Why don't we just kill the check, and dump any request that has a
matching hctx? We already know the bit was set, so just print
all of them.

-- 
Jens Axboe

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

* [PATCH] blk-mq-debugfs: Also show requests that have not yet been started
@ 2018-01-12 21:52 Bart Van Assche
  2018-01-12 21:55 ` Jens Axboe
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Van Assche @ 2018-01-12 21:52 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Ming Lei,
	Hannes Reinecke, Johannes Thumshirn, Martin K . Petersen

When debugging e.g. the SCSI timeout handler it is important that
requests that have not yet been started or that already have
completed are also reported through debugfs.

This patch depends on a patch that went upstream recently, namely
commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL pointer
dereference").

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
---
 block/blk-mq-debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 19db3f583bf1..ccd5ef08c3f0 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -402,7 +402,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved)
 	const struct show_busy_params *params = data;
 
 	if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx &&
-	    blk_mq_rq_state(rq) != MQ_RQ_IDLE)
+	    list_empty(&rq->queuelist))
 		__blk_mq_debugfs_rq_show(params->m,
 					 list_entry_rq(&rq->queuelist));
 }
-- 
2.15.1

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

end of thread, other threads:[~2018-10-08  9:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04 17:35 [PATCH] blk-mq-debugfs: Also show requests that have not yet been started Bart Van Assche
2018-10-05  5:48 ` Hannes Reinecke
2018-10-05  7:06 ` Johannes Thumshirn
2018-10-05 14:18 ` Jens Axboe
2018-10-05 22:37   ` Omar Sandoval
2018-10-06  1:13     ` Jens Axboe
2018-10-08  9:15       ` Johannes Thumshirn
  -- strict thread matches above, loose matches on Subject: below --
2018-02-12 17:02 Bart Van Assche
2018-01-12 21:52 Bart Van Assche
2018-01-12 21:55 ` Jens Axboe
2018-01-12 22:00   ` Bart Van Assche
2018-01-12 22:05     ` Jens Axboe
2018-01-12 22:11       ` Bart Van Assche
2018-10-03 21:42         ` Bart Van Assche
2018-10-03 22:12           ` Jens Axboe
2018-10-03 22:51             ` Bart Van Assche
2018-10-03 23:52               ` Jens Axboe

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.