[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170424135045.blkchz5lwzf4ksgo@hirez.programming.kicks-ass.net>
Date: Mon, 24 Apr 2017 15:50:45 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Clark Williams <williams@...hat.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
John Kacur <jkacur@...hat.com>
Subject: Re: [RFC][PATCH tip/sched/core] sched/rt: Simplify the IPI rt
balancing logic
On Mon, Apr 24, 2017 at 09:28:36AM -0400, Steven Rostedt wrote:
> > static inline bool rto_start_trylock(atomic_t *v)
> > {
> > int zero = 0;
> > return atomic_try_cmpxchg(v, &zero, 1);
>
> To keep the same semantics of spin_trylock(), should we:
try_cmpxchg returns the success of the "cmp" part. So if the above
returns true, the "cmp" part was a success and we did the "xchg" part,
so we now own the lock.
That's right, no?
> return !atomic_cmpxchg(v, &zero, 1);
>
> as the old value of zero means we got it.
The same, but results in an extra compare instruction to compare the
result, instead of using the one cmpxchg already did.
> BTW, I don't see any atomic_try_cmpxchg().
a9ebf306f52c ("locking/atomic: Introduce atomic_try_cmpxchg()")
Should be in tip someplace.
Powered by blists - more mailing lists