* [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
@ 2014-07-21 8:10 Alexander Gordeev
2014-07-21 8:16 ` Jens Axboe
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Gordeev @ 2014-07-21 8:10 UTC (permalink / raw)
To: linux-kernel; +Cc: Alexander Gordeev, Jens Axboe
There is a race between __bt_get_word() and bt_clear_tag(). Since
access to the tags bitmap is not serialized __bt_get_word() might
miss a tag which is about to or being returned by bt_clear_tag().
As result, the process requesting the tag might end up schedulled
out forever.
To avoid this corner case call io_schedule_timeout() instead of
io_schedule(). The timeout should be long enough to not falsely
wake up waiters often, so take the requests queue's "rq_timeout"
for that.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
---
block/blk-mq-tag.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index c1b9242..1785f1f 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -256,7 +256,7 @@ static int bt_get(struct blk_mq_alloc_data *data,
blk_mq_put_ctx(data->ctx);
- io_schedule();
+ WARN_ON(!io_schedule_timeout(hctx->queue->rq_timeout));
data->ctx = blk_mq_get_ctx(data->q);
data->hctx = data->q->mq_ops->map_queue(data->q,
--
1.7.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
2014-07-21 8:10 [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get() Alexander Gordeev
@ 2014-07-21 8:16 ` Jens Axboe
2014-07-21 8:32 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2014-07-21 8:16 UTC (permalink / raw)
To: Alexander Gordeev, linux-kernel
On 2014-07-21 10:10, Alexander Gordeev wrote:
> There is a race between __bt_get_word() and bt_clear_tag(). Since
> access to the tags bitmap is not serialized __bt_get_word() might
> miss a tag which is about to or being returned by bt_clear_tag().
> As result, the process requesting the tag might end up schedulled
> out forever.
>
> To avoid this corner case call io_schedule_timeout() instead of
> io_schedule(). The timeout should be long enough to not falsely
> wake up waiters often, so take the requests queue's "rq_timeout"
> for that.
What is this patch against?
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
2014-07-21 8:16 ` Jens Axboe
@ 2014-07-21 8:32 ` Alexander Gordeev
2014-07-21 8:34 ` Jens Axboe
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Gordeev @ 2014-07-21 8:32 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel
On Mon, Jul 21, 2014 at 10:16:54AM +0200, Jens Axboe wrote:
> What is this patch against?
v3.16-rc5
> --
> Jens Axboe
>
--
Regards,
Alexander Gordeev
agordeev@redhat.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
2014-07-21 8:32 ` Alexander Gordeev
@ 2014-07-21 8:34 ` Jens Axboe
2014-07-21 9:11 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2014-07-21 8:34 UTC (permalink / raw)
To: Alexander Gordeev; +Cc: linux-kernel
On 2014-07-21 10:32, Alexander Gordeev wrote:
> On Mon, Jul 21, 2014 at 10:16:54AM +0200, Jens Axboe wrote:
>> What is this patch against?
>
> v3.16-rc5
My bad, was looking at the wrong sources. What is the race? If the clear
and wakeup come in after the prepare_to_wait() but before the
io_schedule(), the io_schedule() will be a no-op and it wont actually
sleep. Your commit message doesn't mention any particular details.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
2014-07-21 8:34 ` Jens Axboe
@ 2014-07-21 9:11 ` Alexander Gordeev
2014-07-22 8:27 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Gordeev @ 2014-07-21 9:11 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel
On Mon, Jul 21, 2014 at 10:34:20AM +0200, Jens Axboe wrote:
> On 2014-07-21 10:32, Alexander Gordeev wrote:
> >On Mon, Jul 21, 2014 at 10:16:54AM +0200, Jens Axboe wrote:
> >>What is this patch against?
> >
> >v3.16-rc5
>
> My bad, was looking at the wrong sources. What is the race? If the
> clear and wakeup come in after the prepare_to_wait() but before the
> io_schedule(), the io_schedule() will be a no-op and it wont
> actually sleep. Your commit message doesn't mention any particular
> details.
Let me examine the code.. It was few weeks ago and I can not
remember what was that. And the changelog does not help :)
>
> --
> Jens Axboe
>
--
Regards,
Alexander Gordeev
agordeev@redhat.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
2014-07-21 9:11 ` Alexander Gordeev
@ 2014-07-22 8:27 ` Alexander Gordeev
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Gordeev @ 2014-07-22 8:27 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel
On Mon, Jul 21, 2014 at 11:11:44AM +0200, Alexander Gordeev wrote:
> > My bad, was looking at the wrong sources. What is the race? If the
> > clear and wakeup come in after the prepare_to_wait() but before the
> > io_schedule(), the io_schedule() will be a no-op and it wont
> > actually sleep. Your commit message doesn't mention any particular
> > details.
>
> Let me examine the code.. It was few weeks ago and I can not
> remember what was that. And the changelog does not help :)
Jens,
I can not recall what was my concern. Sorry for the noise.
Thanks!
> > --
> > Jens Axboe
> >
--
Regards,
Alexander Gordeev
agordeev@redhat.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-22 8:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-21 8:10 [PATCH] blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get() Alexander Gordeev
2014-07-21 8:16 ` Jens Axboe
2014-07-21 8:32 ` Alexander Gordeev
2014-07-21 8:34 ` Jens Axboe
2014-07-21 9:11 ` Alexander Gordeev
2014-07-22 8:27 ` Alexander Gordeev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox