lkml.org 
[lkml]   [2011]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [perf] enable raw OFFCORE_EVENTS for non-perf userspace

and in case we don't want to be nice to userspace and want to brutally
suppress anyone not using the "perf" tool, here's a patch that
returns EINVAL for any raw access that sets config1.

I actually tested to make sure the patch doesn't break PAPI, unlike my
last attempt.

Currently we "block" access to setting the config1 value from userspace
by silently failing. This can cause unexpected behavior (especially if
the kernel is using the OFFCORE_RSP_0 msr internally) and also makes it
impossible to test if OFFCORE_RESPONSE events are being blocked or not.

This hackish patch causes an EINVAL to propogate back to userspace
by setting an invalid value to the config1 field.

I personally think this patch is a step backward, and the right thing to
do is give users full access to their own hardware. But the current state
of affairs is bad for tools like PAPI too.



diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 4ee3abf..72baf25 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -608,8 +608,11 @@ static int x86_setup_perfctr(struct perf_event *event)
* Do not allow config1 (extended registers) to propagate,
* there's no sane user-space generalization yet:
*/
- if (attr->type == PERF_TYPE_RAW)
- return 0;
+ if (attr->type == PERF_TYPE_RAW) {
+ /* I HATE THIS PATCH AND EVERYTHING IT STANDS FOR. -- VMW */
+ event->attr.config1=0xffffffff; /* invalid, will be caught */
+ return x86_pmu_extra_regs(event->attr.config, event);
+ }

if (attr->type == PERF_TYPE_HW_CACHE)
return set_ext_hw_attr(hwc, event);


\
 
 \ /
  Last update: 2011-08-03 19:03    [W:0.084 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site