mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RISC-V: cpu-hotplug fix
@ 2025-09-19 13:28 Danil Skrebenkov
  2025-09-24 16:56 ` Andrew Jones
  2025-10-08 17:50 ` Paul Walmsley
  0 siblings, 2 replies; 3+ messages in thread
From: Danil Skrebenkov @ 2025-09-19 13:28 UTC (permalink / raw)
  Cc: pjw, Danil Skrebenkov, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Charlie Jenkins, WangYuli, linux-riscv,
	linux-kernel

openSBI v1.7 adds harts checks for ipi operations. Especially it
adds comparison between hmask passed as an argument from linux
and mask of online harts (from openSBI side). If they don't
fit each other the error occurs.

When cpu is offline, cpu_online_mask is explicitly cleared in
__cpu_disable. However, there is no explicit clearing of
mm_cpumask. mm_cpumask is used for rfence operations that
call openSBI RFENCE extension which uses ipi to remote harts.
If hart is offline there may be error if mask of linux is not
as mask of online harts in openSBI.

this patch adds explicit clearing of mm_cpumask for offline hart.

Signed-off-by: Danil Skrebenkov <danil.skrebenkov@cloudbear.ru>
---
 arch/riscv/kernel/cpu-hotplug.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/kernel/cpu-hotplug.c b/arch/riscv/kernel/cpu-hotplug.c
index a1e38ecfc8be..3f50d3dd76c6 100644
--- a/arch/riscv/kernel/cpu-hotplug.c
+++ b/arch/riscv/kernel/cpu-hotplug.c
@@ -54,6 +54,7 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
 
 	pr_notice("CPU%u: off\n", cpu);
 
+	clear_tasks_mm_cpumask(cpu);
 	/* Verify from the firmware if the cpu is really stopped*/
 	if (cpu_ops->cpu_is_stopped)
 		ret = cpu_ops->cpu_is_stopped(cpu);
-- 
2.43.0


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

* Re: [PATCH] RISC-V: cpu-hotplug fix
  2025-09-19 13:28 [PATCH] RISC-V: cpu-hotplug fix Danil Skrebenkov
@ 2025-09-24 16:56 ` Andrew Jones
  2025-10-08 17:50 ` Paul Walmsley
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2025-09-24 16:56 UTC (permalink / raw)
  To: Danil Skrebenkov
  Cc: pjw, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Charlie Jenkins, WangYuli, linux-riscv, linux-kernel

On Fri, Sep 19, 2025 at 04:28:46PM +0300, Danil Skrebenkov wrote:
> openSBI v1.7 adds harts checks for ipi operations. Especially it
> adds comparison between hmask passed as an argument from linux
> and mask of online harts (from openSBI side). If they don't
> fit each other the error occurs.
> 
> When cpu is offline, cpu_online_mask is explicitly cleared in
> __cpu_disable. However, there is no explicit clearing of
> mm_cpumask. mm_cpumask is used for rfence operations that
> call openSBI RFENCE extension which uses ipi to remote harts.
> If hart is offline there may be error if mask of linux is not
> as mask of online harts in openSBI.
> 
> this patch adds explicit clearing of mm_cpumask for offline hart.
> 
> Signed-off-by: Danil Skrebenkov <danil.skrebenkov@cloudbear.ru>
> ---
>  arch/riscv/kernel/cpu-hotplug.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/riscv/kernel/cpu-hotplug.c b/arch/riscv/kernel/cpu-hotplug.c
> index a1e38ecfc8be..3f50d3dd76c6 100644
> --- a/arch/riscv/kernel/cpu-hotplug.c
> +++ b/arch/riscv/kernel/cpu-hotplug.c
> @@ -54,6 +54,7 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
>  
>  	pr_notice("CPU%u: off\n", cpu);
>  
> +	clear_tasks_mm_cpumask(cpu);
>  	/* Verify from the firmware if the cpu is really stopped*/
>  	if (cpu_ops->cpu_is_stopped)
>  		ret = cpu_ops->cpu_is_stopped(cpu);
> -- 
> 2.43.0
>

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

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

* Re: [PATCH] RISC-V: cpu-hotplug fix
  2025-09-19 13:28 [PATCH] RISC-V: cpu-hotplug fix Danil Skrebenkov
  2025-09-24 16:56 ` Andrew Jones
@ 2025-10-08 17:50 ` Paul Walmsley
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Walmsley @ 2025-10-08 17:50 UTC (permalink / raw)
  To: Danil Skrebenkov
  Cc: pjw, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Charlie Jenkins, WangYuli, linux-riscv, linux-kernel

On Fri, 19 Sep 2025, Danil Skrebenkov wrote:

> openSBI v1.7 adds harts checks for ipi operations. Especially it
> adds comparison between hmask passed as an argument from linux
> and mask of online harts (from openSBI side). If they don't
> fit each other the error occurs.
> 
> When cpu is offline, cpu_online_mask is explicitly cleared in
> __cpu_disable. However, there is no explicit clearing of
> mm_cpumask. mm_cpumask is used for rfence operations that
> call openSBI RFENCE extension which uses ipi to remote harts.
> If hart is offline there may be error if mask of linux is not
> as mask of online harts in openSBI.
> 
> this patch adds explicit clearing of mm_cpumask for offline hart.
> 
> Signed-off-by: Danil Skrebenkov <danil.skrebenkov@cloudbear.ru>

Thanks, queued for early v6.18-rc after cleaning up the subject line to be 
more descriptive:

"RISC-V: clear hot-unplugged cores from all task mm_cpumasks to avoid 
rfence errors"


- Paul



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

end of thread, other threads:[~2025-10-08 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-19 13:28 [PATCH] RISC-V: cpu-hotplug fix Danil Skrebenkov
2025-09-24 16:56 ` Andrew Jones
2025-10-08 17:50 ` Paul Walmsley

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®