All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <Bart.VanAssche@sandisk.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"axboe@fb.com" <axboe@fb.com>,
	"hch@infradead.org" <hch@infradead.org>,
	"osandov@fb.com" <osandov@fb.com>
Subject: Re: [PATCH 3/4] blk-mq: use hw tag for scheduling if hw tag space is big enough
Date: Sat, 29 Apr 2017 18:35:54 +0800	[thread overview]
Message-ID: <20170429103554.GC12421@ming.t460p> (raw)
In-Reply-To: <1493402979.2767.10.camel@sandisk.com>

On Fri, Apr 28, 2017 at 06:09:40PM +0000, Bart Van Assche wrote:
> On Fri, 2017-04-28 at 23:15 +0800, Ming Lei wrote:
> > +static inline bool blk_mq_sched_may_use_hw_tag(struct request_queue *q)
> > +{
> > +	if (q->tag_set->flags & BLK_MQ_F_TAG_SHARED)
> > +		return false;
> > +
> > +	if (blk_mq_get_queue_depth(q) < q->nr_requests)
> > +		return false;
> > +
> > +	return true;
> > +}
> 
> The only user of shared tag sets I know of is scsi-mq. I think it's really
> unfortunate that this patch systematically disables BLK_MQ_F_SCHED_USE_HW_TAG
> for scsi-mq.

In previous patch, I actually allow driver to pass this flag, but this
feature is dropped in this post, just for making it simple & clean.
If you think we need it for shared tag set, I can add it in v1.

For shared tag sets, I suggest to not enable it at default, because
scheduler is per request queue now, and generaly more requests available,
better it performs.  When tags are shared among several request
queues, one of them may use tags up for its own scheduling, then
starve others. But it should be possible and not difficult to allocate
requests fairly for scheduling in this case if we switch to per-hctx
scheduling.

> 
> >  int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
> >  {
> >  	struct blk_mq_tag_set *set = q->tag_set;
> > @@ -2681,9 +2694,12 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
> >  			break;
> >  	}
> >  
> > -	if (!ret)
> > +	if (!ret) {
> >  		q->nr_requests = nr;
> >  
> > +		blk_mq_update_sched_flag(q);
> > +	}
> > +
> >  	blk_mq_unfreeze_queue(q);
> >  	blk_mq_start_stopped_hw_queues(q, true);
> 
> If a queue is created with a low value of nr_requests that will cause
> blk_mq_sched_alloc_tags() to skip allocation of .sched_tags. If nr_requests
> is increased, can that cause this function to clear BLK_MQ_F_SCHED_USE_HW_TAG
> while keeping hctx->sched_tags == NULL and hence trigger a NULL pointer
> dereference?

Good catch, will fix it in V1.

Given both scheduler switch and updating requests number are not
frequent actions, we can allocate/deallocate .sched_tags just
in need.


Thanks,
Ming

  reply	other threads:[~2017-04-29 10:36 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 15:15 [PATCH 0/4] blk-mq: support to use hw tag for scheduling Ming Lei
2017-04-28 15:15 ` [PATCH 1/4] blk-mq: introduce BLK_MQ_F_SCHED_USE_HW_TAG Ming Lei
2017-05-03 16:21   ` Omar Sandoval
2017-05-03 16:46   ` Omar Sandoval
2017-05-03 20:13     ` Ming Lei
2017-05-03 21:40       ` Omar Sandoval
2017-05-04  2:01         ` Ming Lei
2017-05-04  2:13           ` Jens Axboe
2017-05-04  2:51             ` Ming Lei
2017-05-04 14:06               ` Jens Axboe
2017-05-05 22:54                 ` Ming Lei
2017-05-05 22:54                   ` Ming Lei
2017-05-05 23:33                   ` Ming Lei
2017-05-05 23:33                     ` Ming Lei
2017-05-10  7:25                 ` Ming Lei
2017-04-28 15:15 ` [PATCH 2/4] blk-mq: introduce blk_mq_get_queue_depth() Ming Lei
2017-04-28 18:23   ` Jens Axboe
2017-04-29  9:55     ` Ming Lei
2017-05-03 16:55   ` Omar Sandoval
2017-05-04  2:10     ` Ming Lei
2017-04-28 15:15 ` [PATCH 3/4] blk-mq: use hw tag for scheduling if hw tag space is big enough Ming Lei
2017-04-28 18:09   ` Bart Van Assche
2017-04-29 10:35     ` Ming Lei [this message]
2017-05-01 15:06       ` Bart Van Assche
2017-05-02  3:49         ` Omar Sandoval
2017-05-02  8:46         ` Ming Lei
2017-04-28 18:22   ` Jens Axboe
2017-04-28 20:11     ` Bart Van Assche
2017-04-29 10:59     ` Ming Lei
2017-05-03 16:29   ` Omar Sandoval
2017-05-03 16:55     ` Ming Lei
2017-05-03 17:00       ` Omar Sandoval
2017-05-03 17:33         ` Ming Lei
2017-04-28 15:15 ` [PATCH 4/4] blk-mq: dump new introduced flag of BLK_MQ_F_SCHED_USE_HW_TAG Ming Lei
2017-04-28 18:10   ` Bart Van Assche
2017-04-29 11:00     ` Ming Lei
2017-04-28 20:29 ` [PATCH 0/4] blk-mq: support to use hw tag for scheduling Jens Axboe
2017-05-03  4:03   ` Ming Lei
2017-05-03 14:08     ` Jens Axboe
2017-05-03 14:10       ` Jens Axboe
2017-05-03 15:03         ` Ming Lei
2017-05-03 15:08           ` Jens Axboe
2017-05-03 15:38             ` Ming Lei
2017-05-03 16:06               ` Omar Sandoval
2017-05-03 16:21                 ` Ming Lei
2017-05-03 16:52               ` Ming Lei
2017-05-03 17:03                 ` Ming Lei
2017-05-03 17:07                   ` Jens Axboe
2017-05-03 17:15                     ` Bart Van Assche
2017-05-03 17:24                       ` Jens Axboe
2017-05-03 17:35                         ` Bart Van Assche
2017-05-03 17:40                           ` Jens Axboe
2017-05-03 17:43                             ` Bart Van Assche
2017-05-03 17:08                 ` Bart Van Assche
2017-05-03 17:11                   ` Jens Axboe
2017-05-03 17:19                   ` Ming Lei
2017-05-03 17:41                     ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170429103554.GC12421@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=axboe@fb.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.