Using __kuser_cmpxchg

Andrew Haley aph@redhat.com
Fri Nov 16 11:32:00 GMT 2007


Pavel Pisa writes:
 > On Friday 16 November 2007 02:17, Nicolas Pitre wrote:
 > topic and do not see real problem,
 > but I have next idea.
 > 
 > There could occur four cases during cmpxchg/CAS processing
 > 
 >                  no disturbance    exception, etc.
 >   old==actual        succeed         FAIL
 >   old!=actual        fail            fail
 > 
 > The problematic case from the caller point of view is the false
 > "FAIL" case which could be incompatible with some other logic
 > (requires retry/busy loop) even that in "fail" case some other
 > activity - sleep report failure etc.
 > 
 > The expected can be achieved by two ways:
 >  - wrap up cmpxchg_orig() such way, that
 > 
 >    cmpxchg(ptr, old, new)
 >      do {
 >        ret = cmpxchg_orig()
 >      } while ((ret!=old) && (*ptr==old));

cmpxchg_orig returns a boolean, but I guess you could do

do {
  ret = cmpxchg_orig(ptr, old, new);
} while (ret && (*ptr == old));

That would be enough for me.  However, I'm quite anxious to get the
kernel version changed in case it trips up other people who don't read
the documentation carefully enough.

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903



More information about the Java mailing list