Skip to content

Commit 97c8580

Browse files
committed
MIPS: Annotate cpu_wait implementations with __cpuidle
Annotate cpu_wait implementations using the __cpuidle macro which places these functions in the .cpuidle.text section. This allows cpu_in_idle() to return true for PC values which fall within these functions, allowing nmi_backtrace() to produce cleaner output for CPUs running idle functions. For example: # echo l >/proc/sysrq-trigger [ 38.587170] sysrq: SysRq : Show backtrace of all active CPUs [ 38.593657] NMI backtrace for cpu 1 [ 38.597611] CPU: 1 PID: 161 Comm: sh Not tainted 4.18.0-rc1+ #27 [ 38.604306] Stack : 00000000 00000004 00000006 80486724 00000000 00000000 00000000 00000000 [ 38.613647] 80e17eda 00000034 00000000 00000000 80d20000 80b67e98 8e559c90 0ffe1e88 [ 38.622986] 00000000 00000000 80e70000 00000000 8f61db18 38312e34 722d302e 202b3163 [ 38.632324] 8e559d3c 8e559adc 00000001 6b636162 80d20000 80000000 00000000 80d1cfa4 [ 38.641664] 00000001 80d20000 80d19520 00000000 00000003 80836724 00000004 80e10004 [ 38.650993] ... [ 38.653724] Call Trace: [ 38.656499] [<8040cdd0>] show_stack+0xa0/0x144 [ 38.661475] [<80b67e98>] dump_stack+0xe8/0x120 [ 38.666455] [<80b6f6d4>] nmi_cpu_backtrace+0x1b4/0x1cc [ 38.672189] [<80b6f81c>] nmi_trigger_cpumask_backtrace+0x130/0x1e4 [ 38.679081] [<808295d8>] __handle_sysrq+0xc0/0x180 [ 38.684421] [<80829b84>] write_sysrq_trigger+0x50/0x64 [ 38.690176] [<8061c984>] proc_reg_write+0xd0/0xfc [ 38.695447] [<805aac1c>] __vfs_write+0x54/0x194 [ 38.700500] [<805aaf24>] vfs_write+0xe0/0x18c [ 38.705360] [<805ab190>] ksys_write+0x7c/0xf0 [ 38.710238] [<80416018>] syscall_common+0x34/0x58 [ 38.715558] Sending NMI from CPU 1 to CPUs 0,2-3: [ 38.720916] NMI backtrace for cpu 0 skipped: idling at r4k_wait_irqoff+0x2c/0x34 [ 38.729186] NMI backtrace for cpu 3 skipped: idling at r4k_wait_irqoff+0x2c/0x34 [ 38.737449] NMI backtrace for cpu 2 skipped: idling at r4k_wait_irqoff+0x2c/0x34 Without this we get register value & backtrace output from all CPUs, which is generally useless for those running the idle function & serves only to overwhelm & obfuscate the meaningful output from non-idle CPUs. Signed-off-by: Paul Burton <[email protected]> Cc: James Hogan <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Huacai Chen <[email protected]> Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/19598/
1 parent 829caee commit 97c8580

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

arch/mips/kernel/idle.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333
void (*cpu_wait)(void);
3434
EXPORT_SYMBOL(cpu_wait);
3535

36-
static void r3081_wait(void)
36+
static void __cpuidle r3081_wait(void)
3737
{
3838
unsigned long cfg = read_c0_conf();
3939
write_c0_conf(cfg | R30XX_CONF_HALT);
4040
local_irq_enable();
4141
}
4242

43-
static void r39xx_wait(void)
43+
static void __cpuidle r39xx_wait(void)
4444
{
4545
if (!need_resched())
4646
write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
4747
local_irq_enable();
4848
}
4949

50-
void r4k_wait(void)
50+
void __cpuidle r4k_wait(void)
5151
{
5252
local_irq_enable();
5353
__r4k_wait();
@@ -60,7 +60,7 @@ void r4k_wait(void)
6060
* interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
6161
* using this version a gamble.
6262
*/
63-
void r4k_wait_irqoff(void)
63+
void __cpuidle r4k_wait_irqoff(void)
6464
{
6565
if (!need_resched())
6666
__asm__(
@@ -75,7 +75,7 @@ void r4k_wait_irqoff(void)
7575
* The RM7000 variant has to handle erratum 38. The workaround is to not
7676
* have any pending stores when the WAIT instruction is executed.
7777
*/
78-
static void rm7k_wait_irqoff(void)
78+
static void __cpuidle rm7k_wait_irqoff(void)
7979
{
8080
if (!need_resched())
8181
__asm__(
@@ -96,7 +96,7 @@ static void rm7k_wait_irqoff(void)
9696
* since coreclock (and the cp0 counter) stops upon executing it. Only an
9797
* interrupt can wake it, so they must be enabled before entering idle modes.
9898
*/
99-
static void au1k_wait(void)
99+
static void __cpuidle au1k_wait(void)
100100
{
101101
unsigned long c0status = read_c0_status() | 1; /* irqs on */
102102

arch/mips/vr41xx/common/pmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* along with this program; if not, write to the Free Software
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
20+
#include <linux/cpu.h>
2021
#include <linux/errno.h>
2122
#include <linux/init.h>
2223
#include <linux/ioport.h>
@@ -46,7 +47,7 @@ static void __iomem *pmu_base;
4647
#define pmu_read(offset) readw(pmu_base + (offset))
4748
#define pmu_write(offset, value) writew((value), pmu_base + (offset))
4849

49-
static void vr41xx_cpu_wait(void)
50+
static void __cpuidle vr41xx_cpu_wait(void)
5051
{
5152
local_irq_disable();
5253
if (!need_resched())

0 commit comments

Comments
 (0)