[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-kernel
Subject: Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops
From: "Paul E. McKenney" <paulmck () kernel ! org>
Date: 2024-05-04 5:08:40
Message-ID: 3f2c415d-dc7e-4647-9002-4beb804d885c () paulmck-laptop
[Download RAW message or body]
On Fri, May 03, 2024 at 05:14:22PM -0700, Linus Torvalds wrote:
> On Fri, 3 May 2024 at 16:59, Paul E. McKenney <paulmck@kernel.org> wrote:
> >
> > Hmmm... Maybe something like this very lightly tested patch?
>
> I'm a bit nervous about using the built-in atomics, when it's not
> clear what the compiler will do on various architectures.
>
> Gcc documentation talks about __atomic_is_lock_free(), which makes me
> think that on various architectures it might end up doing some "fall
> back to helper functions" cases (possibly for odd architectures).
Right now, both GCC and Clang complain if you give __atomic_load_n()
something other than a pointer or a sufficiently small scalar on x86.
Let's see, starting with READ_ONCE()...
ARM7-a Clang complains about even single bytes (ARM7-a GCC is
fine).
ARMv8 works like x86 for both GCC and Clang,
AVR GCC and M68K Clang generate calls to helper functions, so they
need to implement {READ,WRITE}_ONCE_MERGEABLE() in terms of the
current {READ,WRITE}_ONCE() macros.
M68K GCC works like x86, but generates a call to a helper function
for an 8-byte load. Which means that the 8-byte case needs to
generate a build error.
Hexagon Clang works like x86.
Loongarch GCC works like x86. Ditto S390, sh, and xtensa GCC.
MIPS Clang works like x86, but throws a build error for long long,
which might be OK given 32-bit. MIPS GCC handles long long also.
MIPS64 and MIPS EL GCC and Clang work like x86, as do both compilers
for POWERPC and POWERPC LE. And for RISC-V 32 and 64 bit.
I based these on this godbolt: https://godbolt.org/z/rrKnnE8nb
The #ifs on lines select the 8-byte and structure case, respectively,
and you can pick your compiler. I just used the latest versions
of each compiler for each architecture, so there might well be
a few more surprises.
> IOW: I don't think the patch is wrong, but I do think we need to
> verify that all compilers we support generate the obvious code for
> this, and we don't have some "fall back to function calls".
You are right, this is going to need some arch-specific code for a few
of the architectures. Hey, I was hoping!!!
The compilers do not currently optimize these things, but things appear
to me to be heading in that direction.
Thanx, Paul
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic