All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Robert Richter <robert.richter@amd.com>
Subject: [PATCH 2/4] perf, x86: Fix cmpxchg() usage in amd_put_event_constraints()
Date: Thu, 5 Apr 2012 18:24:42 +0200	[thread overview]
Message-ID: <1333643084-26776-3-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1333643084-26776-1-git-send-email-robert.richter@amd.com>

Now the return value of cmpxchg() is used to match an event. The
change removes the duplicate event comparison and traverses the list
until an event was removed. This also fixes the following warning:

 arch/x86/kernel/cpu/perf_event_amd.c:170: warning: value computed is not used

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/kernel/cpu/perf_event_amd.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index 4be3463..6565226 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -210,10 +210,8 @@ static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
 	 * when we come here
 	 */
 	for (i = 0; i < x86_pmu.num_counters; i++) {
-		if (nb->owners[i] == event) {
-			cmpxchg(nb->owners+i, event, NULL);
+		if (cmpxchg(nb->owners + i, event, NULL) == event)
 			break;
-		}
 	}
 }
 
-- 
1.7.8.4



  parent reply	other threads:[~2012-04-05 16:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05 16:24 [PATCH 0/4] perf: Kernel updates Robert Richter
2012-04-05 16:24 ` [PATCH 1/4] perf: Trivial cleanup of duplicate code Robert Richter
2012-04-26 12:17   ` [tip:perf/core] " tip-bot for Robert Richter
2012-04-05 16:24 ` Robert Richter [this message]
2012-04-26 12:18   ` [tip:perf/core] perf/x86: Fix cmpxchg() usage in amd_put_event_constraints() tip-bot for Robert Richter
2012-04-05 16:24 ` [PATCH 3/4] perf: use static variant of perf_event_overflow in core.c Robert Richter
2012-04-26 12:18   ` [tip:perf/core] perf: Use " tip-bot for Robert Richter
2012-04-05 16:24 ` [PATCH 4/4] perf: Remove PERF_COUNTERS config option Robert Richter
2012-04-26 12:19   ` [tip:perf/core] " tip-bot for Robert Richter
2012-04-24 16:37 ` [PATCH 0/4] perf: Kernel updates Robert Richter
2012-04-24 16:38   ` Peter Zijlstra

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=1333643084-26776-3-git-send-email-robert.richter@amd.com \
    --to=robert.richter@amd.com \
    --cc=acme@redhat.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.