[rfc 3/3] perf, x86: P4 PMU -- export ABI part of event config to userspace

Cyrill Gorcunov
2010-11-23T22:48:38Z

[-- Attachment #1: x86-perf-export-abi --]
[-- Type: text/plain, Size: 2071 bytes --]

Due to tight 64 bit size of event config field (where we have to track
pretty lot of info during event lifetime) some bits are to be exported
via header into userspace.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Lin Ming <ming.m.lin@intel.com>
CC: Stephane Eranian <eranian@google.com>
CC: Peter Zijlstra <peterz@infradead.org>
---

Note that I don't like much the idea to export anything into userspace
but it seems there is no other choise. So there is a minimum which should
be exported.

arch/x86/include/asm/Kbuild | 1 +
arch/x86/include/asm/perf_event_p4.h | 8 ++++++++
2 files changed, 9 insertions(+)

Index: linux-2.6.git/arch/x86/include/asm/Kbuild
=====================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/Kbuild
+++ linux-2.6.git/arch/x86/include/asm/Kbuild
@@ -23,3 +23,4 @@ header-y += unistd_32.h
header-y += unistd_64.h
header-y += vm86.h
header-y += vsyscall.h
+header-y += perf_event_p4.h
Index: linux-2.6.git/arch/x86/include/asm/perf_event_p4.h
=====================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/perf_event_p4.h
+++ linux-2.6.git/arch/x86/include/asm/perf_event_p4.h
@@ -5,6 +5,8 @@
#ifndef PERF_EVENT_P4_H
#define PERF_EVENT_P4_H

+#ifdef __KERNEL__
+
#include <linux/cpu.h>
#include <linux/bitops.h>

@@ -201,6 +203,8 @@ static inline u32 p4_default_escr_conf(i
return escr;
}

+#endif /* __KERNEL__ */
+
/*
* This are the events which should be used in "Event Select"
* field of ESCR register, they are like unique keys which allow
@@ -256,6 +260,8 @@ enum P4_EVENTS {
P4_EVENT_INSTR_COMPLETED,
};

+#ifdef __KERNEL__
+
#define P4_OPCODE(event) event##_OPCODE
#define P4_OPCODE_ESEL(opcode) ((opcode & 0x00ff) >> 0)
#define P4_OPCODE_EVNT(opcode) ((opcode & 0xff00) >> 8)
@@ -767,6 +773,8 @@ enum P4_ESCR_EMASKS {

#define p4_config_pebs_has(v, mask) (p4_config_unpack_pebs(v) & (mask))

+#endif /* __KERNEL__ */
+
enum P4_PEBS_METRIC {
P4_PEBS_METRIC__none,