Skip to content

Commit f21afc2

Browse files
daviddaneytorvalds
authored andcommitted
smp.h: Use local_irq_{save,restore}() in !SMP version of on_each_cpu().
Thanks to commit f91eb62 ("init: scream bloody murder if interrupts are enabled too early"), "bloody murder" is now being screamed. With a MIPS OCTEON config, we use on_each_cpu() in our irq_chip.irq_bus_sync_unlock() function. This gets called in early as a result of the time_init() call. Because the !SMP version of on_each_cpu() unconditionally enables irqs, we get: WARNING: at init/main.c:560 start_kernel+0x250/0x410() Interrupts were enabled early CPU: 0 PID: 0 Comm: swapper Not tainted 3.10.0-rc5-Cavium-Octeon+ #801 Call Trace: show_stack+0x68/0x80 warn_slowpath_common+0x78/0xb0 warn_slowpath_fmt+0x38/0x48 start_kernel+0x250/0x410 Suggested fix: Do what we already do in the SMP version of on_each_cpu(), and use local_irq_save/local_irq_restore. Because we need a flags variable, make it a static inline to avoid name space issues. [ Change from v1: Convert on_each_cpu to a static inline function, add #include <linux/irqflags.h> to avoid build breakage on some files. on_each_cpu_mask() and on_each_cpu_cond() suffer the same problem as on_each_cpu(), but they are not causing !SMP bugs for me, so I will defer changing them to a less urgent patch. ] Signed-off-by: David Daney <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d0ff934 commit f21afc2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

include/linux/smp.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/list.h>
1212
#include <linux/cpumask.h>
1313
#include <linux/init.h>
14+
#include <linux/irqflags.h>
1415

1516
extern void cpu_idle(void);
1617

@@ -139,13 +140,17 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info)
139140
}
140141
#define smp_call_function(func, info, wait) \
141142
(up_smp_call_function(func, info))
142-
#define on_each_cpu(func,info,wait) \
143-
({ \
144-
local_irq_disable(); \
145-
func(info); \
146-
local_irq_enable(); \
147-
0; \
148-
})
143+
144+
static inline int on_each_cpu(smp_call_func_t func, void *info, int wait)
145+
{
146+
unsigned long flags;
147+
148+
local_irq_save(flags);
149+
func(info);
150+
local_irq_restore(flags);
151+
return 0;
152+
}
153+
149154
/*
150155
* Note we still need to test the mask even for UP
151156
* because we actually can get an empty mask from

0 commit comments

Comments
 (0)