On Wed, 6 Mar 2024 at 10:53, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > > Now, are you OK with an addition of ADD_ONCE() and/or INC_ONCE()? So that we > don't have to look at: > > WRITE_ONCE(a, READ_ONCE(a) + 1); > > ? In a generic header file under include/linux/? Absolutely not. The above is a completely broken operation. There is no way in hell we should expose it as a general helper. So there is no way we'd add that kind of sh*t-for-brains operation in (for example) our <asm/rwonce.h> header file next to the normal READ/WRITE_ONCE defines. In some individual tracing C file where it has a comment above it how it's braindamaged and unsafe and talking about why it's ok in that particular context? Go wild. But honestly, I do not see when a ADD_ONCE() would ever be a valid thing to do, and *if* it's a valid thing to do, why you'd do it with READ_ONCE and WRITE_ONCE. If you don't care about races, just do a simple "++" and be done with it. The end result is random. Adding a "ADD_ONCE()" macro doesn't make it one whit less random. It just makes a broken concept even uglier. So honestly, I think the ADD_ONCE macro not only needs to be in some tracing-specific C file, the comment needs to be pretty damn big too. Because as a random number generator, it's not even a very good one. So you need to explain *why* you want a particularly bad random number generator in the first place. Linus