Skip to content

Commit 5fd7a09

Browse files
committed
atomic: Export fetch_or()
Export fetch_or() that's implemented and used internally by the scheduler. We are going to use it for NO_HZ so make it generally available. Reviewed-by: Chris Metcalf <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Chris Metcalf <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Luiz Capitulino <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Viresh Kumar <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 36f90b0 commit 5fd7a09

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

include/linux/atomic.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,27 @@ static inline int atomic_dec_if_positive(atomic_t *v)
548548
}
549549
#endif
550550

551+
/**
552+
* fetch_or - perform *ptr |= mask and return old value of *ptr
553+
* @ptr: pointer to value
554+
* @mask: mask to OR on the value
555+
*
556+
* cmpxchg based fetch_or, macro so it works for different integer types
557+
*/
558+
#ifndef fetch_or
559+
#define fetch_or(ptr, mask) \
560+
({ typeof(*(ptr)) __old, __val = *(ptr); \
561+
for (;;) { \
562+
__old = cmpxchg((ptr), __val, __val | (mask)); \
563+
if (__old == __val) \
564+
break; \
565+
__val = __old; \
566+
} \
567+
__old; \
568+
})
569+
#endif
570+
571+
551572
#ifdef CONFIG_GENERIC_ATOMIC64
552573
#include <asm-generic/atomic64.h>
553574
#endif

kernel/sched/core.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -453,20 +453,6 @@ static inline void init_hrtick(void)
453453
}
454454
#endif /* CONFIG_SCHED_HRTICK */
455455

456-
/*
457-
* cmpxchg based fetch_or, macro so it works for different integer types
458-
*/
459-
#define fetch_or(ptr, val) \
460-
({ typeof(*(ptr)) __old, __val = *(ptr); \
461-
for (;;) { \
462-
__old = cmpxchg((ptr), __val, __val | (val)); \
463-
if (__old == __val) \
464-
break; \
465-
__val = __old; \
466-
} \
467-
__old; \
468-
})
469-
470456
#if defined(CONFIG_SMP) && defined(TIF_POLLING_NRFLAG)
471457
/*
472458
* Atomically set TIF_NEED_RESCHED and test for TIF_POLLING_NRFLAG,

0 commit comments

Comments
 (0)