All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Lin Ming" <ming.m.lin@intel.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Frédéric Weisbecker" <fweisbec@gmail.com>,
	"Cyrill Gorcunov" <gorcunov@openvz.org>,
	"Peter Zijlstra" <a.p.zijlstra@chello.nl>
Subject: [patch 1/4] x86,perf: P4 PMU -- do a real check for ESCR address being in hash
Date: Wed, 19 May 2010 01:19:17 +0400	[thread overview]
Message-ID: <20100518212439.004503600@openvz.org> (raw)
In-Reply-To: 20100518211916.407689068@openvz.org

[-- Attachment #1: x86-perf-p4-escr-check-hash --]
[-- Type: text/plain, Size: 1497 bytes --]

To prevent from clashes in future code modifications do a real
check for ESCR address being in hash. At moment the callers
are known to pass sane values but better to be on a safe side.

And comment fix.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Lin Ming <ming.m.lin@intel.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
CC: Ingo Molnar <mingo@elte.hu>
CC: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/x86/kernel/cpu/perf_event_p4.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/cpu/perf_event_p4.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/cpu/perf_event_p4.c
+++ linux-2.6.git/arch/x86/kernel/cpu/perf_event_p4.c
@@ -670,7 +670,7 @@ static void p4_pmu_swap_config_ts(struct
 
 /*
  * ESCR address hashing is tricky, ESCRs are not sequential
- * in memory but all starts from MSR_P4_BSU_ESCR0 (0x03e0) and
+ * in memory but all starts from MSR_P4_BSU_ESCR0 (0x03a0) and
  * the metric between any ESCRs is laid in range [0xa0,0xe1]
  *
  * so we make ~70% filled hashtable
@@ -735,8 +735,9 @@ static int p4_get_escr_idx(unsigned int 
 {
 	unsigned int idx = P4_ESCR_MSR_IDX(addr);
 
-	if (unlikely(idx >= P4_ESCR_MSR_TABLE_SIZE ||
-			!p4_escr_table[idx])) {
+	if (unlikely(idx >= P4_ESCR_MSR_TABLE_SIZE	||
+			!p4_escr_table[idx]		||
+			p4_escr_table[idx] != addr)) {
 		WARN_ONCE(1, "P4 PMU: Wrong address passed: %x\n", addr);
 		return -1;
 	}


  reply	other threads:[~2010-05-18 21:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-18 21:19 [patch 0/4] [perf -tip/master] p4 pmu updates Cyrill Gorcunov
2010-05-18 21:19 ` Cyrill Gorcunov [this message]
2010-05-19  7:57   ` [tip:perf/core] perf, x86: P4 PMU -- do a real check for ESCR address being in hash tip-bot for Cyrill Gorcunov
2010-05-18 21:19 ` [patch 2/4] x86,perf: p4_pmu_schedule_events -- use smp_processor_id instead of raw_ Cyrill Gorcunov
2010-05-19  7:57   ` [tip:perf/core] perf, x86: P4_pmu_schedule_events " tip-bot for Cyrill Gorcunov
2010-05-18 21:19 ` [patch 3/4] x86,perf: P4 PMU -- add missing bit in CCCR mask Cyrill Gorcunov
2010-05-19  7:57   ` [tip:perf/core] perf, x86: " tip-bot for Cyrill Gorcunov
2010-05-18 21:19 ` [patch 4/4] x86,perf: P4 PMU -- prepare header for user-space inclusion Cyrill Gorcunov
2010-05-19  7:35   ` Ingo Molnar
2010-05-19  7:41     ` Cyrill Gorcunov

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=20100518212439.004503600@openvz.org \
    --to=gorcunov@openvz.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    --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.