mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Ethan Barnes <Ethan.Barnes@wdc.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Srivatsa S. Bhat" <srivatsa@mit.edu>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.or>,
	Sebastian Siewior <bigeasy@linutronix.d>
Subject: Re: [PATCH] cpu hotplug: Prevent Page Fault in cpuhp_remove_callbacks()
Date: Thu, 20 Jul 2017 16:05:25 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1707201555410.3168@nanos> (raw)
In-Reply-To: <DM2PR04MB398242FC7776D603D9F99C894A60@DM2PR04MB398.namprd04.prod.outlook.com>

On Wed, 19 Jul 2017, Ethan Barnes wrote:
> There is a page fault in cpu hotplug when removing the callbacks for the 
> last dynamic state.
> The last dynamic state will not be removed, causing a page fault when 
> hotplug thinks the callbacks still exists and calls it.
> 
> The problem is as follows:
> - __cpuhp_remove_state() eventually calls cpuhp_store_callbacks() with 
> NULLs for most params.
> - If state is the last state (i.e. CPUHP_AP_ONLINE_DYN or 
> CPUHP_BP_PREPARE_STATE) then cpuhp_store_callbacks() calls 
> cpuhp_reserve_state(), which returns the *next* available DYN state.
> - The NULLs are stored in that *next* state (i.e. AP_ONLINE_DYN + 1 or 
> BP_PREPARE_DYN + 1) instead of in AP_ONLINE_DYN or BP_PREPARE_DYN. Thus, 
> the last state is never cleared. The callbacks now point to invalid memory.
> - When the cpu is onlined again and/or offlined, then the invalid 
> callback is invoked, causing a page fault.

Indeed.

> The patch above solves this by detecting when a state is being removed, 
> and not calling cpuhp_reserve_state().
> 
> I have brought this up before, but hoping to get some traction on it 
> this time:
> https://lkml.org/lkml/2017/7/5/574

Escaped my attention.

> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index eee0331..f7fda16 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -1252,7 +1252,8 @@ static int cpuhp_store_callbacks(enum cpuhp_state 
> state, const char *name,

That patch is corrupted by your mail-client or mail-server or both.

>          struct cpuhp_step *sp;
>          int ret = 0;
> 
> -       if (state == CPUHP_AP_ONLINE_DYN || state == CPUHP_BP_PREPARE_DYN) {
> +       if (name &&
> +           (state == CPUHP_AP_ONLINE_DYN || state == 
> CPUHP_BP_PREPARE_DYN)) {
>                  ret = cpuhp_reserve_state(state);
>                  if (ret < 0)
>                          return ret;
> Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
>

Can you please make sure that there is a blank line before that
automatically inserted disclaimer?

Thanks,

	tglx

  reply	other threads:[~2017-07-20 14:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 22:36 Ethan Barnes
2017-07-20 14:05 ` Thomas Gleixner [this message]
2017-07-20 14:49 ` [tip:smp/hotplug] smp/hotplug: Handle removal correctly in cpuhp_store_callbacks() tip-bot for Ethan Barnes

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=alpine.DEB.2.20.1707201555410.3168@nanos \
    --to=tglx@linutronix.de \
    --cc=Ethan.Barnes@wdc.com \
    --cc=bigeasy@linutronix.d \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.or \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=srivatsa@mit.edu \
    /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

all inboxes | Powered by JetHome®