Re: [PATCH 8/9] RISC-V: User-facing API

From: Palmer Dabbelt
Date: Mon Jul 10 2017 - 16:18:37 EST

On Mon, 10 Jul 2017 13:00:29 PDT (-0700), Palmer Dabbelt wrote:
> On Thu, 06 Jul 2017 08:45:13 PDT (-0700), will.deacon@xxxxxxx wrote:
>> On Thu, Jul 06, 2017 at 08:34:27AM -0700, Christoph Hellwig wrote:
>>> On Thu, Jul 06, 2017 at 09:55:03AM +0100, Will Deacon wrote:
>>> > Agreed on the indirection; it feels like this is something that should be in
>>> > the vDSO, which could use the cmpxchg instruction if it's available, or
>>> > otherwise just uses plain loads and stores.
> These are already in the vDSO, and use the corresponding atomic instructions on
> systems with the A extension. The vDSO routines call the system calls in non-A
> systems. As far as I can tell that's necessary to preserve atomicity, which we
> currently do by disabling scheduling. If there's a way to do this without
> entering the kernel then I'd be happy to support it, but I'm not sure how we
> could maintain atomicity using only regular loads and stores.
>>> Even that seems like a lot of indirection for something that is in
>>> the critical fast path for synchronization. I really can't understand
>>> how a new ISA / ABI could even come up with an idea as stupid as making
>>> essential synchronization primitives optional.
>> No disagreement there!
> The default set of multilibs on Linux are:
> * rv32imac: 32-bit; Multiply, Atomic, and Compressed extensions
> * rv32imafdc: like above, but with single+double float
> * rv64imac: 64-bit, Multiply, Atomic and Compressed
> * rv64imafdc: like above, but with single+double float
> all of which support the A extension. We certainly don't plan on building any
> systems that support Linux without the A extension at SiFive, so I'm fine
> removing the system call -- this was originally added by a user, so there was
> at least enough interest for someone to add the system call.
> We've found people are retrofitting other cores to run RISC-V, and I could
> certainly imagine an older design that lacks a beefy enough memory system to
> support our atomics (which are LR/SC based) being a design that might arise.
> There's a lot of systems where people don't seem to care that much about the
> performance and just want something to work -- if they're on such a tiny system
> they can't implement the A extension then they're probably not going to be
> doing a lot of atomics anyway, so maybe it doesn't matter if atomics are slow.
> As the cost for supporting these A-less systems seems fairly small, it seemed
> like the right thing to do -- one of the points of making RISC-V have many
> optional extensions was to let people pick the ones they view as important.
> Since I don't know the performance constraints of their systems or the cost of
> implementing the A extension in their design, I'm not really qualified to tell
> them a cmpxchg syscall is a bad idea.
> I'm fine either way here: if someone's core can't support the A extension they
> can always just buy one that does (ideally from us :)). If it was up to be I'd
> leave the calls in there, as I generally don't like to tell users we won't
> support their use case, but since you guys seem to know a lot more about this
> than I do I'll just leave the decision up to you.
> If you want the system call (and the corresponding vDSO entry, which will be
> unnecessary if we mandate A) gone then I'll remove it for our v5. Just give me
> a heads up.
> Thanks, and sorry for wasting your time!

I mangled this message when sending it so I'm trying again.