* [patch 0/4] perf,p4 series for -tip
@ 2010-05-08 11:25 Cyrill Gorcunov
2010-05-08 11:25 ` [patch 1/4] x86,perf: P4 PMU -- configurate predefined events Cyrill Gorcunov
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2010-05-08 11:25 UTC (permalink / raw)
To: mingo; +Cc: linux-kernel
Hi,
please review and test if possible. Any complains
are quite welcome! Thanks!
Cyrill
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 1/4] x86,perf: P4 PMU -- configurate predefined events
2010-05-08 11:25 [patch 0/4] perf,p4 series for -tip Cyrill Gorcunov
@ 2010-05-08 11:25 ` Cyrill Gorcunov
2010-05-08 11:33 ` Cyrill Gorcunov
2010-05-10 12:43 ` Robert Richter
2010-05-08 11:25 ` [patch 2/4] x86,perf: P4 PMU -- protect sensible procedures from preemption Cyrill Gorcunov
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2010-05-08 11:25 UTC (permalink / raw)
To: mingo
Cc: linux-kernel, Peter Zijlstra, Frederic Weisbecker, Lin Ming,
Robert Richter, Cyrill Gorcunov
[-- Attachment #1: x86-perf-p4-repir-raw --]
[-- Type: text/plain, Size: 2054 bytes --]
If an event is not RAW we should exit p4_hw_config
early but call x86_setup_perfctr as well.
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Lin Ming <ming.m.lin@intel.com>
CC: Robert Richter <robert.richter@amd.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
Robert, if only I'm not missing something this is
a side effect of commit 9d0fcba67e47ff398a6fa86476d4884d472dc98a,
wonders why don't we hit it earlier. Am I wrong?
arch/x86/kernel/cpu/perf_event_p4.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 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
@@ -439,21 +439,20 @@ static int p4_hw_config(struct perf_even
if (p4_ht_active() && p4_ht_thread(cpu))
event->hw.config = p4_set_ht_bit(event->hw.config);
- if (event->attr.type != PERF_TYPE_RAW)
- return 0;
-
- /*
- * We don't control raw events so it's up to the caller
- * to pass sane values (and we don't count the thread number
- * on HT machine but allow HT-compatible specifics to be
- * passed on)
- *
- * XXX: HT wide things should check perf_paranoid_cpu() &&
- * CAP_SYS_ADMIN
- */
- event->hw.config |= event->attr.config &
- (p4_config_pack_escr(P4_ESCR_MASK_HT) |
- p4_config_pack_cccr(P4_CCCR_MASK_HT));
+ if (event->attr.type == PERF_TYPE_RAW) {
+ /*
+ * We don't control raw events so it's up to the caller
+ * to pass sane values (and we don't count the thread number
+ * on HT machine but allow HT-compatible specifics to be
+ * passed on)
+ *
+ * XXX: HT wide things should check perf_paranoid_cpu() &&
+ * CAP_SYS_ADMIN
+ */
+ event->hw.config |= event->attr.config &
+ (p4_config_pack_escr(P4_ESCR_MASK_HT) |
+ p4_config_pack_cccr(P4_CCCR_MASK_HT));
+ }
return x86_setup_perfctr(event);
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 2/4] x86,perf: P4 PMU -- protect sensible procedures from preemption
2010-05-08 11:25 [patch 0/4] perf,p4 series for -tip Cyrill Gorcunov
2010-05-08 11:25 ` [patch 1/4] x86,perf: P4 PMU -- configurate predefined events Cyrill Gorcunov
@ 2010-05-08 11:25 ` Cyrill Gorcunov
2010-05-08 16:09 ` [tip:perf/core] x86, perf: " tip-bot for Cyrill Gorcunov
2010-05-08 11:25 ` [patch 3/4] x86,perf: P4 PMU -- Get rid of redundant check for array index Cyrill Gorcunov
2010-05-08 11:25 ` [patch 4/4] x86,perf: P4 PMU -- check for proper event index in RAW events Cyrill Gorcunov
3 siblings, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2010-05-08 11:25 UTC (permalink / raw)
To: mingo
Cc: linux-kernel, Steven Rostedt, Peter Zijlstra, Frederic Weisbecker,
Lin Ming, Cyrill Gorcunov
[-- Attachment #1: x86-perf-p4-getcpu --]
[-- Type: text/plain, Size: 2525 bytes --]
Steven reported
|
| I'm getting:
|
| Pid: 3477, comm: perf Not tainted 2.6.34-rc6 #2727
| Call Trace:
| [<ffffffff811c7565>] debug_smp_processor_id+0xd5/0xf0
| [<ffffffff81019874>] p4_hw_config+0x2b/0x15c
| [<ffffffff8107acbc>] ? trace_hardirqs_on_caller+0x12b/0x14f
| [<ffffffff81019143>] hw_perf_event_init+0x468/0x7be
| [<ffffffff810782fd>] ? debug_mutex_init+0x31/0x3c
| [<ffffffff810c68b2>] T.850+0x273/0x42e
| [<ffffffff810c6cab>] sys_perf_event_open+0x23e/0x3f1
| [<ffffffff81009e6a>] ? sysret_check+0x2e/0x69
| [<ffffffff81009e32>] system_call_fastpath+0x16/0x1b
|
| When running perf record in latest tip/perf/core
|
Due to the fact that p4 counters are shared between HT threads
we synthetically divide the whole set of counters into two
non-intersected subsets. And while we're "borrowing" counters
from these subsets we should not be preempted (well, strictly
speaking in p4_hw_config we just pre-set reference to the
subset which allow to save some cycles in schedule routine
if it happens on the same cpu). So use get_cpu/put_cpu pair.
Also p4_pmu_schedule_events should use smp_processor_id rather
than raw_ version. This allow us to catch up preemption issue
(if there will ever be).
Reported-by: Steven Rostedt <rostedt@goodmis.org>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
Note: I've removed Steven's Tested-by tag, since due to
commit 9d0fcba67e47ff398a6fa86476d4884d472dc98a the former
patch Steven were testing is not applicable anymore.
arch/x86/kernel/cpu/perf_event_p4.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 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
@@ -421,7 +421,8 @@ static u64 p4_pmu_event_map(int hw_event
static int p4_hw_config(struct perf_event *event)
{
- int cpu = raw_smp_processor_id();
+ int cpu = get_cpu();
+ int rc = 0;
u32 escr, cccr;
/*
@@ -454,7 +455,10 @@ static int p4_hw_config(struct perf_even
p4_config_pack_cccr(P4_CCCR_MASK_HT));
}
- return x86_setup_perfctr(event);
+ rc = x86_setup_perfctr(event);
+ put_cpu();
+
+ return rc;
}
static inline void p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 3/4] x86,perf: P4 PMU -- Get rid of redundant check for array index
2010-05-08 11:25 [patch 0/4] perf,p4 series for -tip Cyrill Gorcunov
2010-05-08 11:25 ` [patch 1/4] x86,perf: P4 PMU -- configurate predefined events Cyrill Gorcunov
2010-05-08 11:25 ` [patch 2/4] x86,perf: P4 PMU -- protect sensible procedures from preemption Cyrill Gorcunov
@ 2010-05-08 11:25 ` Cyrill Gorcunov
2010-05-08 16:10 ` [tip:perf/core] x86, perf: " tip-bot for Cyrill Gorcunov
2010-05-08 11:25 ` [patch 4/4] x86,perf: P4 PMU -- check for proper event index in RAW events Cyrill Gorcunov
3 siblings, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2010-05-08 11:25 UTC (permalink / raw)
To: mingo
Cc: linux-kernel, Peter Zijlstra, Frederic Weisbecker, Lin Ming,
Cyrill Gorcunov
[-- Attachment #1: x86-perf-p4-redundant-check --]
[-- Type: text/plain, Size: 984 bytes --]
The caller already has done such a check.
And it was wrong anyway, it had to be '>=' rather then '>'
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
arch/x86/kernel/cpu/perf_event_p4.c | 5 -----
1 file changed, 5 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
@@ -406,11 +406,6 @@ static u64 p4_pmu_event_map(int hw_event
unsigned int esel;
u64 config;
- if (hw_event > ARRAY_SIZE(p4_general_events)) {
- printk_once(KERN_ERR "P4 PMU: Bad index: %i\n", hw_event);
- return 0;
- }
-
config = p4_general_events[hw_event];
bind = p4_config_get_bind(config);
esel = P4_OPCODE_ESEL(bind->opcode);
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 4/4] x86,perf: P4 PMU -- check for proper event index in RAW events
2010-05-08 11:25 [patch 0/4] perf,p4 series for -tip Cyrill Gorcunov
` (2 preceding siblings ...)
2010-05-08 11:25 ` [patch 3/4] x86,perf: P4 PMU -- Get rid of redundant check for array index Cyrill Gorcunov
@ 2010-05-08 11:25 ` Cyrill Gorcunov
2010-05-08 16:10 ` [tip:perf/core] x86, perf: " tip-bot for Cyrill Gorcunov
3 siblings, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2010-05-08 11:25 UTC (permalink / raw)
To: mingo
Cc: linux-kernel, Peter Zijlstra, Frederic Weisbecker, Lin Ming,
Cyrill Gorcunov
[-- Attachment #1: x86-perf-p4-raw-index --]
[-- Type: text/plain, Size: 1416 bytes --]
RAW events are special and we should be ready for user passing
insane event index.
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
arch/x86/kernel/cpu/perf_event_p4.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
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
@@ -418,6 +418,7 @@ static int p4_hw_config(struct perf_even
{
int cpu = get_cpu();
int rc = 0;
+ unsigned int evnt;
u32 escr, cccr;
/*
@@ -436,6 +437,14 @@ static int p4_hw_config(struct perf_even
event->hw.config = p4_set_ht_bit(event->hw.config);
if (event->attr.type == PERF_TYPE_RAW) {
+
+ /* user data may have out-of-bound event index */
+ evnt = p4_config_unpack_event(event->attr.config);
+ if (evnt >= ARRAY_SIZE(p4_event_bind_map)) {
+ rc = -EINVAL;
+ goto out;
+ }
+
/*
* We don't control raw events so it's up to the caller
* to pass sane values (and we don't count the thread number
@@ -451,8 +460,8 @@ static int p4_hw_config(struct perf_even
}
rc = x86_setup_perfctr(event);
+out:
put_cpu();
-
return rc;
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 1/4] x86,perf: P4 PMU -- configurate predefined events
2010-05-08 11:25 ` [patch 1/4] x86,perf: P4 PMU -- configurate predefined events Cyrill Gorcunov
@ 2010-05-08 11:33 ` Cyrill Gorcunov
2010-05-10 12:43 ` Robert Richter
1 sibling, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2010-05-08 11:33 UTC (permalink / raw)
To: Cyrill Gorcunov
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org, Peter Zijlstra,
Frederic Weisbecker, Lin Ming, Robert Richter
On Saturday, May 8, 2010, Cyrill Gorcunov <gorcunov@openvz.org> wrote:
> If an event is not RAW we should exit p4_hw_config
> early but call x86_setup_perfctr as well.
>
Actually i meant "should not"
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Lin Ming <ming.m.lin@intel.com>
> CC: Robert Richter <robert.richter@amd.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>
> Robert, if only I'm not missing something this is
> a side effect of commit 9d0fcba67e47ff398a6fa86476d4884d472dc98a,
> wonders why don't we hit it earlier. Am I wrong?
>
> arch/x86/kernel/cpu/perf_event_p4.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 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
> @@ -439,21 +439,20 @@ static int p4_hw_config(struct perf_even
> if (p4_ht_active() && p4_ht_thread(cpu))
> event->hw.config = p4_set_ht_bit(event->hw.config);
>
> - if (event->attr.type != PERF_TYPE_RAW)
> - return 0;
> -
> - /*
> - * We don't control raw events so it's up to the caller
> - * to pass sane values (and we don't count the thread number
> - * on HT machine but allow HT-compatible specifics to be
> - * passed on)
> - *
> - * XXX: HT wide things should check perf_paranoid_cpu() &&
> - * CAP_SYS_ADMIN
> - */
> - event->hw.config |= event->attr.config &
> - (p4_config_pack_escr(P4_ESCR_MASK_HT) |
> - p4_config_pack_cccr(P4_CCCR_MASK_HT));
> + if (event->attr.type == PERF_TYPE_RAW) {
> + /*
> + * We don't control raw events so it's up to the caller
> + * to pass sane values (and we don't count the thread number
> + * on HT machine but allow HT-compatible specifics to be
> + * passed on)
> + *
> + * XXX: HT wide things should check perf_paranoid_cpu() &&
> + * CAP_SYS_ADMIN
> + */
> + event->hw.config |= event->attr.config &
> + (p4_config_pack_escr(P4_ESCR_MASK_HT) |
> + p4_config_pack_cccr(P4_CCCR_MASK_HT));
> + }
>
> return x86_setup_perfctr(event);
> }
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [tip:perf/core] x86, perf: P4 PMU -- protect sensible procedures from preemption
2010-05-08 11:25 ` [patch 2/4] x86,perf: P4 PMU -- protect sensible procedures from preemption Cyrill Gorcunov
@ 2010-05-08 16:09 ` tip-bot for Cyrill Gorcunov
0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Cyrill Gorcunov @ 2010-05-08 16:09 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, gorcunov, peterz, fweisbec, rostedt,
ming.m.lin, tglx, mingo
Commit-ID: 137351e0feeb9f25d99488ee1afc1c79f5499a9a
Gitweb: http://git.kernel.org/tip/137351e0feeb9f25d99488ee1afc1c79f5499a9a
Author: Cyrill Gorcunov <gorcunov@openvz.org>
AuthorDate: Sat, 8 May 2010 15:25:52 +0400
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sat, 8 May 2010 14:17:53 +0200
x86, perf: P4 PMU -- protect sensible procedures from preemption
Steven reported:
|
| I'm getting:
|
| Pid: 3477, comm: perf Not tainted 2.6.34-rc6 #2727
| Call Trace:
| [<ffffffff811c7565>] debug_smp_processor_id+0xd5/0xf0
| [<ffffffff81019874>] p4_hw_config+0x2b/0x15c
| [<ffffffff8107acbc>] ? trace_hardirqs_on_caller+0x12b/0x14f
| [<ffffffff81019143>] hw_perf_event_init+0x468/0x7be
| [<ffffffff810782fd>] ? debug_mutex_init+0x31/0x3c
| [<ffffffff810c68b2>] T.850+0x273/0x42e
| [<ffffffff810c6cab>] sys_perf_event_open+0x23e/0x3f1
| [<ffffffff81009e6a>] ? sysret_check+0x2e/0x69
| [<ffffffff81009e32>] system_call_fastpath+0x16/0x1b
|
| When running perf record in latest tip/perf/core
|
Due to the fact that p4 counters are shared between HT threads
we synthetically divide the whole set of counters into two
non-intersected subsets. And while we're "borrowing" counters
from these subsets we should not be preempted (well, strictly
speaking in p4_hw_config we just pre-set reference to the
subset which allow to save some cycles in schedule routine
if it happens on the same cpu). So use get_cpu/put_cpu pair.
Also p4_pmu_schedule_events should use smp_processor_id rather
than raw_ version. This allow us to catch up preemption issue
(if there will ever be).
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>
LKML-Reference: <20100508112716.963478928@openvz.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/cpu/perf_event_p4.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index b1f532d..ca40180 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -421,7 +421,8 @@ static u64 p4_pmu_event_map(int hw_event)
static int p4_hw_config(struct perf_event *event)
{
- int cpu = raw_smp_processor_id();
+ int cpu = get_cpu();
+ int rc = 0;
u32 escr, cccr;
/*
@@ -454,7 +455,10 @@ static int p4_hw_config(struct perf_event *event)
p4_config_pack_cccr(P4_CCCR_MASK_HT));
}
- return x86_setup_perfctr(event);
+ rc = x86_setup_perfctr(event);
+ put_cpu();
+
+ return rc;
}
static inline void p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [tip:perf/core] x86, perf: P4 PMU -- Get rid of redundant check for array index
2010-05-08 11:25 ` [patch 3/4] x86,perf: P4 PMU -- Get rid of redundant check for array index Cyrill Gorcunov
@ 2010-05-08 16:10 ` tip-bot for Cyrill Gorcunov
0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Cyrill Gorcunov @ 2010-05-08 16:10 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, gorcunov, peterz, fweisbec, ming.m.lin,
tglx, mingo
Commit-ID: 3f51b7119d052827dbb0e40c966acdf2bdc6f47f
Gitweb: http://git.kernel.org/tip/3f51b7119d052827dbb0e40c966acdf2bdc6f47f
Author: Cyrill Gorcunov <gorcunov@openvz.org>
AuthorDate: Sat, 8 May 2010 15:25:53 +0400
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sat, 8 May 2010 14:17:53 +0200
x86, perf: P4 PMU -- Get rid of redundant check for array index
The caller already has done such a check.
And it was wrong anyway, it had to be '>=' rather than '>'
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>
LKML-Reference: <20100508112717.130386882@openvz.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/cpu/perf_event_p4.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index ca40180..b8c2d37 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -406,11 +406,6 @@ static u64 p4_pmu_event_map(int hw_event)
unsigned int esel;
u64 config;
- if (hw_event > ARRAY_SIZE(p4_general_events)) {
- printk_once(KERN_ERR "P4 PMU: Bad index: %i\n", hw_event);
- return 0;
- }
-
config = p4_general_events[hw_event];
bind = p4_config_get_bind(config);
esel = P4_OPCODE_ESEL(bind->opcode);
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [tip:perf/core] x86, perf: P4 PMU -- check for proper event index in RAW events
2010-05-08 11:25 ` [patch 4/4] x86,perf: P4 PMU -- check for proper event index in RAW events Cyrill Gorcunov
@ 2010-05-08 16:10 ` tip-bot for Cyrill Gorcunov
0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Cyrill Gorcunov @ 2010-05-08 16:10 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, gorcunov, peterz, fweisbec, ming.m.lin,
tglx, mingo
Commit-ID: c7993165ef0c1d636ca05f4787739f8414584e6d
Gitweb: http://git.kernel.org/tip/c7993165ef0c1d636ca05f4787739f8414584e6d
Author: Cyrill Gorcunov <gorcunov@openvz.org>
AuthorDate: Sat, 8 May 2010 15:25:54 +0400
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sat, 8 May 2010 14:17:53 +0200
x86, perf: P4 PMU -- check for proper event index in RAW events
RAW events are special and we should be ready for user passing
in insane event index values.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>
LKML-Reference: <20100508112717.315897547@openvz.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/cpu/perf_event_p4.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index b8c2d37..a603930 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -418,6 +418,7 @@ static int p4_hw_config(struct perf_event *event)
{
int cpu = get_cpu();
int rc = 0;
+ unsigned int evnt;
u32 escr, cccr;
/*
@@ -436,6 +437,14 @@ static int p4_hw_config(struct perf_event *event)
event->hw.config = p4_set_ht_bit(event->hw.config);
if (event->attr.type == PERF_TYPE_RAW) {
+
+ /* user data may have out-of-bound event index */
+ evnt = p4_config_unpack_event(event->attr.config);
+ if (evnt >= ARRAY_SIZE(p4_event_bind_map)) {
+ rc = -EINVAL;
+ goto out;
+ }
+
/*
* We don't control raw events so it's up to the caller
* to pass sane values (and we don't count the thread number
@@ -451,8 +460,8 @@ static int p4_hw_config(struct perf_event *event)
}
rc = x86_setup_perfctr(event);
+out:
put_cpu();
-
return rc;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [patch 1/4] x86,perf: P4 PMU -- configurate predefined events
2010-05-08 11:25 ` [patch 1/4] x86,perf: P4 PMU -- configurate predefined events Cyrill Gorcunov
2010-05-08 11:33 ` Cyrill Gorcunov
@ 2010-05-10 12:43 ` Robert Richter
1 sibling, 0 replies; 10+ messages in thread
From: Robert Richter @ 2010-05-10 12:43 UTC (permalink / raw)
To: Cyrill Gorcunov
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org, Peter Zijlstra,
Frederic Weisbecker, Lin Ming
On 08.05.10 07:25:51, Cyrill Gorcunov wrote:
> If an event is not RAW we should exit p4_hw_config
> early but call x86_setup_perfctr as well.
>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Lin Ming <ming.m.lin@intel.com>
> CC: Robert Richter <robert.richter@amd.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>
> Robert, if only I'm not missing something this is
> a side effect of commit 9d0fcba67e47ff398a6fa86476d4884d472dc98a,
> wonders why don't we hit it earlier. Am I wrong?
Yes, that's true, the function had have two exit points. Thanks for
the fix.
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-05-10 12:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-08 11:25 [patch 0/4] perf,p4 series for -tip Cyrill Gorcunov
2010-05-08 11:25 ` [patch 1/4] x86,perf: P4 PMU -- configurate predefined events Cyrill Gorcunov
2010-05-08 11:33 ` Cyrill Gorcunov
2010-05-10 12:43 ` Robert Richter
2010-05-08 11:25 ` [patch 2/4] x86,perf: P4 PMU -- protect sensible procedures from preemption Cyrill Gorcunov
2010-05-08 16:09 ` [tip:perf/core] x86, perf: " tip-bot for Cyrill Gorcunov
2010-05-08 11:25 ` [patch 3/4] x86,perf: P4 PMU -- Get rid of redundant check for array index Cyrill Gorcunov
2010-05-08 16:10 ` [tip:perf/core] x86, perf: " tip-bot for Cyrill Gorcunov
2010-05-08 11:25 ` [patch 4/4] x86,perf: P4 PMU -- check for proper event index in RAW events Cyrill Gorcunov
2010-05-08 16:10 ` [tip:perf/core] x86, perf: " tip-bot for Cyrill Gorcunov
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.