aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/atomic.h21
-rw-r--r--kernel/sched/core.c18
2 files changed, 18 insertions, 21 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 3d64c0852164..506c3531832e 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -579,27 +579,6 @@ static inline int atomic_fetch_or(atomic_t *p, int mask)
579} 579}
580#endif 580#endif
581 581
582/**
583 * fetch_or - perform *ptr |= mask and return old value of *ptr
584 * @ptr: pointer to value
585 * @mask: mask to OR on the value
586 *
587 * cmpxchg based fetch_or, macro so it works for different integer types
588 */
589#ifndef fetch_or
590#define fetch_or(ptr, mask) \
591({ typeof(*(ptr)) __old, __val = *(ptr); \
592 for (;;) { \
593 __old = cmpxchg((ptr), __val, __val | (mask)); \
594 if (__old == __val) \
595 break; \
596 __val = __old; \
597 } \
598 __old; \
599})
600#endif
601
602
603#ifdef CONFIG_GENERIC_ATOMIC64 582#ifdef CONFIG_GENERIC_ATOMIC64
604#include <asm-generic/atomic64.h> 583#include <asm-generic/atomic64.h>
605#endif 584#endif
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d8465eeab8b3..8b489fcac37b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -321,6 +321,24 @@ static inline void init_hrtick(void)
321} 321}
322#endif /* CONFIG_SCHED_HRTICK */ 322#endif /* CONFIG_SCHED_HRTICK */
323 323
324/*
325 * cmpxchg based fetch_or, macro so it works for different integer types
326 */
327#define fetch_or(ptr, mask) \
328 ({ \
329 typeof(ptr) _ptr = (ptr); \
330 typeof(mask) _mask = (mask); \
331 typeof(*_ptr) _old, _val = *_ptr; \
332 \
333 for (;;) { \
334 _old = cmpxchg(_ptr, _val, _val | _mask); \
335 if (_old == _val) \
336 break; \
337 _val = _old; \
338 } \
339 _old; \
340})
341
324#if defined(CONFIG_SMP) && defined(TIF_POLLING_NRFLAG) 342#if defined(CONFIG_SMP) && defined(TIF_POLLING_NRFLAG)
325/* 343/*
326 * Atomically set TIF_NEED_RESCHED and test for TIF_POLLING_NRFLAG, 344 * Atomically set TIF_NEED_RESCHED and test for TIF_POLLING_NRFLAG,