public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Frederic Weisbecker <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, fweisbec@gmail.com,
	torvalds@linux-foundation.org, peterz@infradead.org,
	mingo@kernel.org, tglx@linutronix.de
Subject: [tip:core/urgent] locking/atomic: Introduce atomic_fetch_or()
Date: Tue, 29 Mar 2016 03:36:47 -0700	[thread overview]
Message-ID: <tip-5acba71e18833b9d06686b3751598bfa263a3ac3@git.kernel.org> (raw)
In-Reply-To: <1458830281-4255-2-git-send-email-fweisbec@gmail.com>

Commit-ID:  5acba71e18833b9d06686b3751598bfa263a3ac3
Gitweb:     http://git.kernel.org/tip/5acba71e18833b9d06686b3751598bfa263a3ac3
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Thu, 24 Mar 2016 15:37:59 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 29 Mar 2016 11:52:11 +0200

locking/atomic: Introduce atomic_fetch_or()

This is deemed to replace the type generic fetch_or() which brings a lot
of issues such as macro induced block variable aliasing and sloppy types.
Not to mention fetch_or() doesn't refer to any namespace, adding even
more confusion.

So lets provide an atomic_t version. Current and next users of fetch_or()
are thus encouraged to use atomic_t.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1458830281-4255-2-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/atomic.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index df4f369..3d64c08 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -559,6 +559,27 @@ static inline int atomic_dec_if_positive(atomic_t *v)
 #endif
 
 /**
+ * atomic_fetch_or - perform *p |= mask and return old value of *p
+ * @p: pointer to atomic_t
+ * @mask: mask to OR on the atomic_t
+ */
+#ifndef atomic_fetch_or
+static inline int atomic_fetch_or(atomic_t *p, int mask)
+{
+	int old, val = atomic_read(p);
+
+	for (;;) {
+		old = atomic_cmpxchg(p, val, val | mask);
+		if (old == val)
+			break;
+		val = old;
+	}
+
+	return old;
+}
+#endif
+
+/**
  * fetch_or - perform *ptr |= mask and return old value of *ptr
  * @ptr: pointer to value
  * @mask: mask to OR on the value

  reply	other threads:[~2016-03-29 10:37 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-bot for Frederic Weisbecker [this message]
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:core/urgent] locking/atomic, sched: Unexport fetch_or() tip-bot for Frederic Weisbecker
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-5acba71e18833b9d06686b3751598bfa263a3ac3@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