public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: yang.yang29@zte.com.cn, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpu/hotplug: dont offline the last non-isolated CPU
Date: Wed, 11 Oct 2023 14:56:05 +0200	[thread overview]
Message-ID: <87lec9l3mi.ffs@tglx> (raw)
In-Reply-To: <202309161037416349176@zte.com.cn>

On Sat, Sep 16 2023 at 10:37, yang wrote:
> @@ -1502,6 +1502,7 @@ static long __cpu_down_maps_locked(void *arg)
>  static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target)
>  {
>  	struct cpu_down_work work = { .cpu = cpu, .target = target, };
> +	struct cpumask tmp_mask;

Allocating a cpumask on stack is not really a good idea as it takes up
to 1K stack space.

>  	/*
>  	 * If the platform does not support hotplug, report it explicitly to
> @@ -1512,11 +1513,16 @@ static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target)
>  	if (cpu_hotplug_disabled)
>  		return -EBUSY;
>
> +	/*
> +	 * Ensure the last non-isolated CPU is not offlined.
> +	 */
> +	cpumask_and(&tmp_mask, cpu_online_mask, housekeeping_cpumask(HK_TYPE_DOMAIN));

You can spare that excercise. See below.

>  	/*
>  	 * Ensure that the control task does not run on the to be offlined
>  	 * CPU to prevent a deadlock against cfs_b->period_timer.
>  	 */
> -	cpu = cpumask_any_but(cpu_online_mask, cpu);
> +	cpu = cpumask_any_but(&tmp_mask, cpu);

Just open code it this way:

        for_each_cpu_and(cpu, cpu_online_mask, housekeeping_cpumask(HK_TYPE_DOMAIN)) {
        	if (cpu != work.cpu)
  			return work_on_cpu(cpu, __cpu_down_maps_locked, &work);
	}
        return -EBUSY;

Hmm?

Thanks,

        tglx

  reply	other threads:[~2023-10-11 12:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-16  2:37 [PATCH] cpu/hotplug: dont offline the last non-isolated CPU yang.yang29
2023-10-11 12:56 ` Thomas Gleixner [this message]
2023-10-17  9:09   ` [PATCH V2] " yang.yang29

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=87lec9l3mi.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=yang.yang29@zte.com.cn \
    /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