linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Chris Metcalf <cmetcalf@ezchip.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Christoph Lameter <cl@linux.com>, Ingo Molnar <mingo@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Rik van Riel <riel@redhat.com>
Subject: [PATCH 1/9] atomic: Export fetch_or()
Date: Mon, 14 Dec 2015 19:38:24 +0100	[thread overview]
Message-ID: <1450118312-3788-2-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1450118312-3788-1-git-send-email-fweisbec@gmail.com>

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.

Cc: Christoph Lameter <cl@linux.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 include/linux/atomic.h | 21 +++++++++++++++++++++
 kernel/sched/core.c    | 14 --------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 301de78..6c502cb 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -548,6 +548,27 @@ static inline int atomic_dec_if_positive(atomic_t *v)
 }
 #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 4d568ac..05b84c6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -453,20 +453,6 @@ 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, val)						\
-({	typeof(*(ptr)) __old, __val = *(ptr);				\
- 	for (;;) {							\
- 		__old = cmpxchg((ptr), __val, __val | (val));		\
- 		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,
-- 
2.6.4


  reply	other threads:[~2015-12-14 18:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14 18:38 [PATCH 0/9] nohz: Tick dependency mask v4 Frederic Weisbecker
2015-12-14 18:38 ` Frederic Weisbecker [this message]
2015-12-16 16:34   ` [PATCH 1/9] atomic: Export fetch_or() Chris Metcalf
2015-12-14 18:38 ` [PATCH 2/9] nohz: Implement wide kick on top of irq work Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 3/9] nohz: New tick dependency mask Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 4/9] nohz: Use enum code for tick stop failure tracing message Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 5/9] perf: Migrate perf to use new tick dependency mask model Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 6/9] sched: Account rr tasks Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 7/9] sched: Migrate sched to use new tick dependency mask model Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 8/9] posix-cpu-timers: Migrate " Frederic Weisbecker
2015-12-14 18:38 ` [PATCH 9/9] sched-clock: " Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2016-02-04 17:00 [PATCH 0/9] nohz: Tick dependency mask v5 Frederic Weisbecker
2016-02-04 17:00 ` [PATCH 1/9] atomic: Export fetch_or() Frederic Weisbecker

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=1450118312-3788-2-git-send-email-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=cl@linux.com \
    --cc=cmetcalf@ezchip.com \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).