public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: 'Christoph Muellner' <christoph.muellner@vrull.eu>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Aaron Durbin <adurbin@rivosinc.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Atish Patra <atishp@atishpatra.org>
Cc: David Laight <David.Laight@aculab.com>
Subject: Re: [RFC PATCH v2] riscv: Add Zawrs support for spinlocks
Date: Mon, 15 May 2023 00:29:30 +0200	[thread overview]
Message-ID: <2679603.mvXUDI8C0e@diego> (raw)
In-Reply-To: <f04bd42eb93b4c4dbece34236a7b994b@AcuMS.aculab.com>

Hi David,

Am Freitag, 24. Juni 2022, 10:52:40 CEST schrieb David Laight:
> From: Christoph Muellner
> > Sent: 23 June 2022 16:30
> > 
> > From: Christoph Müllner <christoph.muellner@vrull.eu>
> > 
> > The current RISC-V code uses the generic ticket lock implementation,
> > that calls the macros smp_cond_load_relaxed() and smp_cond_load_acquire().
> > Currently, RISC-V uses the generic implementation of these macros.
> > This patch introduces a RISC-V specific implementation, of these
> > macros, that peels off the first loop iteration and modifies the waiting
> > loop such, that it is possible to use the WRS.STO instruction of the Zawrs
> > ISA extension to stall the CPU.
> > 
> > The resulting implementation of smp_cond_load_*() will only work for
> > 32-bit or 64-bit types for RV64 and 32-bit types for RV32.
> > This is caused by the restrictions of the LR instruction (RISC-V only
> > has LR.W and LR.D). Compiler assertions guard this new restriction.
> > 
> > This patch uses the existing RISC-V ISA extension framework
> > to detect the presents of Zawrs at run-time.
> > If available a NOP instruction will be replaced by WRS.NTO or WRS.STO.
> > 
> > The whole mechanism is gated by Kconfig setting, which defaults to Y.
> > 
> > The Zawrs specification can be found here:
> > https://github.com/riscv/riscv-zawrs/blob/main/zawrs.adoc
> > 
> > Note, that the Zawrs extension is not frozen or ratified yet.
> > Therefore this patch is an RFC and not intended to get merged.
> > 
> > Changes since v1:
> > * Adding "depends on !XIP_KERNEL" to RISCV_ISA_ZAWRS
> > * Fixing type checking code in __smp_load_reserved*
> > * Adjustments according to the specification change
> > 
> > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>

I'm only addressing the point here were I don't agree with you :-)
Everything else will be in the next version.

[...]

> > +
> > +#define ___smp_load_reservedN(pfx, ptr)					\
> > +({									\
> > +	typeof(*ptr) ___p1;						\
> > +	__asm__ __volatile__ ("lr." pfx "	%[p], %[c]\n"		\
> > +			      : [p]"=&r" (___p1), [c]"+A"(*ptr));	\
> > +	___p1;								\
> > +})
> 
> Isn't that missing the memory reference?
> It either needs a extra memory parameter for 'ptr' or
> a full/partial memory clobber.

Shouldn't the "+A" for *ptr should take care of that?

From the gcc docs [0]:
	‘+’  Means that this operand is both read and written by the instruction.


Heiko

[0] https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#index-_002b-in-constraint




      reply	other threads:[~2023-05-14 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 15:29 [RFC PATCH v2] riscv: Add Zawrs support for spinlocks Christoph Muellner
2022-06-23 16:31 ` Heiko Stübner
2022-06-24  7:33   ` Christoph Müllner
2022-06-24  8:52 ` David Laight
2023-05-14 22:29   ` Heiko Stübner [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=2679603.mvXUDI8C0e@diego \
    --to=heiko@sntech.de \
    --cc=David.Laight@aculab.com \
    --cc=adurbin@rivosinc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=christoph.muellner@vrull.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=rdunlap@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox