linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: John Garry <john.garry@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	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 23:04:17 +0800	[thread overview]
Message-ID: <20191007150416.GB1668@ming.t460p> (raw)
In-Reply-To: <047ecdf1-bd4b-6702-1add-83b902a6902f@huawei.com>

On Mon, Oct 07, 2019 at 11:23:22AM +0100, John Garry wrote:
> 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.

Yes, but we have to allocate space for 'tmp', that is what this patch
tries to avoid, given the logic isn't too complicated.

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

OK, I will add it in V3.


Thanks,
Ming

  reply	other threads:[~2019-10-07 15:04 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
2019-10-07 15:04     ` Ming Lei [this message]
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=20191007150416.GB1668@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=john.garry@huawei.com \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --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).