From: tip-bot for Frederic Weisbecker <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de,
fweisbec@gmail.com, akpm@linux-foundation.org, hpa@zytor.com
Subject: [tip:core/urgent] locking/atomic, sched: Unexport fetch_or()
Date: Tue, 29 Mar 2016 03:37:35 -0700 [thread overview]
Message-ID: <tip-5529578a27288d11d4d15635c258c6dde0f0fb10@git.kernel.org> (raw)
In-Reply-To: <1458830281-4255-4-git-send-email-fweisbec@gmail.com>
Commit-ID: 5529578a27288d11d4d15635c258c6dde0f0fb10
Gitweb: http://git.kernel.org/tip/5529578a27288d11d4d15635c258c6dde0f0fb10
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Thu, 24 Mar 2016 15:38:01 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 29 Mar 2016 11:52:11 +0200
locking/atomic, sched: Unexport fetch_or()
This patch functionally reverts:
5fd7a09cfb8c ("atomic: Export fetch_or()")
During the merge Linus observed that the generic version of fetch_or()
was messy:
" This makes the ugly "fetch_or()" macro that the scheduler used
internally a new generic helper, and does a bad job at it. "
e23604edac2a Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Now that we have introduced atomic_fetch_or(), fetch_or() is only used
by the scheduler in order to deal with thread_info flags which type
can vary across architectures.
Lets confine fetch_or() back to the scheduler so that we encourage
future users to use the more robust and well typed atomic_t version
instead.
While at it, fetch_or() gets robustified, pasting improvements from a
previous patch by Ingo Molnar that avoids needless expression
re-evaluations in the loop.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1458830281-4255-4-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/atomic.h | 21 ---------------------
kernel/sched/core.c | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 3d64c08..506c353 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)
}
#endif
-/**
- * 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
-
-
#ifdef CONFIG_GENERIC_ATOMIC64
#include <asm-generic/atomic64.h>
#endif
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d8465ee..8b489fc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -321,6 +321,24 @@ static inline void init_hrtick(void)
}
#endif /* CONFIG_SCHED_HRTICK */
+/*
+ * cmpxchg based fetch_or, macro so it works for different integer types
+ */
+#define fetch_or(ptr, mask) \
+ ({ \
+ typeof(ptr) _ptr = (ptr); \
+ typeof(mask) _mask = (mask); \
+ typeof(*_ptr) _old, _val = *_ptr; \
+ \
+ for (;;) { \
+ _old = cmpxchg(_ptr, _val, _val | _mask); \
+ if (_old == _val) \
+ break; \
+ _val = _old; \
+ } \
+ _old; \
+})
+
#if defined(CONFIG_SMP) && defined(TIF_POLLING_NRFLAG)
/*
* Atomically set TIF_NEED_RESCHED and test for TIF_POLLING_NRFLAG,
next prev parent reply other threads:[~2016-03-29 10:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-24 14:37 [PATCH 0/3] nohz: Convert tick dependency mask to atomic_t Frederic Weisbecker
2016-03-24 14:37 ` [PATCH 1/3] atomic: Introduce atomic_fetch_or Frederic Weisbecker
2016-03-29 10:36 ` [tip:core/urgent] locking/atomic: Introduce atomic_fetch_or() tip-bot for Frederic Weisbecker
2016-03-24 14:38 ` [PATCH 2/3] nohz: Convert tick dependency mask to atomic_t Frederic Weisbecker
2016-03-25 8:52 ` Ingo Molnar
2016-03-25 14:56 ` Frederic Weisbecker
2016-03-29 10:37 ` [tip:core/urgent] timers/nohz: " tip-bot for Frederic Weisbecker
2016-03-24 14:38 ` [PATCH 3/3] Revert "atomic: Export fetch_or()" Frederic Weisbecker
2016-03-29 10:37 ` tip-bot for Frederic Weisbecker [this message]
2016-03-25 8:48 ` [PATCH 0/3] nohz: Convert tick dependency mask to atomic_t Ingo Molnar
2016-03-25 13:17 ` Frederic Weisbecker
2016-03-29 9:44 ` Ingo Molnar
2016-03-29 12:23 ` Linus Torvalds
2016-03-29 12:59 ` Ingo Molnar
2016-03-29 13:05 ` Ingo Molnar
2016-03-29 13:08 ` Frederic Weisbecker
2016-03-31 6:54 ` Ingo Molnar
2016-03-31 9:20 ` Peter Zijlstra
2016-03-31 13:18 ` Ingo Molnar
2016-03-29 13:14 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-5529578a27288d11d4d15635c258c6dde0f0fb10@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox