Thread (32 messages) 32 messages, 10 authors, 2018-11-05

Re: [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed

From: Guenter Roeck <linux@roeck-us.net>
Date: 2018-11-01 15:28:54
Also in: linux-mips, linux-nfs, lkml, netdev

On Thu, Nov 01, 2018 at 06:30:08AM +0000, Trond Myklebust wrote:
[ ... ]
quoted
For my part I agree that this would be a much better solution. The
argument
that it is not always absolutely guaranteed that atomics don't wrap
doesn't
really hold for me because it looks like they all do. On top of that,
there
is an explicit atomic_dec_if_positive() and
atomic_fetch_add_unless(),
which to me strongly suggests that they _are_ supposed to wrap.
Given the cost of adding a comparison to each atomic operation to
prevent it from wrapping, anything else would not really make sense
to me.
That's a hypothesis, not a proven fact. There are architectures out
there that do not wrap signed integers, hence my question.
If what you say is correct, the kernel is in big trouble on those architectures.
atomic_inc_return() is used all over the place in the kernel with the assumption
that each returned value differs from the previous value (ie the value is used
as cookie, session ID, or for similar purposes).

Guenter
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help