DPDK patches and discussions
 help / color / mirror / Atom feed
From: Punit Agrawal <punit.agrawal@bytedance.com>
To: "Stanisław Kardach" <stanislaw.kardach@gmail.com>
Cc: Daniel Gregory <daniel.gregory@bytedance.com>,
	 Bruce Richardson <bruce.richardson@intel.com>,
	 dev@dpdk.org,  Liang Ma <liangma@bytedance.com>,
	 Punit Agrawal <punit.agrawal@bytedance.com>
Subject: Re: [External] Re: [RFC PATCH] eal/riscv: add support for zawrs extension
Date: Mon, 20 May 2024 16:43:56 +0100	[thread overview]
Message-ID: <87msoko5dv.fsf@bytedance.com> (raw)
In-Reply-To: <CAJcPQBrX+-XceJ0RTNEKTzHQQ9NH==nXnE2_dJJhh6Q=R9wVcA@mail.gmail.com> (=?utf-8?Q?=22Stanis=C5=82aw?= Kardach"'s message of "Sun, 12 May 2024 09:10:49 +0200")

Stanisław Kardach <stanislaw.kardach@gmail.com> writes:

> On Thu, May 2, 2024 at 4:44 PM Daniel Gregory
> <daniel.gregory@bytedance.com> wrote:
>>
>> The zawrs extension adds a pair of instructions that stall a core until
>> a memory location is written to. This patch uses one of them to
>> implement RISCV-specific versions of the rte_wait_until_equal_*
>> functions. This is potentially more energy efficient than the default
>> implementation that uses rte_pause/Zihintpause.
>>
>> The technique works as follows:
>>
>> * Create a reservation set containing the address we want to wait on
>>   using an atomic load (lr.dw)
>> * Call wrs.nto - this blocks until the reservation set is invalidated by
>>   someone else writing to that address
>> * Execution can also resume arbitrarily, so we still need to check
>>   whether a change occurred and loop if not
>>
>> Due to RISC-V atomics only supporting naturally aligned word (32 bit)
>> and double word (64 bit) loads, I've used pointer rounding and bit
>> shifting to implement waiting on 16-bit values.
>>
>> This new functionality is controlled by a Meson flag that is disabled by
>> default.
>>
>> Signed-off-by: Daniel Gregory <daniel.gregory@bytedance.com>
>> Suggested-by: Punit Agrawal <punit.agrawal@bytedance.com>
>> ---
>>
>> Posting as an RFC to get early feedback and enable testing by others
>> with Zawrs-enabled hardware. Whilst I have been able to test it compiles
>> & passes tests using QEMU, I am waiting on some Zawrs-enabled hardware
>> to become available before I carry out performance tests.
>>
>> Nonetheless, I would be glad to hear any feedback on the general
>> approach. Thanks, Daniel
>>
>>  config/riscv/meson.build          |   5 ++
>>  lib/eal/riscv/include/rte_pause.h | 139 ++++++++++++++++++++++++++++++
>>  2 files changed, 144 insertions(+)
>>
>> diff --git a/config/riscv/meson.build b/config/riscv/meson.build
>> index 07d7d9da23..4cfdc42ecb 100644
>> --- a/config/riscv/meson.build
>> +++ b/config/riscv/meson.build
>> @@ -26,6 +26,11 @@ flags_common = [
>>      # read from /proc/device-tree/cpus/timebase-frequency. This property is
>>      # guaranteed on Linux, as riscv time_init() requires it.
>>      ['RTE_RISCV_TIME_FREQ', 0],
>> +
>> +    # Enable use of RISC-V Wait-on-Reservation-Set extension (Zawrs)
>> +    # Mitigates looping when polling on memory locations
>> +    # Make sure to add '_zawrs' to your target's -march below
>> +    ['RTE_RISCV_ZAWRS', false]
> A bit orthogonal to this patch (or maybe not?)
> Should we perhaps add a Qemu target in meson.build which would have
> the modified -march for what qemu supports now?
> Or perhaps add machine detection logic based either on the "riscv,isa"
> cpu@0 property in the DT or RHCT ACPI table?

Compile time feature detection doesn't add a lot of benefit - it doesn't
work in cross builds environments - which is the common way things are
built for RISC-V at the moment. Also it doesn't work for distros where a
single build is used across a broad set of machines.

> Or add perhaps some other way we could specify the extension list
> suffix for -march?

Making it easier to specify the required extensions during the build
does make sense. Though this is an orthogonal change and is better done
in follow-on patches.

[...]

      parent reply	other threads:[~2024-05-21 11:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02 14:41 Daniel Gregory
2024-05-08 11:48 ` Stanisław Kardach
2024-05-12  7:10 ` Stanisław Kardach
2024-05-20  9:48   ` Daniel Gregory
2024-05-20 15:43   ` Punit Agrawal [this message]

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=87msoko5dv.fsf@bytedance.com \
    --to=punit.agrawal@bytedance.com \
    --cc=bruce.richardson@intel.com \
    --cc=daniel.gregory@bytedance.com \
    --cc=dev@dpdk.org \
    --cc=liangma@bytedance.com \
    --cc=stanislaw.kardach@gmail.com \
    /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 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).