linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>,
	Bart Van Assche <bvanassche@acm.org>,
	Hannes Reinecke <hare@suse.com>, Christoph Hellwig <hch@lst.de>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	Keith Busch <keith.busch@intel.com>
Subject: Re: [PATCH V2 RESEND 3/5] blk-mq: stop to handle IO before hctx's all CPUs become offline
Date: Mon, 7 Oct 2019 11:23:22 +0100	[thread overview]
Message-ID: <047ecdf1-bd4b-6702-1add-83b902a6902f@huawei.com> (raw)
In-Reply-To: <20191006024516.19996-4-ming.lei@redhat.com>

On 06/10/2019 03:45, Ming Lei wrote:
> +	}
> +}
> +
> +static int blk_mq_hctx_notify_online(unsigned int cpu, struct hlist_node *node)
> +{
> +	struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node,
> +			struct blk_mq_hw_ctx, cpuhp_online);
> +	unsigned prev_cpu = -1;
> +
> +	while (true) {
> +		unsigned next_cpu = cpumask_next_and(prev_cpu, hctx->cpumask,
> +				cpu_online_mask);
> +
> +		if (next_cpu >= nr_cpu_ids)
> +			break;
> +
> +		/* return if there is other online CPU on this hctx */
> +		if (next_cpu != cpu)
> +			return 0;
> +
> +		prev_cpu = next_cpu;
> +	}
> +
> +	set_bit(BLK_MQ_S_INTERNAL_STOPPED, &hctx->state);
> +	blk_mq_drain_inflight_rqs(hctx);
> +

Does this do the same:

{
	struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node,
			struct blk_mq_hw_ctx, cpuhp_online);
	cpumask_var_t tmp;

	cpumask_and(tmp, hctx->cpumask, cpu_online_mask);

	/* test if there is any other cpu online in the hctx cpu mask */
	if (cpumask_any_but(tmp, cpu) < nr_cpu_ids)
		return 0;

	set_bit(BLK_MQ_S_INTERNAL_STOPPED, &hctx->state);
	blk_mq_drain_inflight_rqs(hctx);

	return 0;
}

If so, it's more readable and concise.

Thanks,
John


BTW, You could have added my Tested-by tags...

> +	return 0;
> +}
> +



  parent reply	other threads:[~2019-10-07 10:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-06  2:45 [PATCH V2 RESEND 0/5] blk-mq: improvement on handling IO during CPU hotplug Ming Lei
2019-10-06  2:45 ` [PATCH V2 RESEND 1/5] blk-mq: add new state of BLK_MQ_S_INTERNAL_STOPPED Ming Lei
2019-10-07  6:02   ` Hannes Reinecke
2019-10-06  2:45 ` [PATCH V2 RESEND 2/5] blk-mq: add blk-mq flag of BLK_MQ_F_NO_MANAGED_IRQ Ming Lei
2019-10-07  6:06   ` Hannes Reinecke
2019-10-06  2:45 ` [PATCH V2 RESEND 3/5] blk-mq: stop to handle IO before hctx's all CPUs become offline Ming Lei
2019-10-07  6:23   ` Hannes Reinecke
2019-10-07 15:01     ` Ming Lei
2019-10-07 10:23   ` John Garry [this message]
2019-10-07 15:04     ` Ming Lei
2019-10-07 16:49       ` John Garry
2019-10-06  2:45 ` [PATCH V2 RESEND 4/5] blk-mq: re-submit IO in case that hctx is dead Ming Lei
2019-10-07  6:27   ` Hannes Reinecke
2019-10-07 15:05     ` Ming Lei
2019-10-06  2:45 ` [PATCH V2 RESEND 5/5] blk-mq: handle requests dispatched from IO scheduler " Ming Lei
2019-10-07  6:28   ` Hannes Reinecke

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=047ecdf1-bd4b-6702-1add-83b902a6902f@huawei.com \
    --to=john.garry@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=tglx@linutronix.de \
    /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).