Skip to content

Commit e72daf3

Browse files
Jiri OlsaIngo Molnar
authored andcommitted
perf/x86/intel: Use PAGE_SIZE for PEBS buffer size on Core2
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 <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Cc: <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 927a557 commit e72daf3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arch/x86/events/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;
@@ -1319,6 +1319,7 @@ void __init intel_ds_init(void)
13191319

13201320
x86_pmu.bts = boot_cpu_has(X86_FEATURE_BTS);
13211321
x86_pmu.pebs = boot_cpu_has(X86_FEATURE_PEBS);
1322+
x86_pmu.pebs_buffer_size = PEBS_BUFFER_SIZE;
13221323
if (x86_pmu.pebs) {
13231324
char pebs_type = x86_pmu.intel_cap.pebs_trap ? '+' : '-';
13241325
int format = x86_pmu.intel_cap.pebs_format;
@@ -1327,6 +1328,14 @@ void __init intel_ds_init(void)
13271328
case 0:
13281329
pr_cont("PEBS fmt0%c, ", pebs_type);
13291330
x86_pmu.pebs_record_size = sizeof(struct pebs_record_core);
1331+
/*
1332+
* Using >PAGE_SIZE buffers makes the WRMSR to
1333+
* PERF_GLOBAL_CTRL in intel_pmu_enable_all()
1334+
* mysteriously hang on Core2.
1335+
*
1336+
* As a workaround, we don't do this.
1337+
*/
1338+
x86_pmu.pebs_buffer_size = PAGE_SIZE;
13301339
x86_pmu.drain_pebs = intel_pmu_drain_pebs_core;
13311340
break;
13321341

arch/x86/events/perf_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ struct x86_pmu {
586586
pebs_broken :1,
587587
pebs_prec_dist :1;
588588
int pebs_record_size;
589+
int pebs_buffer_size;
589590
void (*drain_pebs)(struct pt_regs *regs);
590591
struct event_constraint *pebs_constraints;
591592
void (*pebs_aliases)(struct perf_event *event);

0 commit comments

Comments
 (0)