linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug
@ 2021-07-07 18:38 Valentin Schneider
  2021-07-08  9:38 ` Bharata B Rao
  2021-07-08 13:53 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Valentin Schneider @ 2021-07-07 18:38 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Guenter Roeck, Bharata B Rao, Arnd Bergmann, Michael Ellerman,
	Benjamin Herrenschmidt, Paul Mackerras, Peter Zijlstra,
	Ingo Molnar, Srikar Dronamraju

Powerpc currently resets a CPU's idle task preempt_count to 0 before said
task starts executing the secondary startup routine (and becomes an idle
task proper).

This conflicts with commit

  f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")

which initializes all of the idle tasks' preempt_count to PREEMPT_DISABLED
during smp_init(). Note that this was superfluous before said commit, as
back then the hotplug machinery would invoke init_idle() via
idle_thread_get(), which would have already reset the CPU's idle task's
preempt_count to PREEMPT_ENABLED.

Get rid of this preempt_count write.

Cc: Guenter Roeck <linux@roeck-us.net>
Fixes: f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")
Reported-by: Bharata B Rao <bharata@linux.ibm.com>
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
---
 arch/powerpc/platforms/cell/smp.c    | 3 ---
 arch/powerpc/platforms/pseries/smp.c | 5 +----
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index c855a0aeb49c..d7ab868aab54 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -78,9 +78,6 @@ static inline int smp_startup_cpu(unsigned int lcpu)
 
 	pcpu = get_hard_smp_processor_id(lcpu);
 
-	/* Fixup atomic count: it exited inside IRQ handler. */
-	task_thread_info(paca_ptrs[lcpu]->__current)->preempt_count	= 0;
-
 	/*
 	 * If the RTAS start-cpu token does not exist then presume the
 	 * cpu is already spinning.
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 096629f54576..7ebf3382816a 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -105,10 +105,7 @@ static inline int smp_startup_cpu(unsigned int lcpu)
 		return 1;
 	}
 
-	/* Fixup atomic count: it exited inside IRQ handler. */
-	task_thread_info(paca_ptrs[lcpu]->__current)->preempt_count	= 0;
-
-	/* 
+	/*
 	 * If the RTAS start-cpu token does not exist then presume the
 	 * cpu is already spinning.
 	 */
-- 
2.25.1


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

* Re: [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug
  2021-07-07 18:38 [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug Valentin Schneider
@ 2021-07-08  9:38 ` Bharata B Rao
  2021-07-08 13:53 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Bharata B Rao @ 2021-07-08  9:38 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: linux-kernel, linuxppc-dev, Guenter Roeck, Arnd Bergmann,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Peter Zijlstra, Ingo Molnar, Srikar Dronamraju

On Wed, Jul 07, 2021 at 07:38:31PM +0100, Valentin Schneider wrote:
> Powerpc currently resets a CPU's idle task preempt_count to 0 before said
> task starts executing the secondary startup routine (and becomes an idle
> task proper).
> 
> This conflicts with commit
> 
>   f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")
> 
> which initializes all of the idle tasks' preempt_count to PREEMPT_DISABLED
> during smp_init(). Note that this was superfluous before said commit, as
> back then the hotplug machinery would invoke init_idle() via
> idle_thread_get(), which would have already reset the CPU's idle task's
> preempt_count to PREEMPT_ENABLED.
> 
> Get rid of this preempt_count write.
> 
> Cc: Guenter Roeck <linux@roeck-us.net>
> Fixes: f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")
> Reported-by: Bharata B Rao <bharata@linux.ibm.com>
> Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
> ---
>  arch/powerpc/platforms/cell/smp.c    | 3 ---
>  arch/powerpc/platforms/pseries/smp.c | 5 +----
>  2 files changed, 1 insertion(+), 7 deletions(-)

The messages like "BUG: scheduling while atomic: swapper/1/0/0x00000000"
for each secondary CPU are no longer seen after this patch on powerpc.

Tested-by: Bharata B Rao <bharata@linux.ibm.com>

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

* Re: [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug
  2021-07-07 18:38 [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug Valentin Schneider
  2021-07-08  9:38 ` Bharata B Rao
@ 2021-07-08 13:53 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-07-08 13:53 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Valentin Schneider
  Cc: Peter Zijlstra, Paul Mackerras, Guenter Roeck, Ingo Molnar,
	Michael Ellerman, Benjamin Herrenschmidt, Srikar Dronamraju,
	Arnd Bergmann, Bharata B Rao

On Wed, 7 Jul 2021 19:38:31 +0100, Valentin Schneider wrote:
> Powerpc currently resets a CPU's idle task preempt_count to 0 before said
> task starts executing the secondary startup routine (and becomes an idle
> task proper).
> 
> This conflicts with commit
> 
>   f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug
      https://git.kernel.org/powerpc/c/2c669ef6979c370f98d4b876e54f19613c81e075

cheers

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

* Re: [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug
@ 2021-07-07 19:18 Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-07-07 19:18 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: linux-kernel, linuxppc-dev, Bharata B Rao, Arnd Bergmann,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Peter Zijlstra, Ingo Molnar, Srikar Dronamraju

On Wed, Jul 07, 2021 at 07:38:31PM +0100, Valentin Schneider wrote:
> Powerpc currently resets a CPU's idle task preempt_count to 0 before said
> task starts executing the secondary startup routine (and becomes an idle
> task proper).
> 
> This conflicts with commit
> 
>   f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")
> 
> which initializes all of the idle tasks' preempt_count to PREEMPT_DISABLED
> during smp_init(). Note that this was superfluous before said commit, as
> back then the hotplug machinery would invoke init_idle() via
> idle_thread_get(), which would have already reset the CPU's idle task's
> preempt_count to PREEMPT_ENABLED.
> 
> Get rid of this preempt_count write.
> 
> Cc: Guenter Roeck <linux@roeck-us.net>
> Fixes: f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")
> Reported-by: Bharata B Rao <bharata@linux.ibm.com>
> Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  arch/powerpc/platforms/cell/smp.c    | 3 ---
>  arch/powerpc/platforms/pseries/smp.c | 5 +----
>  2 files changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
> index c855a0aeb49c..d7ab868aab54 100644
> --- a/arch/powerpc/platforms/cell/smp.c
> +++ b/arch/powerpc/platforms/cell/smp.c
> @@ -78,9 +78,6 @@ static inline int smp_startup_cpu(unsigned int lcpu)
>  
>  	pcpu = get_hard_smp_processor_id(lcpu);
>  
> -	/* Fixup atomic count: it exited inside IRQ handler. */
> -	task_thread_info(paca_ptrs[lcpu]->__current)->preempt_count	= 0;
> -
>  	/*
>  	 * If the RTAS start-cpu token does not exist then presume the
>  	 * cpu is already spinning.
> diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
> index 096629f54576..7ebf3382816a 100644
> --- a/arch/powerpc/platforms/pseries/smp.c
> +++ b/arch/powerpc/platforms/pseries/smp.c
> @@ -105,10 +105,7 @@ static inline int smp_startup_cpu(unsigned int lcpu)
>  		return 1;
>  	}
>  
> -	/* Fixup atomic count: it exited inside IRQ handler. */
> -	task_thread_info(paca_ptrs[lcpu]->__current)->preempt_count	= 0;
> -
> -	/* 
> +	/*
>  	 * If the RTAS start-cpu token does not exist then presume the
>  	 * cpu is already spinning.
>  	 */
> -- 
> 2.25.1
> 

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

end of thread, other threads:[~2021-07-08 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 18:38 [PATCH] powerpc: preempt: Don't touch the idle task's preempt_count during hotplug Valentin Schneider
2021-07-08  9:38 ` Bharata B Rao
2021-07-08 13:53 ` Michael Ellerman
2021-07-07 19:18 Guenter Roeck

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