Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y

From
Arnd Bergmann <arnd@arndb.de>
Date
2020-06-30 19:25:24
Also in
linux-alpha, lkml, virtualization
Reply to
Will Deacon, 2020-06-30
On Tue, Jun 30, 2020 at 7:39 PM Will Deacon [off-list ref] wrote:
quoted hunk ↗ jump to hunk
+#define __READ_ONCE(x)                                                 \
+({                                                                     \
+       int atomic = 1;                                                 \
+       union { __unqual_scalar_typeof(x) __val; char __c[1]; } __u;    \
+       typeof(&(x)) __x = &(x);                                        \
+       switch (sizeof(x)) {                                            \
...
+       atomic ? (typeof(x))__u.__val : (*(volatile typeof(x) *)__x);   \
+})
This expands (x) nine times (five in __unqual_scala_typeof()), which can
lead to significant code bloat after preprocessing if something passes a
compound expression into READ_ONCE().
The compiler works it out eventually, but we've seen an actual slowdown
in compile speed from this recently, especially on clang.

I think if you move the

        typeof(&(x)) __x = &(x);

line first, all other instances can use typeof(*__x) instead of typeof(x)
and avoid this problem. Once we make gcc-4.9 the minimum version,
this could be further improved to

       __auto_type __x = &(x);

       Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (58 messages) 58 messages, 12 authors, last reply 2020-07-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help