mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Patrick Palka <patrick@parcs.ath.cx>
To: linux-kernel@vger.kernel.org
Cc: Patrick Palka <patrick@parcs.ath.cx>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: [PATCH] ring-buffer: use atomic_[set|clear]_mask in place of a cmpxchg loop
Date: Wed, 15 Oct 2014 09:41:40 -0400	[thread overview]
Message-ID: <1413380500-3914-1-git-send-email-patrick@parcs.ath.cx> (raw)

Instead of open-coding the equivalent cmpxchg loop we can just use
atomic_set_mask and atomic_clear_mask to atomically OR or AND
the value in &buffer->record_disabled.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Patrick Palka <patrick@parcs.ath.cx>
---

NB: I have only tested this patch on x86_64 by booting with
CONFIG_RING_BUFFER_STARTUP_TEST=y.

 kernel/trace/ring_buffer.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2d75c94..e15ce2a 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3050,13 +3050,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_record_enable);
  */
 void ring_buffer_record_off(struct ring_buffer *buffer)
 {
-	unsigned int rd;
-	unsigned int new_rd;
-
-	do {
-		rd = atomic_read(&buffer->record_disabled);
-		new_rd = rd | RB_BUFFER_OFF;
-	} while (atomic_cmpxchg(&buffer->record_disabled, rd, new_rd) != rd);
+	atomic_set_mask(RB_BUFFER_OFF, &buffer->record_disabled);
 }
 EXPORT_SYMBOL_GPL(ring_buffer_record_off);
 
@@ -3073,13 +3067,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_record_off);
  */
 void ring_buffer_record_on(struct ring_buffer *buffer)
 {
-	unsigned int rd;
-	unsigned int new_rd;
-
-	do {
-		rd = atomic_read(&buffer->record_disabled);
-		new_rd = rd & ~RB_BUFFER_OFF;
-	} while (atomic_cmpxchg(&buffer->record_disabled, rd, new_rd) != rd);
+	atomic_clear_mask(RB_BUFFER_OFF, &buffer->record_disabled);
 }
 EXPORT_SYMBOL_GPL(ring_buffer_record_on);
 
-- 
2.1.2.443.g670a3c1


             reply	other threads:[~2014-10-15 13:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 13:41 Patrick Palka [this message]
2014-10-15 19:08 ` Patrick Palka
2014-10-15 19:33   ` Patrick Palka

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=1413380500-3914-1-git-send-email-patrick@parcs.ath.cx \
    --to=patrick@parcs.ath.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.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

all inboxes | Powered by JetHome®