* [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0
@ 2018-12-18 4:15 Ming Lei
2018-12-18 4:34 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2018-12-18 4:15 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei, Jeff Moyer, Christoph Hellwig
The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues
is bigger than zero, so enhance the constraint by checking .nr_queues of type poll
before enabling IO poll.
Otherwise IO race & timeout can be observed when running block/007.
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq.c | 3 ++-
block/blk-sysfs.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 6847f014606b..e45400da4180 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2833,7 +2833,8 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
q->tag_set = set;
q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT;
- if (set->nr_maps > HCTX_TYPE_POLL)
+ if (set->nr_maps > HCTX_TYPE_POLL &&
+ set->map[HCTX_TYPE_POLL].nr_queues)
blk_queue_flag_set(QUEUE_FLAG_POLL, q);
if (!(set->flags & BLK_MQ_F_SG_MERGE))
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index bb7c642ffefa..0619c8922893 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -402,7 +402,8 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
unsigned long poll_on;
ssize_t ret;
- if (!q->tag_set || q->tag_set->nr_maps <= HCTX_TYPE_POLL)
+ if (!q->tag_set || q->tag_set->nr_maps <= HCTX_TYPE_POLL ||
+ !q->tag_set->map[HCTX_TYPE_POLL].nr_queues)
return -EINVAL;
ret = queue_var_store(&poll_on, page, count);
--
2.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0
2018-12-18 4:15 [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0 Ming Lei
@ 2018-12-18 4:34 ` Jens Axboe
2018-12-18 6:47 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2018-12-18 4:34 UTC (permalink / raw)
To: Ming Lei; +Cc: linux-block, Jeff Moyer, Christoph Hellwig
On 12/17/18 9:15 PM, Ming Lei wrote:
> The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues
> is bigger than zero, so enhance the constraint by checking .nr_queues of type poll
> before enabling IO poll.
>
> Otherwise IO race & timeout can be observed when running block/007.
Looks good to me, but we might consider having a helper for this, since
we have this check in 3 places now. But for now this is good, thanks
Ming.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0
2018-12-18 4:34 ` Jens Axboe
@ 2018-12-18 6:47 ` Christoph Hellwig
2018-12-18 8:09 ` Ming Lei
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-12-18 6:47 UTC (permalink / raw)
To: Jens Axboe; +Cc: Ming Lei, linux-block, Jeff Moyer, Christoph Hellwig
On Mon, Dec 17, 2018 at 09:34:55PM -0700, Jens Axboe wrote:
> On 12/17/18 9:15 PM, Ming Lei wrote:
> > The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues
> > is bigger than zero, so enhance the constraint by checking .nr_queues of type poll
> > before enabling IO poll.
> >
> > Otherwise IO race & timeout can be observed when running block/007.
>
> Looks good to me, but we might consider having a helper for this, since
> we have this check in 3 places now. But for now this is good, thanks
> Ming.
Jens, if you want this I can drop the nvme patch to set nr_maps to 2
as it wouldn't be needed. Not sure which one is more elegant, but
I guess Mings version is a little more fool proof.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0
2018-12-18 6:47 ` Christoph Hellwig
@ 2018-12-18 8:09 ` Ming Lei
2018-12-18 13:27 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2018-12-18 8:09 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jens Axboe, linux-block, Jeff Moyer
On Tue, Dec 18, 2018 at 07:47:39AM +0100, Christoph Hellwig wrote:
> On Mon, Dec 17, 2018 at 09:34:55PM -0700, Jens Axboe wrote:
> > On 12/17/18 9:15 PM, Ming Lei wrote:
> > > The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues
> > > is bigger than zero, so enhance the constraint by checking .nr_queues of type poll
> > > before enabling IO poll.
> > >
> > > Otherwise IO race & timeout can be observed when running block/007.
> >
> > Looks good to me, but we might consider having a helper for this, since
> > we have this check in 3 places now. But for now this is good, thanks
> > Ming.
>
> Jens, if you want this I can drop the nvme patch to set nr_maps to 2
> as it wouldn't be needed. Not sure which one is more elegant, but
> I guess Mings version is a little more fool proof.
For READ queue type, its .nr_maps can be 3 and .nr_queues is zero, so
if check on the two queue type is kept as consistent, we may get good
code readability, IMO.
As Jens mentioned, we may introduce blk_mq_queue_type_supported() helper
to cover both.
Thanks,
Ming
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0
2018-12-18 8:09 ` Ming Lei
@ 2018-12-18 13:27 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2018-12-18 13:27 UTC (permalink / raw)
To: Ming Lei, Christoph Hellwig; +Cc: linux-block, Jeff Moyer
On 12/18/18 1:09 AM, Ming Lei wrote:
> On Tue, Dec 18, 2018 at 07:47:39AM +0100, Christoph Hellwig wrote:
>> On Mon, Dec 17, 2018 at 09:34:55PM -0700, Jens Axboe wrote:
>>> On 12/17/18 9:15 PM, Ming Lei wrote:
>>>> The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues
>>>> is bigger than zero, so enhance the constraint by checking .nr_queues of type poll
>>>> before enabling IO poll.
>>>>
>>>> Otherwise IO race & timeout can be observed when running block/007.
>>>
>>> Looks good to me, but we might consider having a helper for this, since
>>> we have this check in 3 places now. But for now this is good, thanks
>>> Ming.
>>
>> Jens, if you want this I can drop the nvme patch to set nr_maps to 2
>> as it wouldn't be needed. Not sure which one is more elegant, but
>> I guess Mings version is a little more fool proof.
>
> For READ queue type, its .nr_maps can be 3 and .nr_queues is zero, so
> if check on the two queue type is kept as consistent, we may get good
> code readability, IMO.
>
> As Jens mentioned, we may introduce blk_mq_queue_type_supported() helper
> to cover both.
I think that would be preferable.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-12-18 13:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-18 4:15 [PATCH] blk-mq: enable IO poll if .nr_queues of type poll > 0 Ming Lei
2018-12-18 4:34 ` Jens Axboe
2018-12-18 6:47 ` Christoph Hellwig
2018-12-18 8:09 ` Ming Lei
2018-12-18 13:27 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).