Exemple #1
0
int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *),
			       void *info, int wait)
{
	struct call_data_struct data;
	int cpus, cpu;
	bool yield;

	/* Holding any lock stops cpus from going down. */
	spin_lock(&call_lock);

	cpu_clear(smp_processor_id(), mask);

	cpus = cpus_weight(mask);
	if (!cpus) {
		spin_unlock(&call_lock);
		return 0;
	}

	/* Can deadlock when called with interrupts disabled */
	WARN_ON(irqs_disabled());

	data.func = func;
	data.info = info;
	atomic_set(&data.started, 0);
	data.wait = wait;
	if (wait)
		atomic_set(&data.finished, 0);

	call_data = &data;
	mb();			/* write everything before IPI */

	/* Send a message to other CPUs and wait for them to respond */
	xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);

	/* Make sure other vcpus get a chance to run if they need to. */
	yield = false;
	for_each_cpu_mask(cpu, mask)
		if (xen_vcpu_stolen(cpu))
			yield = true;

	if (yield)
		HYPERVISOR_sched_op(SCHEDOP_yield, 0);

	/* Wait for response */
	while (atomic_read(&data.started) != cpus ||
	       (wait && atomic_read(&data.finished) != cpus))
		cpu_relax();

	spin_unlock(&call_lock);

	return 0;
}
Exemple #2
0
static void xen_smp_send_call_function_ipi(cpumask_t mask)
{
	int cpu;

	xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);

	/* Make sure other vcpus get a chance to run if they need to. */
	for_each_cpu_mask_nr(cpu, mask) {
		if (xen_vcpu_stolen(cpu)) {
			HYPERVISOR_sched_op(SCHEDOP_yield, 0);
			break;
		}
	}
}
static void xen_smp_send_call_function_ipi(const struct cpumask *mask)
{
	int cpu;

	xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);

	
	for_each_cpu(cpu, mask) {
		if (xen_vcpu_stolen(cpu)) {
			HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
			break;
		}
	}
}