blk-mq-debugfs: Also show requests that have not yet been started
PATCH 1/1 blk-mq-debugfs: Also show requests that have not yet been started
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").
--- block/blk-mq-debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq-debugfs.c +1 -1
@@ -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)); }
Signature · 1 line
2.15.1
Jens Axboe
maintainerQuoted 7 lines · Bart Van Assche
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 ascsi_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.
Signature · 1 line
Jens Axboe
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
Jens Axboe
maintainerQuoted 14 lines · Bart Van Assche
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Bart Van Assche
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.
Quoted 7 lines
Quoted 3 lines
This patch depends on a patch that went upstream recently, namely commit
14e3062fb185("scsi: core: Fix ascsi_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.
Quoted 5 lines
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).
Signature · 1 line
Jens Axboe
T24gRnJpLCAyMDE4LTAxLTEyIGF0IDE1OjA1IC0wNzAwLCBKZW5zIEF4Ym9lIHdyb3RlOg0KPiBP biAxLzEyLzE4IDM6MDAgUE0sIEJhcnQgVmFuIEFzc2NoZSB3cm90ZToNCj4gPiBPbiBGcmksIDIw MTgtMDEtMTIgYXQgMTQ6NTUgLTA3MDAsIEplbnMgQXhib2Ugd3JvdGU6DQo+ID4gPiBPbiAxLzEy LzE4IDI6NTIgUE0sIEJhcnQgVmFuIEFzc2NoZSB3cm90ZToNCj4gPiA+ID4gV2hlbiBkZWJ1Z2dp bmcgZS5nLiB0aGUgU0NTSSB0aW1lb3V0IGhhbmRsZXIgaXQgaXMgaW1wb3J0YW50IHRoYXQNCj4g PiA+ID4gcmVxdWVzdHMgdGhhdCBoYXZlIG5vdCB5ZXQgYmVlbiBzdGFydGVkIG9yIHRoYXQgYWxy ZWFkeSBoYXZlDQo+ID4gPiA+IGNvbXBsZXRlZCBhcmUgYWxzbyByZXBvcnRlZCB0aHJvdWdoIGRl YnVnZnMuDQo+ID4gPiA+IA0KPiA+ID4gPiBUaGlzIHBhdGNoIGRlcGVuZHMgb24gYSBwYXRjaCB0 aGF0IHdlbnQgdXBzdHJlYW0gcmVjZW50bHksIG5hbWVseQ0KPiA+ID4gPiBjb21taXQgMTRlMzA2 MmZiMTg1ICgic2NzaTogY29yZTogRml4IGEgc2NzaV9zaG93X3JxKCkgTlVMTCBwb2ludGVyDQo+ ID4gP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2J1c3lfcnEoc3RydWN0IHJlcXVlc3Qg KnJxLCB2b2lkICpkYXRhLCBib29sIHJlc2VydmVkKQ0KIAljb25zdCBzdHJ1Y3Qgc2hvd19idXN5 X3BhcmFtcyAqcGFyYW1zID0gZGF0YTsNCiANCiAJaWYgKGJsa19tcV9tYXBfcXVldWUocnEtPnEs IHJxLT5tcV9jdHgtPmNwdSkgPT0gcGFyYW1zLT5oY3R4ICYmDQotCSAgICBibGtfbXFfcnFfc3Rh dGUocnEpICE9IE1RX1JRX0lETEUpDQorCSAgICBsaXN0X2VtcHR5KCZycS0+cXVldWVsaXN0KSkN CiAJCV9fYmxrX21xX2RlYnVnZnNfcnFfc2hvdyhwYXJhbXMtPm0sDQogCQkJCQkgbGlzdF9lbnRy eV9ycSgmcnEtPnF1ZXVlbGlzdCkpOw0KIH0NCg0KVGhhbmtzLA0KDQpCYXJ0Lg==
Quoted 35 lines · Bart Van Assche
Quoted 21 lines · Jens Axboe
Quoted 14 lines · Bart Van Assche
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Bart Van Assche
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.
Quoted 7 lines
Quoted 3 lines
This patch depends on a patch that went upstream recently, namely commit
14e3062fb185("scsi: core: Fix ascsi_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.
Quoted 5 lines
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.
Quoted 4 lines
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?
block/blk-mq-debugfs.c +1
-1--- 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.
Quoted 13 lines
+- *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.
Jens Axboe
maintainerQuoted 59 lines · Bart Van Assche
Quoted 47 lines · Bart Van Assche
Quoted 21 lines · Jens Axboe
Quoted 14 lines · Bart Van Assche
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Bart Van Assche
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.
Quoted 7 lines
Quoted 3 lines
This patch depends on a patch that went upstream recently, namely commit
14e3062fb185("scsi: core: Fix ascsi_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.
Quoted 5 lines
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.
Quoted 4 lines
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?
block/blk-mq-debugfs.c +6
-0@@ -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. */ block/blk-mq-debugfs.c static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved) · line 414
Quoted 8 lines
block/blk-mq-debugfs.c +1
-1@@ -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,
Quoted 1 line
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?
Signature · 1 line
Jens Axboe
Quoted 26 lines · Jens Axboe
Quoted 15 lines · Bart Van Assche
Quoted 14 lines · Bart Van Assche
/*>>>+- *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));>>> }>>Quoted 3 lines
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.
Quoted 3 lines
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.
Jens Axboe
maintainerQuoted 39 lines · Bart Van Assche
Quoted 32 lines · Jens Axboe
Quoted 23 lines · Bart Van Assche
Quoted 11 lines · Bart Van Assche
/*
+ * Show "busy" requests - these are the requests owned by the block driver.
+ * The testlist_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 useslist_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 concurrentblk_mq_finish_request()call.
*/Review static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved) · line 414
Quoted 8 lines
(quoted diff) +1
-1@@ -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,
Quoted 1 line
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.
Quoted 3 lines
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,
Quoted 8 lines
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.
Signature · 1 line
Jens Axboe