Skip to content

Commit a54af12

Browse files
Jiri Olsagregkh
authored andcommitted
perf/x86/intel: Use PAGE_SIZE for PEBS buffer size on Core2
commit e72daf3f4d764c47fb71c9bdc7f9c54a503825b1 upstream. Using PAGE_SIZE buffers makes the WRMSR to PERF_GLOBAL_CTRL in intel_pmu_enable_all() mysteriously hang on Core2. As a workaround, we don't do this. The hard lockup is easily triggered by running 'perf test attr' repeatedly. Most of the time it gets stuck on sample session with small periods. # perf test attr -vv 14: struct perf_event_attr setup : --- start --- ... 'PERF_TEST_ATTR=/tmp/tmpuEKz3B /usr/bin/perf record -o /tmp/tmpuEKz3B/perf.data -c 123 kill >/dev/null 2>&1' ret 1 Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Andi Kleen <ak@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20160301190352.GA8355@krava.redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 886629e commit a54af12

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

arch/x86/kernel/cpu/perf_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ struct x86_pmu {
591591
pebs_active :1,
592592
pebs_broken :1;
593593
int pebs_record_size;
594+
int pebs_buffer_size;
594595
void (*drain_pebs)(struct pt_regs *regs);
595596
struct event_constraint *pebs_constraints;
596597
void (*pebs_aliases)(struct perf_event *event);

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static int alloc_pebs_buffer(int cpu)
269269
if (!x86_pmu.pebs)
270270
return 0;
271271

272-
buffer = kzalloc_node(PEBS_BUFFER_SIZE, GFP_KERNEL, node);
272+
buffer = kzalloc_node(x86_pmu.pebs_buffer_size, GFP_KERNEL, node);
273273
if (unlikely(!buffer))
274274
return -ENOMEM;
275275

@@ -286,7 +286,7 @@ static int alloc_pebs_buffer(int cpu)
286286
per_cpu(insn_buffer, cpu) = ibuffer;
287287
}
288288

289-
max = PEBS_BUFFER_SIZE / x86_pmu.pebs_record_size;
289+
max = x86_pmu.pebs_buffer_size / x86_pmu.pebs_record_size;
290290

291291
ds->pebs_buffer_base = (u64)(unsigned long)buffer;
292292
ds->pebs_index = ds->pebs_buffer_base;
@@ -1296,6 +1296,7 @@ void __init intel_ds_init(void)
12961296

12971297
x86_pmu.bts = boot_cpu_has(X86_FEATURE_BTS);
12981298
x86_pmu.pebs = boot_cpu_has(X86_FEATURE_PEBS);
1299+
x86_pmu.pebs_buffer_size = PEBS_BUFFER_SIZE;
12991300
if (x86_pmu.pebs) {
13001301
char pebs_type = x86_pmu.intel_cap.pebs_trap ? '+' : '-';
13011302
int format = x86_pmu.intel_cap.pebs_format;
@@ -1304,6 +1305,14 @@ void __init intel_ds_init(void)
13041305
case 0:
13051306
printk(KERN_CONT "PEBS fmt0%c, ", pebs_type);
13061307
x86_pmu.pebs_record_size = sizeof(struct pebs_record_core);
1308+
/*
1309+
* Using >PAGE_SIZE buffers makes the WRMSR to
1310+
* PERF_GLOBAL_CTRL in intel_pmu_enable_all()
1311+
* mysteriously hang on Core2.
1312+
*
1313+
* As a workaround, we don't do this.
1314+
*/
1315+
x86_pmu.pebs_buffer_size = PAGE_SIZE;
13071316
x86_pmu.drain_pebs = intel_pmu_drain_pebs_core;
13081317
break;
13091318

0 commit comments

Comments
 (0)