Skip to contentSkip to conversation

blk-mq: kyber: fix domain token leak during requeue

PATCH Applied Ming Lei 5 participants 8 messages Feb 23, 2018 – Feb 26, 2018 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

cover blk-mq: kyber: fix domain token leak during requeue

Hi,

This two patch fixes domain token leak on kyber scheduler, and actually fixes one IO hang issue.

Thanks,

Ming Lei (2):
blk-mq: don't call io sched's .requeue_request when requeueing rq to

    ->dispatch

block: kyber: fix domain token leak during requeue

 block/blk-mq.c        | 4 +++-
 block/kyber-iosched.c | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH 1/2 blk-mq: don't call io sched's .requeue_request when requeueing rq to ->dispatch

__blk_mq_requeue_request() covers two cases:

- one is that the requeued request is added to hctx->dispatch, such as blk_mq_dispatch_rq_list()

- another case is that the request is requeued to io scheduler, such as blk_mq_requeue_request().

We should call io sched's .requeue_request callback only for the 2nd case.

Cc Paolo Valente <[email protected]>
Cc Omar Sandoval <[email protected]>
---
 block/blk-mq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-mq.c +3 -1
index 357492712b0e..16e83e6df404 100644
@@ -712,7 +712,6 @@ static void __blk_mq_requeue_request(struct request *rq)
 
 	trace_block_rq_requeue(q, rq);
 	wbt_requeue(q->rq_wb, &rq->issue_stat);
-	blk_mq_sched_requeue_request(rq);
 
 	if (blk_mq_rq_state(rq) != MQ_RQ_IDLE) {
 		blk_mq_rq_update_state(rq, MQ_RQ_IDLE);
@@ -725,6 +724,9 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list)
 {
 	__blk_mq_requeue_request(rq);
 
+	/* this request will be re-inserted to io scheduler queue */
+	blk_mq_sched_requeue_request(rq);
+
 	BUG_ON(blk_queued_rq(rq));
 	blk_mq_add_to_requeue_list(rq, true, kick_requeue_list);
 }
Signature · 1 line
2.9.5
#2 lore raw

Re: [PATCH 1/2] blk-mq: don't call io sched's .requeue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hcnQgVmFuIEFzc2NoZSA8YmFydC52YW5hc3Nj aGVAd2RjLmNvbT4NCg0KDQoNCg==

Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] blk-mq: don't call io sched's .requeue_request when requeueing rq to ->dispatch

In reply to Ming Lei
Quoted 3 lines

Il giorno 23 feb 2018, alle ore 16:36, Ming Lei <[email protected]> =

ha scritto:

Quoted 7 lines

=20
__blk_mq_requeue_request() covers two cases:
=20
- one is that the requeued request is added to hctx->dispatch, such as blk_mq_dispatch_rq_list()
=20
- another case is that the request is requeued to io scheduler, such =

as

Quoted 5 lines

blk_mq_requeue_request().
=20
We should call io sched's .requeue_request callback only for the 2nd case.
=20

block/blk-mq.c static void __blk_mq_requeue_request(struct =

Quoted 12 lines
Cc Paolo Valente <[email protected]>
Cc Omar Sandoval <[email protected]>

---
block/blk-mq.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)

=20

block/blk-mq.c +0 -0
index 357492712b0e..16e83e6df404 100644
@@ -712,7 +712,6 @@ static void __blk_mq_requeue_request(struct =

request *rq)

block/blk-mq.c void blk_mq_requeue_request(struct request *rq, =

Quoted 8 lines

=20

	trace_block_rq_requeue(q, rq);
	wbt_requeue(q->rq_wb, &rq->issue_stat);
block/blk-mq.c +0 -1
-	blk_mq_sched_requeue_request(rq);

=20

	if (blk_mq_rq_state(rq) !=3D MQ_RQ_IDLE) {
		blk_mq_rq_update_state(rq, MQ_RQ_IDLE);
block/blk-mq.c +0 -0
@@ -725,6 +724,9 @@ void blk_mq_requeue_request(struct request *rq, =

bool kick_requeue_list)

Quoted 12 lines
block/blk-mq.c +0 -0
 {
 	__blk_mq_requeue_request(rq);

=20

block/blk-mq.c +3 -0
+	/* this request will be re-inserted to io scheduler queue */
+	blk_mq_sched_requeue_request(rq);
+
	BUG_ON(blk_queued_rq(rq));
	blk_mq_add_to_requeue_list(rq, true, kick_requeue_list);
}

--=20
2.9.5
=20

author
#4 lore raw

PATCH 2/2 block: kyber: fix domain token leak during requeue

In reply to Ming Lei

When requeuing request, the domain token should have been freed before re-inserting the request to io scheduler. Otherwise, the assigned domain token will be leaked, and IO hang can be caused.

Cc Paolo Valente <[email protected]>
Cc Omar Sandoval <[email protected]>
---
 block/kyber-iosched.c | 1 +
 1 file changed, 1 insertion(+)
block/kyber-iosched.c +1 -0
index f95c60774ce8..0d6d25e32e1f 100644
@@ -833,6 +833,7 @@ static struct elevator_type kyber_sched = {
 		.limit_depth = kyber_limit_depth,
 		.prepare_request = kyber_prepare_request,
 		.finish_request = kyber_finish_request,
+		.requeue_request = kyber_finish_request,
 		.completed_request = kyber_completed_request,
 		.dispatch_request = kyber_dispatch_request,
 		.has_work = kyber_has_work,
Signature · 1 line
2.9.5
#5 lore raw

Re: [PATCH 2/2] block: kyber: fix domain token leak during requeue

T24gRnJpLCAyMDE4LTAyLTIzIGF0IDIzOjM2ICswODAwLCBNaW5nIExlaSB3cm90ZToNCj4gV2hl biByZXF1ZXVpbmcgcmVxdWVzdCwgdGhlIGRvbWFpbiB0b2tlbiBzaG91bGQgaGF2ZSBiZWVuIGZy ZWVkDQo+IGJlZm9yZSByZS1pbnNlcnRpbmcgdGhlIHJlcXVlc3QgdG8gaW8gc2NoZWR1bGVyLiBP dGhlcndpc2UsIHRoZQ0KPiBhc3NpZ25lZCBkb21haW4gdG9rZW4gd2lsbCBiZSBsZWFrZWQsIGFu ZCBJTyBoYW5nIGNhbiBiZSBjYXVzZWQuDQoNClBsZWFzZSBjb25zaWRlciB0byBhZGQgYSAiQ2M6 IHN0YWJsZSIgdGFnIHRvIHRoaXMgcGF0Y2guDQoNCkFueXdheToNCg0KUmV2aWV3ZWQtYnk6IEJh cnQgVmFuIEFzc2NoZSA8YmFydC52YW5hc3NjaGVAd2RjLmNvbT4NCg0KDQo=

maintainer Applied
#6 lore raw
In reply to Ming Lei
Quoted 11 lines · Ming Lei

Hi,

This two patch fixes domain token leak on kyber scheduler, and actually fixes one IO hang issue.

Thanks,

Ming Lei (2):
blk-mq: don't call io sched's .requeue_request when requeueing rq to

    ->dispatch

block: kyber: fix domain token leak during requeue

Applied, thanks.

Signature · 1 line
Jens Axboe
#7 lore raw
In reply to Ming Lei
Quoted 7 lines · Ming Lei

Hi,

This two patch fixes domain token leak on kyber scheduler, and actually fixes one IO hang issue.

Thanks,

Quoted 12 lines

Ming Lei (2):
blk-mq: don't call io sched's .requeue_request when requeueing rq to

    ->dispatch

block: kyber: fix domain token leak during requeue

 block/blk-mq.c        | 4 +++-
 block/kyber-iosched.c | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.9.5

I didn't get to add my reviewed-by before Jens queued this up, but thanks for fixing this, Ming.