Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1357908
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [GIT PULL] NOHZ updates for v4.6 |
| Date | 2016-03-15 09:50 +0100 |
| Message-ID | <rcSPU-84X-15@gated-at.bofh.it> (permalink) |
| References | <rczWV-3JY-15@gated-at.bofh.it> <rcNdw-49L-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Mar 14, 2016 at 07:44:14PM -0700, Linus Torvalds wrote:
> On Mon, Mar 14, 2016 at 5:32 AM, Ingo Molnar <mingo@kernel.org> wrote:
> > +/**
> > + * fetch_or - perform *ptr |= mask and return old value of *ptr
> > + * @ptr: pointer to value
> > + * @mask: mask to OR on the value
> > + *
> > + * cmpxchg based fetch_or, macro so it works for different integer types
> > + */
> > +#ifndef fetch_or
> > +#define fetch_or(ptr, mask) \
> > +({ typeof(*(ptr)) __old, __val = *(ptr); \
> > + for (;;) { \
> > + __old = cmpxchg((ptr), __val, __val | (mask)); \
> > + if (__old == __val) \
> > + break; \
> > + __val = __old; \
> > + } \
> > + __old; \
> > +})
> > +#endif
>
> This is garbage.
>
> This macro re-uses the "mask" argument potentially many many times, so
> semantically it's very dubious.
So the below cures that; but do we want to maybe pull this back into
sched.c and expose a version that operates on a fixed type instead?
Although with xchg() and cmpxchg() we've already set a precedence for
multi-width operators.
The whole thread_info::flags thing is rather 'special' and I'm not sure
we even want to go clean that up, I can see why 64bit arch would very
much want a 64bit flags word etc. And TIF_flags are very arch specific.
---
include/linux/atomic.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 6c502cb13c95..114caf672b11 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -558,8 +558,9 @@ static inline int atomic_dec_if_positive(atomic_t *v)
#ifndef fetch_or
#define fetch_or(ptr, mask) \
({ typeof(*(ptr)) __old, __val = *(ptr); \
+ typeof(mask) __mask = (mask); \
for (;;) { \
- __old = cmpxchg((ptr), __val, __val | (mask)); \
+ __old = cmpxchg((ptr), __val, __val | __mask); \
if (__old == __val) \
break; \
__val = __old; \
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL] NOHZ updates for v4.6 Ingo Molnar <mingo@kernel.org> - 2016-03-14 13:40 +0100
Re: [GIT PULL] NOHZ updates for v4.6 Linus Torvalds <torvalds@linux-foundation.org> - 2016-03-15 03:50 +0100
Re: [GIT PULL] NOHZ updates for v4.6 Peter Zijlstra <peterz@infradead.org> - 2016-03-15 09:50 +0100
Re: [GIT PULL] NOHZ updates for v4.6 Ingo Molnar <mingo@kernel.org> - 2016-03-15 10:50 +0100
[PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-15 10:40 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-15 12:00 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-15 13:10 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-15 13:50 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-15 12:10 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-15 13:10 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-15 13:40 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-15 13:40 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-15 14:20 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-15 13:30 +0100
[PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-15 13:30 +0100
Re: [PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-15 14:30 +0100
Re: [PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-16 09:10 +0100
Re: [PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Peter Zijlstra <peterz@infradead.org> - 2016-03-16 09:40 +0100
Re: [PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Frederic Weisbecker <fweisbec@gmail.com> - 2016-03-15 18:10 +0100
Re: [PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Ingo Molnar <mingo@kernel.org> - 2016-03-16 09:20 +0100
Re: [PATCH v2] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Frederic Weisbecker <fweisbec@gmail.com> - 2016-03-17 02:00 +0100
Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Linus Torvalds <torvalds@linux-foundation.org> - 2016-03-15 17:20 +0100
[PATCH] nohz: Change tick_dep_mask from 'unsigned long' to 'unsigned int' Ingo Molnar <mingo@kernel.org> - 2016-03-15 11:00 +0100
Re: [PATCH] nohz: Change tick_dep_mask from 'unsigned long' to 'unsigned int' Ingo Molnar <mingo@kernel.org> - 2016-03-15 13:20 +0100
Re: [PATCH] nohz: Change tick_dep_mask from 'unsigned long' to 'unsigned int' Linus Torvalds <torvalds@linux-foundation.org> - 2016-03-15 17:40 +0100
Re: [PATCH] nohz: Change tick_dep_mask from 'unsigned long' to 'unsigned int' Frederic Weisbecker <fweisbec@gmail.com> - 2016-03-15 18:30 +0100
Re: [PATCH] nohz: Change tick_dep_mask from 'unsigned long' to 'unsigned int' Linus Torvalds <torvalds@linux-foundation.org> - 2016-03-15 18:40 +0100
csiph-web