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>
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 17:49:01 +0100	[thread overview]
Message-ID: <ccd2cdfa-089b-adcf-f52f-1b543ee5393e@huawei.com> (raw)
In-Reply-To: <20191007150416.GB1668@ming.t460p>

On 07/10/2019 16:04, Ming Lei wrote:
> 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,

Yeah, I forgot about the extra complications of the cpumask offstack 
stuff; but it does seem rarely used...

There is this:

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

	if ((cpumask_next_and(-1, hctx->cpumask, cpu_online_mask) ==
	     cpu) &&
	     (cpumask_next_and(cpu, hctx->cpumask, cpu_online_mask) >=
               nr_cpu_ids)) {
		set_bit(BLK_MQ_S_INTERNAL_STOPPED, &hctx->state);
		blk_mq_drain_inflight_rqs(hctx);
	}

	return 0;
}

... which looks effectively the same as yours, except a bit more 
readable (ignoring the fixable spilling of lines) to me.

Thanks,
John

 > 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 16:49 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
2019-10-07 16:49       ` John Garry [this message]
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=ccd2cdfa-089b-adcf-f52f-1b543ee5393e@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).