linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>
Cc: linux-block@vger.kernel.org, Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH V2 1/2] block: fix race between adding/removing rq qos and normal IO
Date: Tue, 8 Jun 2021 08:04:00 -0700	[thread overview]
Message-ID: <897fbf4d-569d-afae-c20d-745c8e2965d2@acm.org> (raw)
In-Reply-To: <20210608071903.431195-2-ming.lei@redhat.com>

On 6/8/21 12:19 AM, Ming Lei wrote:
>  static inline void rq_qos_add(struct request_queue *q, struct rq_qos *rqos)
>  {
> +	/*
> +	 * No IO can be in-flight when adding rqos, so freeze queue, which
> +	 * is fine since we only support rq_qos for blk-mq queue
> +	 */
> +	blk_mq_freeze_queue(q);
>  	rqos->next = q->rq_qos;
>  	q->rq_qos = rqos;
> +	blk_mq_unfreeze_queue(q);
>  
>  	if (rqos->ops->debugfs_attrs)
>  		blk_mq_debugfs_register_rqos(rqos);
> @@ -110,12 +117,18 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
>  {
>  	struct rq_qos **cur;
>  
> +	/*
> +	 * No IO can be in-flight when removing rqos, so freeze queue,
> +	 * which is fine since we only support rq_qos for blk-mq queue
> +	 */
> +	blk_mq_freeze_queue(q);
>  	for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {
>  		if (*cur == rqos) {
>  			*cur = rqos->next;
>  			break;
>  		}
>  	}
> +	blk_mq_unfreeze_queue(q);
>  
>  	blk_mq_debugfs_unregister_rqos(rqos);
>  }

Although this patch looks like an improvement to me, I think we also
need protection against concurrent rq_qos_add() and rq_qos_del() calls,
e.g. via a mutex.

Thanks,

Bart.



  reply	other threads:[~2021-06-08 15:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08  7:19 [PATCH V2 0/2] block: fix race between adding wbt and normal IO Ming Lei
2021-06-08  7:19 ` [PATCH V2 1/2] block: fix race between adding/removing rq qos " Ming Lei
2021-06-08 15:04   ` Bart Van Assche [this message]
2021-06-09  0:55     ` Ming Lei
2021-06-08  7:19 ` [PATCH V2 2/2] block: mark queue init done at the end of blk_register_queue Ming Lei

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=897fbf4d-569d-afae-c20d-745c8e2965d2@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=yi.zhang@redhat.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 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).