mbox series

[RFC,v2,0/2] riscv: Idle thread using Zawrs extension

Message ID 20240621093223.37893-1-luxu.kernel@bytedance.com (mailing list archive)
Headers show
Series riscv: Idle thread using Zawrs extension | expand

Message

Xu Lu June 21, 2024, 9:32 a.m. UTC
This is the second version of idle thread based on Zawrs extension. We
rebased our code on Andrew's patch series[1] which provides basic
support for Zawrs as well as optimization for spinlock.

This patch series introduces a new implementation of idle thread using
Zawrs extension.

The Zawrs[0] extension introduces two new instructions named WRS.STO and
WRS.NTO in RISC-V. When software registers a reservation set using LR
instruction, a subsequent WRS.STO or WRS.NTO instruction will cause the
hart to stall in a low-power state until a store happens to the
reservation set or an interrupt becomes pending. The difference between
these two instructions is that WRS.STO will terminate stall after an
implementation-defined timeout while WRS.NTO won't.

This patch series implements idle thread using WRS.NTO instruction.
Besides, we found there is no need to send a real IPI to wake up an idle
CPU. Instead, we write IPI information to the reservation set of an idle
CPU to wake it up and let it handle IPI quickly, without going through
tranditional interrupt handling routine.

[0] https://github.com/riscv/riscv-zawrs/blob/main/zawrs.adoc
[1] https://github.com/jones-drew/linux/commits/riscv/zawrs-v3

Xu Lu (2):
  riscv: process: Introduce idle thread using Zawrs extension
  riscv: Use Zawrs to accelerate IPI to idle cpu

 arch/riscv/Kconfig                 |  10 +++
 arch/riscv/include/asm/cpuidle.h   |  11 +---
 arch/riscv/include/asm/processor.h |  32 +++++++++
 arch/riscv/include/asm/smp.h       |  14 ++++
 arch/riscv/kernel/cpu.c            |   5 ++
 arch/riscv/kernel/process.c        | 102 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/smp.c            |  39 +++++++----
 7 files changed, 190 insertions(+), 23 deletions(-)

Comments

Andrea Parri June 21, 2024, 11:16 a.m. UTC | #1
> This is the second version of idle thread based on Zawrs extension. We
> rebased our code on Andrew's patch series[1] which provides basic
> support for Zawrs as well as optimization for spinlock.

There's some feedback on Andrew's v2 [1] which seems to equally apply
to the later, mentioned series/submission, and hence to the series in
question (although only indirectly admittedly).

As an additional comment, please do add  linux-kernel@vger.kernel.org 
(the LKML) to your Cc:  list on patch submission (again, this applies
to both Andrew's and the present submissions).

  Andrea

[1] https://lore.kernel.org/linux-riscv/ZiWCP6f6zZ3dKXfN@andrea/
Andrea Parri June 21, 2024, 11:24 a.m. UTC | #2
On Fri, Jun 21, 2024 at 01:16:50PM +0200, Andrea Parri wrote:
> > This is the second version of idle thread based on Zawrs extension. We
> > rebased our code on Andrew's patch series[1] which provides basic
> > support for Zawrs as well as optimization for spinlock.
> 
> There's some feedback on Andrew's v2 [1] which seems to equally apply
> to the later, mentioned series/submission, and hence to the series in
> question (although only indirectly admittedly).
> 
> As an additional comment, please do add  linux-kernel@vger.kernel.org 
> (the LKML) to your Cc:  list on patch submission (again, this applies
> to both Andrew's and the present submissions).

Ah, yes, and possibly people mentioned in the changelog!  :-)  + Andrew

  Andrea
Xu Lu June 21, 2024, 12:09 p.m. UTC | #3
On Fri, Jun 21, 2024 at 7:17 PM Andrea Parri <parri.andrea@gmail.com> wrote:
>
> > This is the second version of idle thread based on Zawrs extension. We
> > rebased our code on Andrew's patch series[1] which provides basic
> > support for Zawrs as well as optimization for spinlock.
>
> There's some feedback on Andrew's v2 [1] which seems to equally apply
> to the later, mentioned series/submission, and hence to the series in
> question (although only indirectly admittedly).
>
> As an additional comment, please do add  linux-kernel@vger.kernel.org
> (the LKML) to your Cc:  list on patch submission (again, this applies
> to both Andrew's and the present submissions).
>
>   Andrea
>
> [1] https://lore.kernel.org/linux-riscv/ZiWCP6f6zZ3dKXfN@andrea/
Hi Andrea,

Thanks a lot for your reminder. I will check the feedback and add this
email in the next patch series!

Xu Lu