Skip to content

Commit 2a853e1

Browse files
kliang2Ingo Molnar
authored andcommitted
perf/x86/intel/pebs: Fix event disable PEBS buffer drain
When disabling a PEBS event, we need to drain the buffer. Doing so requires a correct cpuc->pebs_active mask. The current code clears the pebs_active bit before draining the buffer. Fix that. Signed-off-by: "Liang, Kan" <kan.liang@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: Vince Weaver<vincent.weaver@maine.edu> Link: http://lkml.kernel.org/r/37D7C6CF3E00A74B8858931C1DB2F07701885A65@SHSMSX103.ccr.corp.intel.com [ Fixed the SOB. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent b7b7c78 commit 2a853e1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,11 @@ void intel_pmu_pebs_disable(struct perf_event *event)
789789
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
790790
struct hw_perf_event *hwc = &event->hw;
791791
struct debug_store *ds = cpuc->ds;
792+
bool large_pebs = ds->pebs_interrupt_threshold >
793+
ds->pebs_buffer_base + x86_pmu.pebs_record_size;
794+
795+
if (large_pebs)
796+
intel_pmu_drain_pebs_buffer();
792797

793798
cpuc->pebs_enabled &= ~(1ULL << hwc->idx);
794799

@@ -797,12 +802,8 @@ void intel_pmu_pebs_disable(struct perf_event *event)
797802
else if (event->hw.flags & PERF_X86_EVENT_PEBS_ST)
798803
cpuc->pebs_enabled &= ~(1ULL << 63);
799804

800-
if (ds->pebs_interrupt_threshold >
801-
ds->pebs_buffer_base + x86_pmu.pebs_record_size) {
802-
intel_pmu_drain_pebs_buffer();
803-
if (!pebs_is_enabled(cpuc))
804-
perf_sched_cb_dec(event->ctx->pmu);
805-
}
805+
if (large_pebs && !pebs_is_enabled(cpuc))
806+
perf_sched_cb_dec(event->ctx->pmu);
806807

807808
if (cpuc->enabled)
808809
wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);

0 commit comments

Comments
 (0)