[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimo2CoYvcSyKB-s_iGVEpir5qh7SxL5oOGd7MXk@mail.gmail.com>
Date: Wed, 24 Nov 2010 14:46:34 +0300
From: Cyrill Gorcunov <gorcunov@...nvz.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...e.hu>, LKML <linux-kernel@...r.kernel.org>,
ming.m.lin@...el.com, eranian@...gle.com
Subject: Re: [rfc 3/3] perf, x86: P4 PMU -- export ABI part of event config to userspace
On Wed, Nov 24, 2010 at 12:39 PM, Cyrill Gorcunov <gorcunov@...nvz.org> wrote:
> On 11/24/10, Peter Zijlstra <peterz@...radead.org> wrote:
>> On Wed, 2010-11-24 at 11:48 +0300, Cyrill Gorcunov wrote:
>>> On 11/24/10, Peter Zijlstra <peterz@...radead.org> wrote:
>>> > On Wed, 2010-11-24 at 01:46 +0300, Cyrill Gorcunov wrote:
>>> >> plain text document attachment (x86-perf-export-abi)
>>> >> 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@...nvz.org>
>>> >> CC: Lin Ming <ming.m.lin@...el.com>
>>> >> CC: Stephane Eranian <eranian@...gle.com>
>>> >> CC: Peter Zijlstra <peterz@...radead.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.
>>> >
>>> >
>>> > Could you say what exactly is exposed to userspace and why?
>>>
>>> yes, we need two enums to be exported, because we use custom encoding,
>>> which is described in first patch. peter i'll describe more detailed
>>> in a couple of hours, ok?
>>
>> Sure, but have you seen my sysfs patches? wouldn't describing the format
>> in there suffice?
>>
>> http://lkml.org/lkml/2010/11/17/154
>>
>>
> just looked at them, but the main problem is that a few fields in
> .config consist of custom values about which userspace knows nothing,
> ie these fields are not described in SDM but we define own ones. this
> mess is because we need to pack a lot of info in single 64bit field so
> kernel would track event properly in terms of hardware resources. i
> will describe the details as only reach the computer.
>
Peter, would the following change log make more sense?
---
perf, x86: P4 PMU -- export ABI part of event config to userspace v2
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, so the caller (regardless if it's a kernel
side caller or call from userspace) should pass them to get event running.
In particular we have to export enums P4_PEBS_METRIC and P4_EVENTS.
The P4_PEBS_METRIC is used to inform the perf subsystem that an
event needs PEBs metric to be set (which tells the kernel to program
tow additional MSR for such event).
In turn P4_EVENTS is used as a primary key for tracking event's
hardware resource.
The proper places of these enums in config are described in comments
in header (the comments are exported as well).
Such a bit complex scheme grows from nature of P4 events, the kernel
has to track ESCR+CCCR+COUNTER+METRIC for every event and 64 bits solely
is not enough for that. Moreover, some events share ESCR "Event Select"
and CCCR "EventMask", so to make every event unique from kernel point
of veiew we define own keys to be used instead of ESCR "Event Select".
v2: Describe what we need to export in commit message
Signed-off-by: Cyrill Gorcunov <gorcunov@...nvz.org>
CC: Lin Ming <ming.m.lin@...el.com>
CC: Stephane Eranian <eranian@...gle.com>
CC: Peter Zijlstra <peterz@...radead.org>
---
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,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists