[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190111092408.GM30894@hirez.programming.kicks-ass.net>
Date: Fri, 11 Jan 2019 10:24:08 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Vineet Gupta <vineet.gupta1@...opsys.com>
Cc: linux-kernel@...r.kernel.org, linux-snps-arc@...ts.infradead.org,
linux-mm@...ck.org, Miklos Szeredi <mszeredi@...hat.com>,
Ingo Molnar <mingo@...nel.org>,
Jani Nikula <jani.nikula@...el.com>,
Chris Wilson <chris@...is-wilson.co.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Will Deacon <will.deacon@....com>,
Mark Rutland <mark.rutland@....com>
Subject: Re: [PATCH 3/3] bitops.h: set_mask_bits() to return old value
On Thu, Jan 10, 2019 at 04:26:27PM -0800, Vineet Gupta wrote:
> @@ -246,7 +246,7 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr,
> new__ = (old__ & ~mask__) | bits__; \
> } while (cmpxchg(ptr, old__, new__) != old__); \
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 705f7c442691..2060d26a35f5 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -241,10 +241,10 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr,
const typeof(*(ptr)) mask__ = (mask), bits__ = (bits); \
typeof(*(ptr)) old__, new__; \
\
+ old__ = READ_ONCE(*(ptr)); \
do { \
- old__ = READ_ONCE(*(ptr)); \
new__ = (old__ & ~mask__) | bits__; \
- } while (cmpxchg(ptr, old__, new__) != old__); \
+ } while (!try_cmpxchg(ptr, &old__, new__)); \
\
new__; \
})
While there you probably want something like the above... although,
looking at it now, we seem to have 'forgotten' to add try_cmpxchg to the
generic code :/
Powered by blists - more mailing lists