All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <ajones@ventanamicro.com>
To: kvm-riscv@lists.infradead.org
Subject: [PATCH 0/5] riscv: Apply Zawrs when available
Date: Mon, 18 Mar 2024 16:31:45 +0100	[thread overview]
Message-ID: <20240318-b4b5fb6b806fdae244142a32@orel> (raw)
In-Reply-To: <20240315134009.580167-7-ajones@ventanamicro.com>

On Fri, Mar 15, 2024 at 02:40:10PM +0100, Andrew Jones wrote:
> Zawrs provides two instructions (wrs.nto and wrs.sto), where both are
> meant to allow the hart to enter a low-power state while waiting on a
> store to a memory location. The instructions also both wait an
> implementation-defined "short" duration (unless the implementation
> terminates the stall for another reason). The difference is that while
> wrs.sto will terminate when the duration elapses, wrs.nto, depending on
> configuration, will either just keep waiting or an ILL exception will be
> raised.
> 
> Like wfi (and with the same {m,h}status bits to configure it), when
> wrs.nto is configured to raise exceptions it's expected that the higher
> privilege level will see the instruction was a wait instruction, do
> something, and then resume execution following the instruction.
> Currently, it's not expected that M-mode will configure and handle
> exceptions for timeouts (so it's expected that mstatus.TW=0), but KVM does
> configure exceptions for wfi (hstatus.VTW=1) and therefore also for
> wrs.nto. KVM does this for wfi since it's better to allow other tasks to
> be scheduled while a VCPU waits for an interrupt. For waits such as those
> where wrs.nto/sto would be used, which are typically locks, it is also a
> good idea for KVM to be involved, as it can attempt to schedule the lock
> holding VCPU.
> 
> This series starts with Christoph's addition of riscv smp_cond_load*
> functions which apply wrs.sto when available. We then switch from
> wrs.sto to wrs.nto, add hwprobe support (since the instructions are also
> usable from usermode), and finally teach KVM about wrs.nto, allowing
> guests to see and use the Zawrs extension.
> 
> We still don't have test results from hardware, and it's not possible to
> prove that using Zawrs is a win when testing on QEMU, not even when
> oversubscribing VCPUs to guests. However, it is possible to use KVM
> selftests to force a scenario where we can prove Zawrs does its job and
> does it well. [4] is a test which does this and, on my machine, without
> Zawrs it takes 16 seconds to complete and with Zawrs it takes 0.25
> seconds.
> 
> This series is based on kvm/queue and also available here [1]. In order
> to use QEMU for testing a build with [2] is needed. In order to enable
> guests to use Zawrs with KVM using kvmtool, the branch at [3] may be used.
> 
> [1] https://github.com/jones-drew/linux/commits/riscv/zawrs-v1/
> [2] https://lore.kernel.org/all/20240312152901.512001-2-ajones at ventanamicro.com/
> [3] https://github.com/jones-drew/kvmtool/commits/riscv/zawrs/
> [4] https://github.com/jones-drew/linux/commit/2e712b19b7bb78634199bf262e6a75e09e1c87d2
> 
> Thanks,
> drew
> 
> 
> Andrew Jones (4):
>   riscv: Prefer wrs.nto over wrs.sto
>   riscv: hwprobe: export Zawrs ISA extension
>   KVM: riscv: Support guest wrs.nto
>   KVM: riscv: selftests: Add Zawrs extension to get-reg-list test
> 
> Christoph M??llner (1):
>   riscv: Add Zawrs support for spinlocks

I see I also forgot to add the patch for the entry in
Documentation/devicetree/bindings/riscv/extensions.yaml

Will do for v2.

Thanks,
drew


WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jones <ajones@ventanamicro.com>
To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org
Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu,  conor.dooley@microchip.com,
	anup@brainfault.org, atishp@atishpatra.org,
	 christoph.muellner@vrull.eu, heiko@sntech.de,
	charlie@rivosinc.com, David.Laight@aculab.com
Subject: Re: [PATCH 0/5] riscv: Apply Zawrs when available
Date: Mon, 18 Mar 2024 16:31:45 +0100	[thread overview]
Message-ID: <20240318-b4b5fb6b806fdae244142a32@orel> (raw)
In-Reply-To: <20240315134009.580167-7-ajones@ventanamicro.com>

On Fri, Mar 15, 2024 at 02:40:10PM +0100, Andrew Jones wrote:
> Zawrs provides two instructions (wrs.nto and wrs.sto), where both are
> meant to allow the hart to enter a low-power state while waiting on a
> store to a memory location. The instructions also both wait an
> implementation-defined "short" duration (unless the implementation
> terminates the stall for another reason). The difference is that while
> wrs.sto will terminate when the duration elapses, wrs.nto, depending on
> configuration, will either just keep waiting or an ILL exception will be
> raised.
> 
> Like wfi (and with the same {m,h}status bits to configure it), when
> wrs.nto is configured to raise exceptions it's expected that the higher
> privilege level will see the instruction was a wait instruction, do
> something, and then resume execution following the instruction.
> Currently, it's not expected that M-mode will configure and handle
> exceptions for timeouts (so it's expected that mstatus.TW=0), but KVM does
> configure exceptions for wfi (hstatus.VTW=1) and therefore also for
> wrs.nto. KVM does this for wfi since it's better to allow other tasks to
> be scheduled while a VCPU waits for an interrupt. For waits such as those
> where wrs.nto/sto would be used, which are typically locks, it is also a
> good idea for KVM to be involved, as it can attempt to schedule the lock
> holding VCPU.
> 
> This series starts with Christoph's addition of riscv smp_cond_load*
> functions which apply wrs.sto when available. We then switch from
> wrs.sto to wrs.nto, add hwprobe support (since the instructions are also
> usable from usermode), and finally teach KVM about wrs.nto, allowing
> guests to see and use the Zawrs extension.
> 
> We still don't have test results from hardware, and it's not possible to
> prove that using Zawrs is a win when testing on QEMU, not even when
> oversubscribing VCPUs to guests. However, it is possible to use KVM
> selftests to force a scenario where we can prove Zawrs does its job and
> does it well. [4] is a test which does this and, on my machine, without
> Zawrs it takes 16 seconds to complete and with Zawrs it takes 0.25
> seconds.
> 
> This series is based on kvm/queue and also available here [1]. In order
> to use QEMU for testing a build with [2] is needed. In order to enable
> guests to use Zawrs with KVM using kvmtool, the branch at [3] may be used.
> 
> [1] https://github.com/jones-drew/linux/commits/riscv/zawrs-v1/
> [2] https://lore.kernel.org/all/20240312152901.512001-2-ajones@ventanamicro.com/
> [3] https://github.com/jones-drew/kvmtool/commits/riscv/zawrs/
> [4] https://github.com/jones-drew/linux/commit/2e712b19b7bb78634199bf262e6a75e09e1c87d2
> 
> Thanks,
> drew
> 
> 
> Andrew Jones (4):
>   riscv: Prefer wrs.nto over wrs.sto
>   riscv: hwprobe: export Zawrs ISA extension
>   KVM: riscv: Support guest wrs.nto
>   KVM: riscv: selftests: Add Zawrs extension to get-reg-list test
> 
> Christoph M??llner (1):
>   riscv: Add Zawrs support for spinlocks

I see I also forgot to add the patch for the entry in
Documentation/devicetree/bindings/riscv/extensions.yaml

Will do for v2.

Thanks,
drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2024-03-18 15:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 13:40 [PATCH 0/5] riscv: Apply Zawrs when available Andrew Jones
2024-03-15 13:40 ` Andrew Jones
2024-03-15 13:40 ` [PATCH 1/5] riscv: Add Zawrs support for spinlocks Andrew Jones
2024-03-15 13:40   ` Andrew Jones
2024-03-16 11:36   ` Andrea Parri
2024-03-16 11:36     ` Andrea Parri
2024-03-16 17:17     ` Andrew Jones
2024-03-16 17:17       ` Andrew Jones
2024-03-15 13:40 ` [PATCH 2/5] riscv: Prefer wrs.nto over wrs.sto Andrew Jones
2024-03-15 13:40   ` Andrew Jones
2024-03-15 13:40 ` [PATCH 3/5] riscv: hwprobe: export Zawrs ISA extension Andrew Jones
2024-03-15 13:40   ` Andrew Jones
2024-03-15 13:40 ` [PATCH 4/5] KVM: riscv: Support guest wrs.nto Andrew Jones
2024-03-15 13:40   ` Andrew Jones
2024-03-15 13:40 ` [PATCH 5/5] KVM: riscv: selftests: Add Zawrs extension to get-reg-list test Andrew Jones
2024-03-15 13:40   ` Andrew Jones
2024-03-18 15:31 ` Andrew Jones [this message]
2024-03-18 15:31   ` [PATCH 0/5] riscv: Apply Zawrs when available Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240318-b4b5fb6b806fdae244142a32@orel \
    --to=ajones@ventanamicro.com \
    --cc=kvm-riscv@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.