x86, perf: Allow time stamp for free running PEBSv3
Subsystems (2)
PATCH 1/1 x86, perf: Allow time stamp for free running PEBSv3
From: Andi Kleen <[email protected]>
With PEBSv3 the PEBS record contains a time stamp. That means we can allow free-running PEBS without a PMI even if the user program requested a time stamp. This avoids the need to use -T to get free running PEBS, and also avoids any problems with mis-identifying MMAPs later.
Move the free_running_flags state into a variable in x86_pmu and use it. This only works when no explicit clock_id is set.
Signed-off-by Andi Kleen <[email protected]>
--- arch/x86/kernel/cpu/perf_event.h | 1 + arch/x86/kernel/cpu/perf_event_intel.c | 15 ++++++++++++++- arch/x86/kernel/cpu/perf_event_intel_ds.c | 1 + 3 files changed, 16 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event.h +1 -0
@@ -589,6 +589,7 @@ struct x86_pmu {struct event_constraint *pebs_constraints;void (*pebs_aliases)(struct perf_event *event);int max_pebs_events; +unsigned long free_running_flags;/* * Intel LBR
arch/x86/kernel/cpu/perf_event_intel.c +14 -1
@@ -2507,6 +2507,15 @@ static void intel_pebs_aliases_snb(struct perf_event *event) } } +static unsigned long intel_pmu_free_running_flags (struct perf_event *event) +{ +unsigned long flags = x86_pmu.free_running_flags; + +if (event->attr.clockid) + flags &= ~PERF_SAMPLE_TIME ; +return flags; +} +static int intel_pmu_hw_config (struct perf_event *event) {int ret =x86_pmu_hw_config (event);
@@ -2517,7 +2526,8 @@ static int intel_pmu_hw_config(struct perf_event *event)if (event->attr.precise_ip) {if (!event->attr.freq) { event->hw.flags |=PERF_X86_EVENT_AUTO_RELOAD ; -if (!(event->attr.sample_type & ~PEBS_FREERUNNING_FLAGS )) +if (!(event->attr.sample_type & + ~intel_pmu_free_running_flags (event))) event->hw.flags |=PERF_X86_EVENT_FREERUNNING ; }if (x86_pmu.pebs_aliases)
@@ -2954,6 +2964,8 @@ static __initconst const struct x86_pmu core_pmu = { .event_map = intel_pmu_event_map, .max_events = ARRAY_SIZE(intel_perfmon_event_map), .apic = 1, + .free_running_flags = PEBS_FREERUNNING_FLAGS, +/* * Intel PMCs cannot be accessed sanely above 32-bit width, * so we install an artificial 1<<31 period regardless of
@@ -2992,6 +3004,7 @@ static __initconst const struct x86_pmu intel_pmu = { .event_map = intel_pmu_event_map, .max_events = ARRAY_SIZE(intel_perfmon_event_map), .apic = 1, + .free_running_flags = PEBS_FREERUNNING_FLAGS,/* * Intel PMCs cannot be accessed sanely above 32 bit width, * so we install an artificial 1<<31 period regardless of
arch/x86/kernel/cpu/perf_event_intel_ds.c +1 -0
@@ -1295,6 +1295,7 @@ void __init intel_ds_init(void) x86_pmu.pebs_record_size =sizeof (struct pebs_record_skl ); x86_pmu.drain_pebs = intel_pmu_drain_pebs_nhm; + x86_pmu.free_running_flags |=PERF_SAMPLE_TIME ;break ;default :
Signature · 1 line
1.9.3
Peter Zijlstra
maintainerarch/x86/kernel/cpu/perf_event_intel.c static void intel_pebs_aliases_snb(struct perf_event *event) · line 2514
Quoted 5 lines · Andi Kleen
arch/x86/kernel/cpu/perf_event_intel.c +5
-0+static unsigned long intel_pmu_free_running_flags (struct perf_event *event) +{ +unsigned long flags = x86_pmu.free_running_flags; + +if (event->attr.clockid)
Made that: use_clockid, otherwise CLOCK_REALTIME would still allow this (if it were allowed with hardware events).
Quoted 3 lines
arch/x86/kernel/cpu/perf_event_intel.c +3
-0+ flags &= ~PERF_SAMPLE_TIME ; +return flags; +}