提交 2513926c 编写于 作者: G Glauber Costa 提交者: Ingo Molnar

x86: change x86_64 smp_call_function_mask to look alike i386

the two versions (the inner version, and the outer version, that takes
the locks) of smp_call_function_mask are made into one. With the changes,
i386 and x86_64 versions look exactly the same.
Signed-off-by: NGlauber Costa <gcosta@redhat.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 3a36d1e4
...@@ -583,7 +583,7 @@ native_smp_call_function_mask(cpumask_t mask, ...@@ -583,7 +583,7 @@ native_smp_call_function_mask(cpumask_t mask,
atomic_set(&data.finished, 0); atomic_set(&data.finished, 0);
call_data = &data; call_data = &data;
mb(); wmb();
/* Send a message to other CPUs */ /* Send a message to other CPUs */
if (cpus_equal(mask, allbutself)) if (cpus_equal(mask, allbutself))
......
...@@ -354,26 +354,30 @@ static void __smp_call_function(void (*func) (void *info), void *info, ...@@ -354,26 +354,30 @@ static void __smp_call_function(void (*func) (void *info), void *info,
} }
/* int native_smp_call_function_mask(cpumask_t mask,
* this function sends a 'generic call function' IPI to all other CPU void (*func)(void *), void *info,
* of the system defined in the mask. int wait)
*/
static int __smp_call_function_mask(cpumask_t mask,
void (*func)(void *), void *info,
int wait)
{ {
struct call_data_struct data; struct call_data_struct data;
cpumask_t allbutself; cpumask_t allbutself;
int cpus; int cpus;
/* Can deadlock when called with interrupts disabled */
WARN_ON(irqs_disabled());
/* Holding any lock stops cpus from going down. */
spin_lock(&call_lock);
allbutself = cpu_online_map; allbutself = cpu_online_map;
cpu_clear(smp_processor_id(), allbutself); cpu_clear(smp_processor_id(), allbutself);
cpus_and(mask, mask, allbutself); cpus_and(mask, mask, allbutself);
cpus = cpus_weight(mask); cpus = cpus_weight(mask);
if (!cpus) if (!cpus) {
spin_unlock(&call_lock);
return 0; return 0;
}
data.func = func; data.func = func;
data.info = info; data.info = info;
...@@ -395,43 +399,14 @@ static int __smp_call_function_mask(cpumask_t mask, ...@@ -395,43 +399,14 @@ static int __smp_call_function_mask(cpumask_t mask,
while (atomic_read(&data.started) != cpus) while (atomic_read(&data.started) != cpus)
cpu_relax(); cpu_relax();
if (!wait) if (wait)
return 0; while (atomic_read(&data.finished) != cpus)
cpu_relax();
while (atomic_read(&data.finished) != cpus) spin_unlock(&call_lock);
cpu_relax();
return 0; return 0;
} }
/**
* smp_call_function_mask(): Run a function on a set of other CPUs.
* @mask: The set of cpus to run on. Must not include the current cpu.
* @func: The function to run. This must be fast and non-blocking.
* @info: An arbitrary pointer to pass to the function.
* @wait: If true, wait (atomically) until function has completed on other CPUs.
*
* Returns 0 on success, else a negative status code.
*
* If @wait is true, then returns once @func has returned; otherwise
* it returns just before the target cpu calls @func.
*
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler.
*/
int native_smp_call_function_mask(cpumask_t mask,
void (*func)(void *), void *info,
int wait)
{
int ret;
/* Can deadlock when called with interrupts disabled */
WARN_ON(irqs_disabled());
spin_lock(&call_lock);
ret = __smp_call_function_mask(mask, func, info, wait);
spin_unlock(&call_lock);
return ret;
}
static void stop_this_cpu(void *dummy) static void stop_this_cpu(void *dummy)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册