arm64: Improve parking of stopped CPUs
PATCH 1/1 arm64: Improve parking of stopped CPUs
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the cpu_park_loop() function here to do a wfi/wfe.
--- arch/arm64/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/smp.c +1 -2
@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable (); -while (1 ) -cpu_relax (); +cpu_park_loop (); }/*
Signature · 1 line
2.7.4
PATCH 1/1 arm64: Improve parking of stopped CPUs
Quoted 14 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>--- arch/arm64/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +0
-0
arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 833
Quoted 7 lines
arch/arm64/kernel/smp.c +1
-2@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable (); -while (1 ) -cpu_relax (); +cpu_park_loop (); }
Hmm, so we actually added the yield for QEMU's benefit iirc, where QEMU will trap the yield and schedule a different vCPU. Should we be adding a yield to cpu_park_loop instead?
Will
PATCH 1/1 arm64: Improve parking of stopped CPUs
Quoted 18 lines · Will Deacon
Quoted 17 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>--- arch/arm64/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +0
-0@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable ();
Quoted 8 lines
arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 833
Quoted 4 lines
arch/arm64/kernel/smp.c +1
-2-while (1 ) -cpu_relax (); +cpu_park_loop (); }Hmm, so we actually added the yield for QEMU's benefit iirc, where QEMU will trap the yield and schedule a different vCPU. Should we be adding a yield to
cpu_park_loopinstead?
Wouldn't wfi/wfe trigger the same ? I don't know how yield affects a physical CPU. The cpu_park_loop is also used by CPUs which cannot run due to the missing capabilities on the system. As long as yield() doesn't affect the PCPUs, we could do that. Going another step further, we could also include local_irq_disable() in cpu_park_loop().
Suzuki
PATCH 1/1 arm64: Improve parking of stopped CPUs
Quoted 28 lines · Suzuki K Poulose
Quoted 18 lines · Will Deacon
Quoted 17 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>---
arch/arm64/kernel/smp.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +0
-0@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable ();Quoted 8 lines
arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 833
Quoted 4 lines
arch/arm64/kernel/smp.c +1
-2-while (1 ) -cpu_relax (); +cpu_park_loop (); }Hmm, so we actually added the yield for QEMU's benefit iirc, where QEMU will trap the yield and schedule a different vCPU. Should we be adding a yield to
cpu_park_loopinstead?
Quoted 4 lines
Wouldn't wfi/wfe trigger the same ? I don't know how yield affects a physical CPU. The
cpu_park_loopis also used by CPUs which cannot run due to the missing capabilities on the system. As long asyield()doesn't affect the PCPUs, we could do that.
Yes, good point, it looks like WFE should do the same thing.
Quoted 2 lines
Going another step further, we could also include
local_irq_disable()incpu_park_loop().
Why?
Will
PATCH 1/1 arm64: Improve parking of stopped CPUs
Quoted 29 lines · Will Deacon
Quoted 28 lines · Suzuki K Poulose
Quoted 26 lines · Will Deacon
Quoted 14 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>---
arch/arm64/kernel/smp.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +0
-0arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 833
Quoted 7 lines
arch/arm64/kernel/smp.c +1
-2@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable (); -while (1 ) -cpu_relax (); +cpu_park_loop (); }Hmm, so we actually added the yield for QEMU's benefit iirc, where QEMU will trap the yield and schedule a different vCPU. Should we be adding a yield to
cpu_park_loopinstead?
Quoted 6 lines
Quoted 4 lines
Wouldn't wfi/wfe trigger the same ? I don't know how yield affects a physical CPU. The
cpu_park_loopis also used by CPUs which cannot run due to the missing capabilities on the system. As long asyield()doesn't affect the PCPUs, we could do that.Yes, good point, it looks like WFE should do the same thing.
Agree, I am not sure if there is any case where 'yield' is a better option. There are a few cases in kernel/process.c which ends in 'while (1);' where the point about QEMU may be valid. These can be fixed up if needed.
Quoted 2 lines
Quoted 2 lines
Going another step further, we could also include
local_irq_disable()incpu_park_loop().
There is a cpu_panic_kernel() which calls cpu_park_loop() without the irq disable. It maybe OK to local_irq_disable for that too, but probably not in the scope of this patch.
JC.
Hi,
Quoted 5 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>
Looks like this patch has been forgotten?
I have a system where CPUs need to be put in wfi/wfe for the warm reset to work, and using cpu_park_loop() would solve this.
A.
Quoted 8 lines
arch/arm64/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +0
-0
arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 835
Quoted 9 lines
arch/arm64/kernel/smp.c +1
-2@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable (); -while (1 ) -cpu_relax (); +cpu_park_loop (); }/*
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 10 lines · Aaro Koskinen
External Email
----------------------------------------------------------------------
Hi,Quoted 4 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.
Quoted 6 lines
Quoted 1 line
Signed-off-by Jayachandran C <[email protected]>Looks like this patch has been forgotten?
I have a system where CPUs need to be put in wfi/wfe for the warm reset to work, and using
cpu_park_loop()would solve this.
If I remember correctly (it has been a while), in my testing I saw that the wfi does not block after a while since interrupts are pending. Most likely that timer interrupts will still be enabled.
We might need some code to reset/disable the GIC interface for the CPU before parking.
Quoted 9 lines
Quoted 9 lines
arch/arm64/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +0
-0@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)
Quoted 8 lines
arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 835
Quoted 8 lines
arch/arm64/kernel/smp.c +1
-2local_irq_disable (); -while (1 ) -cpu_relax (); +cpu_park_loop (); }/*
JC
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi,
Quoted 8 lines · Jayachandran Chandrasekharan Nair
Quoted 7 lines · Aaro Koskinen
Quoted 5 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>
Quoted 8 lines
Quoted 4 lines
Looks like this patch has been forgotten?
I have a system where CPUs need to be put in wfi/wfe for the warm reset to work, and using
cpu_park_loop()would solve this.If I remember correctly (it has been a while), in my testing I saw that the wfi does not block after a while since interrupts are pending. Most likely that timer interrupts will still be enabled.
Right, this is correct; I also observed the same in my testing.
Quoted 2 lines
We might need some code to reset/disable the GIC interface for the CPU before parking.
I solved this by doing the global GIC disable in the firmware PSCI reset function code. So from Linux side cpu_park_loop() is enough, and already this patch is an improvement.
A.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
arch/arm64/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kernel/smp.c +1
-2@@ -829,8 +829,7 @@ static void ipi_cpu_stop(unsigned int cpu)local_irq_disable (); -while (1 ) -cpu_relax (); +cpu_park_loop (); }
Quoted 8 lines
Quoted 1 line
arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 835
Quoted 1 line
arch/arm64/kernel/smp.c +0
-0/* JC
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 20 lines · Aaro Koskinen
Hi,
Quoted 8 lines · Jayachandran Chandrasekharan Nair
Quoted 7 lines · Aaro Koskinen
Quoted 5 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>Quoted 8 lines
Quoted 4 lines
Looks like this patch has been forgotten?
I have a system where CPUs need to be put in wfi/wfe for the warm reset to work, and using
cpu_park_loop()would solve this.If I remember correctly (it has been a while), in my testing I saw that the wfi does not block after a while since interrupts are pending. Most likely that timer interrupts will still be enabled.
Quoted 8 lines
Right, this is correct; I also observed the same in my testing.
Quoted 2 lines
We might need some code to reset/disable the GIC interface for the CPU before parking.
I solved this by doing the global GIC disable in the firmware PSCI reset function code. So from Linux side
cpu_park_loop()is enough, and already this patch is an improvement.
Ideally, I think the GIC driver has to be updated to turn off the interrupts to the CPU before we get to this point in the code. There are some power management and hotplug notifiers already in the GIC driver, I wonder if it is possible to take care of this too.
Since Linux turns on the interrupts, it would be better if Linux turns them off too, rather than relying on the platform to do it.
JC
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 11 lines · Aaro Koskinen
Quoted 5 lines · Jayachandran C
The current code puts the stopped cpus in an 'yield' instruction loop. Using a busy loop here is unnecessary, we can use the
cpu_park_loop()function here to do a wfi/wfe.Signed-off-by Jayachandran C <[email protected]>Looks like this patch has been forgotten?
I have a system where CPUs need to be put in wfi/wfe for the warm reset to work, and using
cpu_park_loop()would solve this.
Yikes, that's over two years old. Maybe resend it?
Will
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel