Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d442233 authored by Jens Axboe's avatar Jens Axboe
Browse files

Add generic helpers for arch IPI function calls



This adds kernel/smp.c which contains helpers for IPI function calls. In
addition to supporting the existing smp_call_function() in a more efficient
manner, it also adds a more scalable variant called smp_call_function_single()
for calling a given function on a single CPU only.

The core of this is based on the x86-64 patch from Nick Piggin, lots of
changes since then. "Alan D. Brunelle" <Alan.Brunelle@hp.com> has
contributed lots of fixes and suggestions as well. Also thanks to
Paul E. McKenney <paulmck@linux.vnet.ibm.com> for reviewing RCU usage
and getting rid of the data allocation fallback deadlock.

Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Reviewed-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 543cf4cb
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -39,3 +39,6 @@ config HAVE_KRETPROBES

config HAVE_DMA_ATTRS
	def_bool n

config USE_GENERIC_SMP_HELPERS
	def_bool n
+6 −5
Original line number Diff line number Diff line
@@ -816,8 +816,9 @@ extern unsigned long xcall_call_function;
 * You must not call this function with disabled interrupts or from a
 * hardware interrupt handler or from a bottom half handler.
 */
static int smp_call_function_mask(void (*func)(void *info), void *info,
				  int nonatomic, int wait, cpumask_t mask)
static int sparc64_smp_call_function_mask(void (*func)(void *info), void *info,
					  int nonatomic, int wait,
					  cpumask_t mask)
{
	struct call_data_struct data;
	int cpus;
@@ -855,7 +856,7 @@ static int smp_call_function_mask(void (*func)(void *info), void *info,
int smp_call_function(void (*func)(void *info), void *info,
		      int nonatomic, int wait)
{
	return smp_call_function_mask(func, info, nonatomic, wait,
	return sparc64_smp_call_function_mask(func, info, nonatomic, wait,
						cpu_online_map);
}

@@ -893,7 +894,7 @@ static void tsb_sync(void *info)

void smp_tsb_sync(struct mm_struct *mm)
{
	smp_call_function_mask(tsb_sync, mm, 0, 1, mm->cpu_vm_mask);
	sparc64_smp_call_function_mask(tsb_sync, mm, 0, 1, mm->cpu_vm_mask);
}

extern unsigned long xcall_flush_tlb_mm;
+33 −2
Original line number Diff line number Diff line
@@ -7,9 +7,19 @@
 */

#include <linux/errno.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/cpumask.h>

extern void cpu_idle(void);

struct call_single_data {
	struct list_head list;
	void (*func) (void *info);
	void *info;
	unsigned int flags;
};

#ifdef CONFIG_SMP

#include <linux/preempt.h>
@@ -53,9 +63,28 @@ extern void smp_cpus_done(unsigned int max_cpus);
 * Call a function on all other processors
 */
int smp_call_function(void(*func)(void *info), void *info, int retry, int wait);

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

/*
 * Generic and arch helpers
 */
#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
void generic_smp_call_function_single_interrupt(void);
void generic_smp_call_function_interrupt(void);
void init_call_single_data(void);
void ipi_call_lock(void);
void ipi_call_unlock(void);
void ipi_call_lock_irq(void);
void ipi_call_unlock_irq(void);
#else
static inline void init_call_single_data(void)
{
}
#endif

/*
 * Call a function on all processors
@@ -112,7 +141,9 @@ static inline void smp_send_reschedule(int cpu) { }
})
#define smp_call_function_mask(mask, func, info, wait) \
			(up_smp_call_function(func, info))

static inline void init_call_single_data(void)
{
}
#endif /* !SMP */

/*
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/kernel_stat.h>
#include <linux/start_kernel.h>
#include <linux/security.h>
#include <linux/smp.h>
#include <linux/workqueue.h>
#include <linux/profile.h>
#include <linux/rcupdate.h>
@@ -779,6 +780,7 @@ static void __init do_pre_smp_initcalls(void)
{
	extern int spawn_ksoftirqd(void);

	init_call_single_data();
	migration_init();
	spawn_ksoftirqd();
	if (!nosoftlockup)
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ 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_SMP) += cpu.o spinlock.o
obj-$(CONFIG_USE_GENERIC_SMP_HELPERS) += smp.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
obj-$(CONFIG_UID16) += uid16.o
Loading