Skip to content

Commit

Permalink
smp_call_function_single(): be slightly less stupid
Browse files Browse the repository at this point in the history
If you do

	smp_call_function_single(expression-with-side-effects, ...)

then expression-with-side-effects never gets evaluated on UP builds.

As always, implementing it in C is the correct thing to do.

While we're there, uninline it for size and possible header dependency
reasons.

And create a new kernel/up.c, as a place in which to put
uniprocessor-specific code and storage.  It should mirror kernel/smp.c.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
akpm00 authored and Ingo Molnar committed Jan 11, 2009
1 parent abede81 commit 53ce3d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
13 changes: 3 additions & 10 deletions include/linux/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ struct call_single_data {
/* total number of cpus in this system (may exceed NR_CPUS) */
extern unsigned int total_cpus;

int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
int wait);

#ifdef CONFIG_SMP

#include <linux/preempt.h>
Expand Down Expand Up @@ -79,8 +82,6 @@ smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
return 0;
}

int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
int wait);
void __smp_call_function_single(int cpuid, struct call_single_data *data);

/*
Expand Down Expand Up @@ -140,14 +141,6 @@ static inline int up_smp_call_function(void (*func)(void *), void *info)
static inline void smp_send_reschedule(int cpu) { }
#define num_booting_cpus() 1
#define smp_prepare_boot_cpu() do {} while (0)
#define smp_call_function_single(cpuid, func, info, wait) \
({ \
WARN_ON(cpuid != 0); \
local_irq_disable(); \
(func)(info); \
local_irq_enable(); \
0; \
})
#define smp_call_function_mask(mask, func, info, wait) \
(up_smp_call_function(func, info))
#define smp_call_function_many(mask, func, info, wait) \
Expand Down
6 changes: 5 additions & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
obj-$(CONFIG_USE_GENERIC_SMP_HELPERS) += smp.o
ifeq ($(CONFIG_USE_GENERIC_SMP_HELPERS),y)
obj-y += smp.o
else
obj-y += up.o
endif
obj-$(CONFIG_SMP) += spinlock.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
Expand Down
18 changes: 18 additions & 0 deletions kernel/up.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Uniprocessor-only support functions. The counterpart to kernel/smp.c
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/smp.h>

int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
int wait)
{
WARN_ON(cpuid != 0);
local_irq_disable();
(func)(info);
local_irq_enable();
return 0;
}
EXPORT_SYMBOL(smp_call_function_single);

0 comments on commit 53ce3d9

Please sign in to comment.