Skip to content

Commit 6727ad9

Browse files
cmetcalf-tileratorvalds
authored andcommitted
nmi_backtrace: generate one-line reports for idle cpus
When doing an nmi backtrace of many cores, most of which are idle, the output is a little overwhelming and very uninformative. Suppress messages for cpus that are idling when they are interrupted and just emit one line, "NMI backtrace for N skipped: idling at pc 0xNNN". We do this by grouping all the cpuidle code together into a new .cpuidle.text section, and then checking the address of the interrupted PC to see if it lies within that section. This commit suitably tags x86 and tile idle routines, and only adds in the minimal framework for other architectures. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Chris Metcalf <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Daniel Thompson <[email protected]> [arm] Tested-by: Petr Mladek <[email protected]> Cc: Aaron Tomlin <[email protected]> Cc: Peter Zijlstra (Intel) <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Russell King <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 511f838 commit 6727ad9

File tree

49 files changed

+93
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+93
-22
lines changed

arch/alpha/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ SECTIONS
2222
HEAD_TEXT
2323
TEXT_TEXT
2424
SCHED_TEXT
25+
CPUIDLE_TEXT
2526
LOCK_TEXT
2627
*(.fixup)
2728
*(.gnu.warning)

arch/arc/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ SECTIONS
8989
_text = .;
9090
TEXT_TEXT
9191
SCHED_TEXT
92+
CPUIDLE_TEXT
9293
LOCK_TEXT
9394
KPROBES_TEXT
9495
*(.fixup)

arch/arm/kernel/vmlinux-xip.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ SECTIONS
9898
IRQENTRY_TEXT
9999
TEXT_TEXT
100100
SCHED_TEXT
101+
CPUIDLE_TEXT
101102
LOCK_TEXT
102103
KPROBES_TEXT
103104
*(.gnu.warning)

arch/arm/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ SECTIONS
111111
SOFTIRQENTRY_TEXT
112112
TEXT_TEXT
113113
SCHED_TEXT
114+
CPUIDLE_TEXT
114115
LOCK_TEXT
115116
HYPERVISOR_TEXT
116117
KPROBES_TEXT

arch/arm64/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ SECTIONS
122122
ENTRY_TEXT
123123
TEXT_TEXT
124124
SCHED_TEXT
125+
CPUIDLE_TEXT
125126
LOCK_TEXT
126127
KPROBES_TEXT
127128
HYPERVISOR_TEXT

arch/avr32/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SECTIONS
5252
KPROBES_TEXT
5353
TEXT_TEXT
5454
SCHED_TEXT
55+
CPUIDLE_TEXT
5556
LOCK_TEXT
5657
*(.fixup)
5758
*(.gnu.warning)

arch/blackfin/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SECTIONS
3333
#ifndef CONFIG_SCHEDULE_L1
3434
SCHED_TEXT
3535
#endif
36+
CPUIDLE_TEXT
3637
LOCK_TEXT
3738
IRQENTRY_TEXT
3839
SOFTIRQENTRY_TEXT

arch/c6x/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SECTIONS
7070
_stext = .;
7171
TEXT_TEXT
7272
SCHED_TEXT
73+
CPUIDLE_TEXT
7374
LOCK_TEXT
7475
IRQENTRY_TEXT
7576
SOFTIRQENTRY_TEXT

arch/cris/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SECTIONS
4343
HEAD_TEXT
4444
TEXT_TEXT
4545
SCHED_TEXT
46+
CPUIDLE_TEXT
4647
LOCK_TEXT
4748
*(.fixup)
4849
*(.text.__*)

arch/frv/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ SECTIONS
6363
*(.text..tlbmiss)
6464
TEXT_TEXT
6565
SCHED_TEXT
66+
CPUIDLE_TEXT
6667
LOCK_TEXT
6768
#ifdef CONFIG_DEBUG_INFO
6869
INIT_TEXT

arch/h8300/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ SECTIONS
2929
_stext = . ;
3030
TEXT_TEXT
3131
SCHED_TEXT
32+
CPUIDLE_TEXT
3233
LOCK_TEXT
3334
#if defined(CONFIG_ROMKERNEL)
3435
*(.int_redirect)

arch/hexagon/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ SECTIONS
5050
_text = .;
5151
TEXT_TEXT
5252
SCHED_TEXT
53+
CPUIDLE_TEXT
5354
LOCK_TEXT
5455
KPROBES_TEXT
5556
*(.fixup)

arch/ia64/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SECTIONS {
4646
__end_ivt_text = .;
4747
TEXT_TEXT
4848
SCHED_TEXT
49+
CPUIDLE_TEXT
4950
LOCK_TEXT
5051
KPROBES_TEXT
5152
*(.gnu.linkonce.t*)

arch/m32r/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SECTIONS
3131
HEAD_TEXT
3232
TEXT_TEXT
3333
SCHED_TEXT
34+
CPUIDLE_TEXT
3435
LOCK_TEXT
3536
*(.fixup)
3637
*(.gnu.warning)

arch/m68k/kernel/vmlinux-nommu.lds

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SECTIONS {
4545
HEAD_TEXT
4646
TEXT_TEXT
4747
SCHED_TEXT
48+
CPUIDLE_TEXT
4849
LOCK_TEXT
4950
*(.fixup)
5051
. = ALIGN(16);

arch/m68k/kernel/vmlinux-std.lds

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SECTIONS
1616
HEAD_TEXT
1717
TEXT_TEXT
1818
SCHED_TEXT
19+
CPUIDLE_TEXT
1920
LOCK_TEXT
2021
*(.fixup)
2122
*(.gnu.warning)

arch/m68k/kernel/vmlinux-sun3.lds

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SECTIONS
1616
HEAD_TEXT
1717
TEXT_TEXT
1818
SCHED_TEXT
19+
CPUIDLE_TEXT
1920
LOCK_TEXT
2021
*(.fixup)
2122
*(.gnu.warning)

arch/metag/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ SECTIONS
2121
.text : {
2222
TEXT_TEXT
2323
SCHED_TEXT
24+
CPUIDLE_TEXT
2425
LOCK_TEXT
2526
KPROBES_TEXT
2627
IRQENTRY_TEXT

arch/microblaze/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SECTIONS {
3333
EXIT_TEXT
3434
EXIT_CALL
3535
SCHED_TEXT
36+
CPUIDLE_TEXT
3637
LOCK_TEXT
3738
KPROBES_TEXT
3839
IRQENTRY_TEXT

arch/mips/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ SECTIONS
5555
.text : {
5656
TEXT_TEXT
5757
SCHED_TEXT
58+
CPUIDLE_TEXT
5859
LOCK_TEXT
5960
KPROBES_TEXT
6061
IRQENTRY_TEXT

arch/mn10300/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SECTIONS
3030
HEAD_TEXT
3131
TEXT_TEXT
3232
SCHED_TEXT
33+
CPUIDLE_TEXT
3334
LOCK_TEXT
3435
KPROBES_TEXT
3536
*(.fixup)

arch/nios2/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SECTIONS
3737
.text : {
3838
TEXT_TEXT
3939
SCHED_TEXT
40+
CPUIDLE_TEXT
4041
LOCK_TEXT
4142
IRQENTRY_TEXT
4243
SOFTIRQENTRY_TEXT

arch/openrisc/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SECTIONS
4747
_stext = .;
4848
TEXT_TEXT
4949
SCHED_TEXT
50+
CPUIDLE_TEXT
5051
LOCK_TEXT
5152
KPROBES_TEXT
5253
IRQENTRY_TEXT

arch/parisc/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ SECTIONS
6969
.text ALIGN(PAGE_SIZE) : {
7070
TEXT_TEXT
7171
SCHED_TEXT
72+
CPUIDLE_TEXT
7273
LOCK_TEXT
7374
KPROBES_TEXT
7475
IRQENTRY_TEXT

arch/powerpc/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SECTIONS
5252
/* careful! __ftr_alt_* sections need to be close to .text */
5353
*(.text .fixup __ftr_alt_* .ref.text)
5454
SCHED_TEXT
55+
CPUIDLE_TEXT
5556
LOCK_TEXT
5657
KPROBES_TEXT
5758
IRQENTRY_TEXT

arch/s390/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SECTIONS
3535
HEAD_TEXT
3636
TEXT_TEXT
3737
SCHED_TEXT
38+
CPUIDLE_TEXT
3839
LOCK_TEXT
3940
KPROBES_TEXT
4041
IRQENTRY_TEXT

arch/score/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SECTIONS
4040
_text = .; /* Text and read-only data */
4141
TEXT_TEXT
4242
SCHED_TEXT
43+
CPUIDLE_TEXT
4344
LOCK_TEXT
4445
KPROBES_TEXT
4546
*(.text.*)

arch/sh/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SECTIONS
3636
TEXT_TEXT
3737
EXTRA_TEXT
3838
SCHED_TEXT
39+
CPUIDLE_TEXT
3940
LOCK_TEXT
4041
KPROBES_TEXT
4142
IRQENTRY_TEXT

arch/sparc/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ SECTIONS
4949
HEAD_TEXT
5050
TEXT_TEXT
5151
SCHED_TEXT
52+
CPUIDLE_TEXT
5253
LOCK_TEXT
5354
KPROBES_TEXT
5455
IRQENTRY_TEXT

arch/tile/kernel/entry.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ STD_ENTRY(smp_nap)
5050
* When interrupted at _cpu_idle_nap, we bump the PC forward 8, and
5151
* as a result return to the function that called _cpu_idle().
5252
*/
53-
STD_ENTRY(_cpu_idle)
53+
STD_ENTRY_SECTION(_cpu_idle, .cpuidle.text)
5454
movei r1, 1
5555
IRQ_ENABLE_LOAD(r2, r3)
5656
mtspr INTERRUPT_CRITICAL_SECTION, r1

arch/tile/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SECTIONS
4242
.text : AT (ADDR(.text) - LOAD_OFFSET) {
4343
HEAD_TEXT
4444
SCHED_TEXT
45+
CPUIDLE_TEXT
4546
LOCK_TEXT
4647
KPROBES_TEXT
4748
IRQENTRY_TEXT

arch/um/kernel/dyn.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ SECTIONS
6868
_stext = .;
6969
TEXT_TEXT
7070
SCHED_TEXT
71+
CPUIDLE_TEXT
7172
LOCK_TEXT
7273
*(.fixup)
7374
*(.stub .text.* .gnu.linkonce.t.*)

arch/um/kernel/uml.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SECTIONS
2828
_stext = .;
2929
TEXT_TEXT
3030
SCHED_TEXT
31+
CPUIDLE_TEXT
3132
LOCK_TEXT
3233
*(.fixup)
3334
/* .gnu.warning sections are handled specially by elf32.em. */

arch/unicore32/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SECTIONS
3737
.text : { /* Real text segment */
3838
TEXT_TEXT
3939
SCHED_TEXT
40+
CPUIDLE_TEXT
4041
LOCK_TEXT
4142

4243
*(.fixup)

arch/x86/include/asm/irqflags.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <asm/processor-flags.h>
55

66
#ifndef __ASSEMBLY__
7+
8+
/* Provide __cpuidle; we can't safely include <linux/cpu.h> */
9+
#define __cpuidle __attribute__((__section__(".cpuidle.text")))
10+
711
/*
812
* Interrupt control:
913
*/
@@ -44,12 +48,12 @@ static inline void native_irq_enable(void)
4448
asm volatile("sti": : :"memory");
4549
}
4650

47-
static inline void native_safe_halt(void)
51+
static inline __cpuidle void native_safe_halt(void)
4852
{
4953
asm volatile("sti; hlt": : :"memory");
5054
}
5155

52-
static inline void native_halt(void)
56+
static inline __cpuidle void native_halt(void)
5357
{
5458
asm volatile("hlt": : :"memory");
5559
}
@@ -86,7 +90,7 @@ static inline notrace void arch_local_irq_enable(void)
8690
* Used in the idle loop; sti takes one instruction cycle
8791
* to complete:
8892
*/
89-
static inline void arch_safe_halt(void)
93+
static inline __cpuidle void arch_safe_halt(void)
9094
{
9195
native_safe_halt();
9296
}
@@ -95,7 +99,7 @@ static inline void arch_safe_halt(void)
9599
* Used when interrupts are already enabled or to
96100
* shutdown the processor:
97101
*/
98-
static inline void halt(void)
102+
static inline __cpuidle void halt(void)
99103
{
100104
native_halt();
101105
}

arch/x86/kernel/acpi/cstate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
152152
}
153153
EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
154154

155-
void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
155+
void __cpuidle acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
156156
{
157157
unsigned int cpu = smp_processor_id();
158158
struct cstate_entry *percpu_entry;

arch/x86/kernel/process.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void arch_cpu_idle(void)
302302
/*
303303
* We use this if we don't have any better idle routine..
304304
*/
305-
void default_idle(void)
305+
void __cpuidle default_idle(void)
306306
{
307307
trace_cpu_idle_rcuidle(1, smp_processor_id());
308308
safe_halt();
@@ -417,7 +417,7 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
417417
* with interrupts enabled and no flags, which is backwards compatible with the
418418
* original MWAIT implementation.
419419
*/
420-
static void mwait_idle(void)
420+
static __cpuidle void mwait_idle(void)
421421
{
422422
if (!current_set_polling_and_test()) {
423423
trace_cpu_idle_rcuidle(1, smp_processor_id());

arch/x86/kernel/vmlinux.lds.S

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ SECTIONS
9797
_stext = .;
9898
TEXT_TEXT
9999
SCHED_TEXT
100+
CPUIDLE_TEXT
100101
LOCK_TEXT
101102
KPROBES_TEXT
102103
ENTRY_TEXT

arch/xtensa/kernel/vmlinux.lds.S

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ SECTIONS
8989
VMLINUX_SYMBOL(__sched_text_start) = .;
9090
*(.sched.literal .sched.text)
9191
VMLINUX_SYMBOL(__sched_text_end) = .;
92+
VMLINUX_SYMBOL(__cpuidle_text_start) = .;
93+
*(.cpuidle.literal .cpuidle.text)
94+
VMLINUX_SYMBOL(__cpuidle_text_end) = .;
9295
VMLINUX_SYMBOL(__lock_text_start) = .;
9396
*(.spinlock.literal .spinlock.text)
9497
VMLINUX_SYMBOL(__lock_text_end) = .;

drivers/acpi/processor_idle.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/sched.h> /* need_resched() */
3232
#include <linux/tick.h>
3333
#include <linux/cpuidle.h>
34+
#include <linux/cpu.h>
3435
#include <acpi/processor.h>
3536

3637
/*
@@ -115,7 +116,7 @@ static const struct dmi_system_id processor_power_dmi_table[] = {
115116
* Callers should disable interrupts before the call and enable
116117
* interrupts after return.
117118
*/
118-
static void acpi_safe_halt(void)
119+
static void __cpuidle acpi_safe_halt(void)
119120
{
120121
if (!tif_need_resched()) {
121122
safe_halt();
@@ -645,7 +646,7 @@ static int acpi_idle_bm_check(void)
645646
*
646647
* Caller disables interrupt before call and enables interrupt after return.
647648
*/
648-
static void acpi_idle_do_entry(struct acpi_processor_cx *cx)
649+
static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx)
649650
{
650651
if (cx->entry_method == ACPI_CSTATE_FFH) {
651652
/* Call into architectural FFH based C-state */

0 commit comments

Comments
 (0)