Skip to content

Commit 4277616

Browse files
committed
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (28 commits) perf session: Fix infinite loop in __perf_session__process_events perf evsel: Support perf_evsel__open(cpus > 1 && threads > 1) perf sched: Use PTHREAD_STACK_MIN to avoid pthread_attr_setstacksize() fail perf tools: Emit clearer message for sys_perf_event_open ENOENT return perf stat: better error message for unsupported events perf sched: Fix allocation result check perf, x86: P4 PMU - Fix unflagged overflows handling dynamic debug: Fix build issue with older gcc tracing: Fix TRACE_EVENT power tracepoint creation tracing: Fix preempt count leak tracepoint: Add __rcu annotation tracing: remove duplicate null-pointer check in skb tracepoint tracing/trivial: Add missing comma in TRACE_EVENT comment tracing: Include module.h in define_trace.h x86: Save rbp in pt_regs on irq entry x86, dumpstack: Fix unused variable warning x86, NMI: Clean-up default_do_nmi() x86, NMI: Allow NMI reason io port (0x61) to be processed on any CPU x86, NMI: Remove DIE_NMI_IPI x86, NMI: Add priorities to handlers ...
2 parents edb2877 + 3d03e2e commit 4277616

38 files changed

Lines changed: 442 additions & 248 deletions

‎arch/x86/include/asm/kdebug.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ enum die_val {
1818
DIE_TRAP,
1919
DIE_GPF,
2020
DIE_CALL,
21-
DIE_NMI_IPI,
2221
DIE_PAGE_FAULT,
2322
DIE_NMIUNKNOWN,
2423
};

‎arch/x86/include/asm/mach_traps.h‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@
77

88
#include <asm/mc146818rtc.h>
99

10+
#define NMI_REASON_PORT 0x61
11+
12+
#define NMI_REASON_SERR 0x80
13+
#define NMI_REASON_IOCHK 0x40
14+
#define NMI_REASON_MASK (NMI_REASON_SERR | NMI_REASON_IOCHK)
15+
16+
#define NMI_REASON_CLEAR_SERR 0x04
17+
#define NMI_REASON_CLEAR_IOCHK 0x08
18+
#define NMI_REASON_CLEAR_MASK 0x0f
19+
1020
static inline unsigned char get_nmi_reason(void)
1121
{
12-
return inb(0x61);
22+
return inb(NMI_REASON_PORT);
1323
}
1424

1525
static inline void reassert_nmi(void)

‎arch/x86/include/asm/nmi.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ void arch_trigger_all_cpu_backtrace(void);
2323
#define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace
2424
#endif
2525

26+
/*
27+
* Define some priorities for the nmi notifier call chain.
28+
*
29+
* Create a local nmi bit that has a higher priority than
30+
* external nmis, because the local ones are more frequent.
31+
*
32+
* Also setup some default high/normal/low settings for
33+
* subsystems to registers with. Using 4 bits to seperate
34+
* the priorities. This can go alot higher if needed be.
35+
*/
36+
37+
#define NMI_LOCAL_SHIFT 16 /* randomly picked */
38+
#define NMI_LOCAL_BIT (1ULL << NMI_LOCAL_SHIFT)
39+
#define NMI_HIGH_PRIOR (1ULL << 8)
40+
#define NMI_NORMAL_PRIOR (1ULL << 4)
41+
#define NMI_LOW_PRIOR (1ULL << 0)
42+
#define NMI_LOCAL_HIGH_PRIOR (NMI_LOCAL_BIT | NMI_HIGH_PRIOR)
43+
#define NMI_LOCAL_NORMAL_PRIOR (NMI_LOCAL_BIT | NMI_NORMAL_PRIOR)
44+
#define NMI_LOCAL_LOW_PRIOR (NMI_LOCAL_BIT | NMI_LOW_PRIOR)
45+
2646
void stop_nmi(void);
2747
void restart_nmi(void);
2848

‎arch/x86/include/asm/perf_event_p4.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#define ARCH_P4_MAX_ESCR (ARCH_P4_TOTAL_ESCR - ARCH_P4_RESERVED_ESCR)
2121
#define ARCH_P4_MAX_CCCR (18)
2222

23+
#define ARCH_P4_CNTRVAL_BITS (40)
24+
#define ARCH_P4_CNTRVAL_MASK ((1ULL << ARCH_P4_CNTRVAL_BITS) - 1)
25+
2326
#define P4_ESCR_EVENT_MASK 0x7e000000U
2427
#define P4_ESCR_EVENT_SHIFT 25
2528
#define P4_ESCR_EVENTMASK_MASK 0x01fffe00U

‎arch/x86/kernel/apic/hw_nmi.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ arch_trigger_all_cpu_backtrace_handler(struct notifier_block *self,
6868

6969
switch (cmd) {
7070
case DIE_NMI:
71-
case DIE_NMI_IPI:
7271
break;
7372

7473
default:
@@ -96,7 +95,7 @@ arch_trigger_all_cpu_backtrace_handler(struct notifier_block *self,
9695
static __read_mostly struct notifier_block backtrace_notifier = {
9796
.notifier_call = arch_trigger_all_cpu_backtrace_handler,
9897
.next = NULL,
99-
.priority = 1
98+
.priority = NMI_LOCAL_LOW_PRIOR,
10099
};
101100

102101
static int __init register_trigger_all_cpu_backtrace(void)

‎arch/x86/kernel/apic/x2apic_uv_x.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ void __cpuinit uv_cpu_init(void)
641641
*/
642642
int uv_handle_nmi(struct notifier_block *self, unsigned long reason, void *data)
643643
{
644-
if (reason != DIE_NMI_IPI)
644+
if (reason != DIE_NMIUNKNOWN)
645645
return NOTIFY_OK;
646646

647647
if (in_crash_kexec)

‎arch/x86/kernel/cpu/mcheck/mce-inject.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/gfp.h>
2626
#include <asm/mce.h>
2727
#include <asm/apic.h>
28+
#include <asm/nmi.h>
2829

2930
/* Update fake mce registers on current CPU. */
3031
static void inject_mce(struct mce *m)
@@ -83,7 +84,7 @@ static int mce_raise_notify(struct notifier_block *self,
8384
struct die_args *args = (struct die_args *)data;
8485
int cpu = smp_processor_id();
8586
struct mce *m = &__get_cpu_var(injectm);
86-
if (val != DIE_NMI_IPI || !cpumask_test_cpu(cpu, mce_inject_cpumask))
87+
if (val != DIE_NMI || !cpumask_test_cpu(cpu, mce_inject_cpumask))
8788
return NOTIFY_DONE;
8889
cpumask_clear_cpu(cpu, mce_inject_cpumask);
8990
if (m->inject_flags & MCJ_EXCEPTION)
@@ -95,7 +96,7 @@ static int mce_raise_notify(struct notifier_block *self,
9596

9697
static struct notifier_block mce_raise_nb = {
9798
.notifier_call = mce_raise_notify,
98-
.priority = 1000,
99+
.priority = NMI_LOCAL_NORMAL_PRIOR,
99100
};
100101

101102
/* Inject mce on current CPU */

‎arch/x86/kernel/cpu/perf_event.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,6 @@ perf_event_nmi_handler(struct notifier_block *self,
12671267

12681268
switch (cmd) {
12691269
case DIE_NMI:
1270-
case DIE_NMI_IPI:
12711270
break;
12721271
case DIE_NMIUNKNOWN:
12731272
this_nmi = percpu_read(irq_stat.__nmi_count);
@@ -1317,7 +1316,7 @@ perf_event_nmi_handler(struct notifier_block *self,
13171316
static __read_mostly struct notifier_block perf_event_nmi_notifier = {
13181317
.notifier_call = perf_event_nmi_handler,
13191318
.next = NULL,
1320-
.priority = 1
1319+
.priority = NMI_LOCAL_LOW_PRIOR,
13211320
};
13221321

13231322
static struct event_constraint unconstrained;

‎arch/x86/kernel/cpu/perf_event_p4.c‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -753,19 +753,21 @@ static int p4_hw_config(struct perf_event *event)
753753

754754
static inline int p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc)
755755
{
756-
int overflow = 0;
757-
u32 low, high;
756+
u64 v;
758757

759-
rdmsr(hwc->config_base + hwc->idx, low, high);
760-
761-
/* we need to check high bit for unflagged overflows */
762-
if ((low & P4_CCCR_OVF) || !(high & (1 << 31))) {
763-
overflow = 1;
764-
(void)checking_wrmsrl(hwc->config_base + hwc->idx,
765-
((u64)low) & ~P4_CCCR_OVF);
758+
/* an official way for overflow indication */
759+
rdmsrl(hwc->config_base + hwc->idx, v);
760+
if (v & P4_CCCR_OVF) {
761+
wrmsrl(hwc->config_base + hwc->idx, v & ~P4_CCCR_OVF);
762+
return 1;
766763
}
767764

768-
return overflow;
765+
/* it might be unflagged overflow */
766+
rdmsrl(hwc->event_base + hwc->idx, v);
767+
if (!(v & ARCH_P4_CNTRVAL_MASK))
768+
return 1;
769+
770+
return 0;
769771
}
770772

771773
static void p4_pmu_disable_pebs(void)
@@ -1152,9 +1154,9 @@ static __initconst const struct x86_pmu p4_pmu = {
11521154
*/
11531155
.num_counters = ARCH_P4_MAX_CCCR,
11541156
.apic = 1,
1155-
.cntval_bits = 40,
1156-
.cntval_mask = (1ULL << 40) - 1,
1157-
.max_period = (1ULL << 39) - 1,
1157+
.cntval_bits = ARCH_P4_CNTRVAL_BITS,
1158+
.cntval_mask = ARCH_P4_CNTRVAL_MASK,
1159+
.max_period = (1ULL << (ARCH_P4_CNTRVAL_BITS - 1)) - 1,
11581160
.hw_config = p4_hw_config,
11591161
.schedule_events = p4_pmu_schedule_events,
11601162
/*

‎arch/x86/kernel/dumpstack.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,8 @@ void show_stack(struct task_struct *task, unsigned long *sp)
197197
*/
198198
void dump_stack(void)
199199
{
200-
unsigned long bp = 0;
201200
unsigned long stack;
202201

203-
#ifdef CONFIG_FRAME_POINTER
204-
if (!bp)
205-
get_bp(bp);
206-
#endif
207-
208202
printk("Pid: %d, comm: %.20s %s %s %.*s\n",
209203
current->pid, current->comm, print_tainted(),
210204
init_utsname()->release,

0 commit comments

Comments
 (0)