Skip to content

Commit a7b58d2

Browse files
Andi KleenIngo Molnar
authored andcommitted
perf/x86/intel/lbr: Allow time stamp for free running PEBSv3
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 <ak@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: acme@kernel.org Cc: eranian@google.com Cc: jolsa@redhat.com Cc: kan.liang@intel.com Link: http://lkml.kernel.org/r/1432786398-23861-2-git-send-email-andi@firstfloor.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 2f7ebf2 commit a7b58d2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

arch/x86/kernel/cpu/perf_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ struct x86_pmu {
594594
struct event_constraint *pebs_constraints;
595595
void (*pebs_aliases)(struct perf_event *event);
596596
int max_pebs_events;
597+
unsigned long free_running_flags;
597598

598599
/*
599600
* Intel LBR

arch/x86/kernel/cpu/perf_event_intel.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,15 @@ static void intel_pebs_aliases_snb(struct perf_event *event)
22572257
}
22582258
}
22592259

2260+
static unsigned long intel_pmu_free_running_flags(struct perf_event *event)
2261+
{
2262+
unsigned long flags = x86_pmu.free_running_flags;
2263+
2264+
if (event->attr.use_clockid)
2265+
flags &= ~PERF_SAMPLE_TIME;
2266+
return flags;
2267+
}
2268+
22602269
static int intel_pmu_hw_config(struct perf_event *event)
22612270
{
22622271
int ret = x86_pmu_hw_config(event);
@@ -2267,7 +2276,8 @@ static int intel_pmu_hw_config(struct perf_event *event)
22672276
if (event->attr.precise_ip) {
22682277
if (!event->attr.freq) {
22692278
event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
2270-
if (!(event->attr.sample_type & ~PEBS_FREERUNNING_FLAGS))
2279+
if (!(event->attr.sample_type &
2280+
~intel_pmu_free_running_flags(event)))
22712281
event->hw.flags |= PERF_X86_EVENT_FREERUNNING;
22722282
}
22732283
if (x86_pmu.pebs_aliases)
@@ -2689,6 +2699,8 @@ static __initconst const struct x86_pmu core_pmu = {
26892699
.event_map = intel_pmu_event_map,
26902700
.max_events = ARRAY_SIZE(intel_perfmon_event_map),
26912701
.apic = 1,
2702+
.free_running_flags = PEBS_FREERUNNING_FLAGS,
2703+
26922704
/*
26932705
* Intel PMCs cannot be accessed sanely above 32-bit width,
26942706
* so we install an artificial 1<<31 period regardless of
@@ -2727,6 +2739,7 @@ static __initconst const struct x86_pmu intel_pmu = {
27272739
.event_map = intel_pmu_event_map,
27282740
.max_events = ARRAY_SIZE(intel_perfmon_event_map),
27292741
.apic = 1,
2742+
.free_running_flags = PEBS_FREERUNNING_FLAGS,
27302743
/*
27312744
* Intel PMCs cannot be accessed sanely above 32 bit width,
27322745
* so we install an artificial 1<<31 period regardless of

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ void __init intel_ds_init(void)
12731273
x86_pmu.pebs_record_size =
12741274
sizeof(struct pebs_record_skl);
12751275
x86_pmu.drain_pebs = intel_pmu_drain_pebs_nhm;
1276+
x86_pmu.free_running_flags |= PERF_SAMPLE_TIME;
12761277
break;
12771278

12781279
default:

0 commit comments

Comments
 (0)