public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Valentin Schneider <vschneid@redhat.com>
To: Phil Auld <pauld@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] cpuhp: make target_store() a nop when target == state
Date: Wed, 25 May 2022 10:48:55 +0100	[thread overview]
Message-ID: <xhsmhwneahri0.mognet@vschneid.remote.csb> (raw)
In-Reply-To: <Yo0z56Fqgj3gqYlG@lorien.usersys.redhat.com>

On 24/05/22 15:37, Phil Auld wrote:
> Hi Valentin,
>
> I did it like this (shown below) and from my test it also works for
> this case.
>
> I could move it below the lock and goto out;  instead if you think
> that is better.

I *think* the cpu_add_remove_lock mutex should be sufficient here.

> It still seems better to me to stop this higher up
> because there's work being done in the out path too.  We're not
> actually doing any hot(un)plug so doing post unplug cleanup seems
> iffy.
>

I think so too; I now realize _cpu_up() and _cpu_down() have slightly
different prologues: _cpu_up() does its hotplug states / cpu_present_mask
checks *after* grabbing the cpu_hotplug_lock, _cpu_down() does that *before*...

So I believe what you have below is fine, modulo whether we want to align
the prologue of these two functions or not :-)

> _cpu_down()
> ...
> out:
>         cpus_write_unlock();
>         /*
>          * Do post unplug cleanup. This is still protected against
>          * concurrent CPU hotplug via cpu_add_remove_lock.
>          */
>         lockup_detector_cleanup();
>         arch_smt_update();
>         cpu_up_down_serialize_trainwrecks(tasks_frozen);
>       return ret;
> }
>
> ----------
>
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 8a71b1149c60..e36788742d18 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -1130,6 +1130,13 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
>       if (!cpu_present(cpu))
>               return -EINVAL;
>
> +	/*
> +	 * The caller of cpu_down() might have raced with another
> +	 * caller. Nothing to do.
> +	 */
> +	if (st->state <= target)
> +		return 0;
> +
>       cpus_write_lock();
>
>       cpuhp_tasks_frozen = tasks_frozen;
>
>
>
>
> Cheers,
> Phil
>
> --


      reply	other threads:[~2022-05-25  9:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23 14:47 [PATCH] cpuhp: make target_store() a nop when target == state Phil Auld
2022-05-24 15:11 ` Valentin Schneider
2022-05-24 16:39   ` Phil Auld
2022-05-25  9:48     ` Valentin Schneider
2022-05-25 13:31       ` Phil Auld
2022-05-25 15:09         ` Valentin Schneider
2022-05-25 15:11           ` Phil Auld
2022-05-24 19:37   ` Phil Auld
2022-05-25  9:48     ` Valentin Schneider [this message]

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=xhsmhwneahri0.mognet@vschneid.remote.csb \
    --to=vschneid@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pauld@redhat.com \
    --cc=peterz@infradead.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