linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpu/hotplug: Fix acquire of st->should_run in cpuhp_thread_fun()
@ 2018-09-05  5:52 Neeraj Upadhyay
  2018-09-05  8:12 ` Peter Zijlstra
  2018-09-06 13:51 ` [tip:smp/urgent] cpu/hotplug: Adjust misplaced smb() " tip-bot for Neeraj Upadhyay
  0 siblings, 2 replies; 3+ messages in thread
From: Neeraj Upadhyay @ 2018-09-05  5:52 UTC (permalink / raw)
  To: tglx, josh, peterz, mingo, jiangshanlai, dzickus,
	brendan.jackman, malat, mojha
  Cc: linux-kernel, sramana, linux-arm-msm, Neeraj Upadhyay

The smp_mb() in cpuhp_thread_fun() appears to be misplaced, and
need to be after the load of st->should_run, to prevent
reordering of the later load/stores w.r.t. the load of
st->should_run.

Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
---
 kernel/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index aa7fe85..eb4041f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -607,15 +607,15 @@ static void cpuhp_thread_fun(unsigned int cpu)
 	bool bringup = st->bringup;
 	enum cpuhp_state state;
 
+	if (WARN_ON_ONCE(!st->should_run))
+		return;
+
 	/*
 	 * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures
 	 * that if we see ->should_run we also see the rest of the state.
 	 */
 	smp_mb();
 
-	if (WARN_ON_ONCE(!st->should_run))
-		return;
-
 	cpuhp_lock_acquire(bringup);
 
 	if (st->single) {
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpu/hotplug: Fix acquire of st->should_run in cpuhp_thread_fun()
  2018-09-05  5:52 [PATCH] cpu/hotplug: Fix acquire of st->should_run in cpuhp_thread_fun() Neeraj Upadhyay
@ 2018-09-05  8:12 ` Peter Zijlstra
  2018-09-06 13:51 ` [tip:smp/urgent] cpu/hotplug: Adjust misplaced smb() " tip-bot for Neeraj Upadhyay
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2018-09-05  8:12 UTC (permalink / raw)
  To: Neeraj Upadhyay
  Cc: tglx, josh, mingo, jiangshanlai, dzickus, brendan.jackman, malat,
	mojha, linux-kernel, sramana, linux-arm-msm

On Wed, Sep 05, 2018 at 11:22:07AM +0530, Neeraj Upadhyay wrote:
> The smp_mb() in cpuhp_thread_fun() appears to be misplaced, and
> need to be after the load of st->should_run, to prevent
> reordering of the later load/stores w.r.t. the load of
> st->should_run.

I'm tempted to say this changelog needs improvement, but given the
comment that goes with the smp_mb(), yes this is obviously right.

Acked-by: Peter Zijlstra (Intel) <peterz@infraded.org>

> Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
> ---
>  kernel/cpu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index aa7fe85..eb4041f 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -607,15 +607,15 @@ static void cpuhp_thread_fun(unsigned int cpu)
>  	bool bringup = st->bringup;
>  	enum cpuhp_state state;
>  
> +	if (WARN_ON_ONCE(!st->should_run))
> +		return;
> +
>  	/*
>  	 * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures
>  	 * that if we see ->should_run we also see the rest of the state.
>  	 */
>  	smp_mb();
>  
> -	if (WARN_ON_ONCE(!st->should_run))
> -		return;
> -
>  	cpuhp_lock_acquire(bringup);
>  
>  	if (st->single) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:smp/urgent] cpu/hotplug: Adjust misplaced smb() in cpuhp_thread_fun()
  2018-09-05  5:52 [PATCH] cpu/hotplug: Fix acquire of st->should_run in cpuhp_thread_fun() Neeraj Upadhyay
  2018-09-05  8:12 ` Peter Zijlstra
@ 2018-09-06 13:51 ` tip-bot for Neeraj Upadhyay
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Neeraj Upadhyay @ 2018-09-06 13:51 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: tglx, hpa, linux-kernel, peterz, mingo, neeraju

Commit-ID:  f8b7530aa0a1def79c93101216b5b17cf408a70a
Gitweb:     https://git.kernel.org/tip/f8b7530aa0a1def79c93101216b5b17cf408a70a
Author:     Neeraj Upadhyay <neeraju@codeaurora.org>
AuthorDate: Wed, 5 Sep 2018 11:22:07 +0530
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 6 Sep 2018 15:21:37 +0200

cpu/hotplug: Adjust misplaced smb() in cpuhp_thread_fun()

The smp_mb() in cpuhp_thread_fun() is misplaced. It needs to be after the
load of st->should_run to prevent reordering of the later load/stores
w.r.t. the load of st->should_run.

Fixes: 4dddfb5faa61 ("smp/hotplug: Rewrite AP state machine core")
Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infraded.org>
Cc: josh@joshtriplett.org
Cc: peterz@infradead.org
Cc: jiangshanlai@gmail.com
Cc: dzickus@redhat.com
Cc: brendan.jackman@arm.com
Cc: malat@debian.org
Cc: mojha@codeaurora.org
Cc: sramana@codeaurora.org
Cc: linux-arm-msm@vger.kernel.org
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/1536126727-11629-1-git-send-email-neeraju@codeaurora.org

---
 kernel/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index aa7fe85ad62e..eb4041f78073 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -607,15 +607,15 @@ static void cpuhp_thread_fun(unsigned int cpu)
 	bool bringup = st->bringup;
 	enum cpuhp_state state;
 
+	if (WARN_ON_ONCE(!st->should_run))
+		return;
+
 	/*
 	 * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures
 	 * that if we see ->should_run we also see the rest of the state.
 	 */
 	smp_mb();
 
-	if (WARN_ON_ONCE(!st->should_run))
-		return;
-
 	cpuhp_lock_acquire(bringup);
 
 	if (st->single) {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-06 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05  5:52 [PATCH] cpu/hotplug: Fix acquire of st->should_run in cpuhp_thread_fun() Neeraj Upadhyay
2018-09-05  8:12 ` Peter Zijlstra
2018-09-06 13:51 ` [tip:smp/urgent] cpu/hotplug: Adjust misplaced smb() " tip-bot for Neeraj Upadhyay

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).