mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: kvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Xiantao Zhang <xiantao.zhang@intel.com>
Subject: [PATCH 29/45] ia64: Implement smp_call_function_mask for ia64
Date: Thu, 17 Apr 2008 12:10:34 +0300	[thread overview]
Message-ID: <1208423450-29415-30-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <1208423450-29415-1-git-send-email-avi@qumranet.com>

From: Xiantao Zhang <xiantao.zhang@intel.com>

This interface provides more flexible functionality for smp
infrastructure.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
 arch/ia64/kernel/smp.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/asm-ia64/smp.h |    3 ++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 4e446aa..9a9d4c4 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -213,6 +213,19 @@ send_IPI_allbutself (int op)
  * Called with preemption disabled.
  */
 static inline void
+send_IPI_mask(cpumask_t mask, int op)
+{
+	unsigned int cpu;
+
+	for_each_cpu_mask(cpu, mask) {
+			send_IPI_single(cpu, op);
+	}
+}
+
+/*
+ * Called with preemption disabled.
+ */
+static inline void
 send_IPI_all (int op)
 {
 	int i;
@@ -401,6 +414,75 @@ smp_call_function_single (int cpuid, void (*func) (void *info), void *info, int
 }
 EXPORT_SYMBOL(smp_call_function_single);
 
+/**
+ * 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 smp_call_function_mask(cpumask_t mask,
+			   void (*func)(void *), void *info,
+			   int wait)
+{
+	struct call_data_struct data;
+	cpumask_t allbutself;
+	int cpus;
+
+	spin_lock(&call_lock);
+	allbutself = cpu_online_map;
+	cpu_clear(smp_processor_id(), allbutself);
+
+	cpus_and(mask, mask, allbutself);
+	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(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC*/
+
+	/* Send a message to other CPUs */
+	if (cpus_equal(mask, allbutself))
+		send_IPI_allbutself(IPI_CALL_FUNC);
+	else
+		send_IPI_mask(mask, IPI_CALL_FUNC);
+
+	/* Wait for response */
+	while (atomic_read(&data.started) != cpus)
+		cpu_relax();
+
+	if (wait)
+		while (atomic_read(&data.finished) != cpus)
+			cpu_relax();
+	call_data = NULL;
+
+	spin_unlock(&call_lock);
+	return 0;
+
+}
+EXPORT_SYMBOL(smp_call_function_mask);
+
 /*
  * this function sends a 'generic call function' IPI to all other CPUs
  * in the system.
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index 4fa733d..ec5f355 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -38,6 +38,9 @@ ia64_get_lid (void)
 	return lid.f.id << 8 | lid.f.eid;
 }
 
+extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
+				  void *info, int wait);
+
 #define hard_smp_processor_id()		ia64_get_lid()
 
 #ifdef CONFIG_SMP
-- 
1.5.5


  parent reply	other threads:[~2008-04-17  9:23 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-17  9:10 [PATCH 00/45] KVM updates for the 2.6.26 merge window (part III) Avi Kivity
2008-04-17  9:10 ` [PATCH 01/45] s390: fixup for kvm Avi Kivity
2008-04-17  9:10 ` [PATCH 02/45] s390: KVM preparation: provide hook to enable pgstes in user pagetable Avi Kivity
2008-04-17  9:10 ` [PATCH 03/45] s390: KVM preparation: host memory management changes for s390 kvm Avi Kivity
2008-04-17  9:10 ` [PATCH 04/45] s390: KVM preparation: address of the 64bit extint parm in lowcore Avi Kivity
2008-04-17  9:10 ` [PATCH 05/45] s390: KVM preparation: split sysinfo defintions for kvm use Avi Kivity
2008-04-17  9:10 ` [PATCH 06/45] KVM: s390: arch backend for the kvm kernel module Avi Kivity
2008-04-17  9:10 ` [PATCH 07/45] KVM: s390: sie intercept handling Avi Kivity
2008-04-17  9:10 ` [PATCH 08/45] KVM: s390: interrupt subsystem, cpu timer, waitpsw Avi Kivity
2008-04-17  9:10 ` [PATCH 09/45] KVM: s390: intercepts for privileged instructions Avi Kivity
2008-04-17  9:10 ` [PATCH 10/45] KVM: s390: interprocessor communication via sigp Avi Kivity
2008-04-17  9:10 ` [PATCH 11/45] KVM: s390: intercepts for diagnose instructions Avi Kivity
2008-04-17  9:10 ` [PATCH 12/45] KVM: s390: add kvm to kconfig on s390 Avi Kivity
2008-04-17  9:10 ` [PATCH 13/45] KVM: s390: API documentation Avi Kivity
2008-04-17 15:11   ` Randy Dunlap
2008-04-17 15:42     ` Carsten Otte
2008-04-17  9:10 ` [PATCH 14/45] KVM: s390: update maintainers Avi Kivity
2008-04-17  9:10 ` [PATCH 15/45] s390: KVM guest: detect when running on kvm Avi Kivity
2008-04-17  9:10 ` [PATCH 16/45] s390: KVM guest: virtio device support, and kvm hypercalls Avi Kivity
2008-04-17  9:10 ` [PATCH 17/45] KVM: VMX: Enable MSR Bitmap feature Avi Kivity
2008-04-17  9:10 ` [PATCH 18/45] KVM: MMU: unify slots_lock usage Avi Kivity
2008-04-17  9:10 ` [PATCH 19/45] KVM: MMU: allow the vm to shrink the kvm mmu shadow caches Avi Kivity
2008-04-17  9:10 ` [PATCH 20/45] KVM: Free apic access page on vm destruction Avi Kivity
2008-04-17  9:10 ` [PATCH 21/45] KVM: function declaration parameter name cleanup Avi Kivity
2008-04-17  9:10 ` [PATCH 22/45] KVM: add vm refcounting Avi Kivity
2008-04-17  9:10 ` [PATCH 23/45] KVM: MMU: Only mark_page_accessed() if the page was accessed by the guest Avi Kivity
2008-04-17  9:10 ` [PATCH 24/45] KVM: MMU: prepopulate guest pages after write-protecting Avi Kivity
2008-04-17  9:10 ` [PATCH 25/45] KVM: s390: Fix incorrect return value Avi Kivity
2008-04-17  9:10 ` [PATCH 26/45] KVM: s390: rename stfl to kvm_stfl Avi Kivity
2008-04-17  9:10 ` [PATCH 27/45] KVM: s390: Improve pgste accesses Avi Kivity
2008-04-17  9:10 ` [PATCH 28/45] ia64: Add API for allocating Dynamic TR resource Avi Kivity
2008-04-17  9:10 ` Avi Kivity [this message]
2008-04-17  9:10 ` [PATCH 30/45] KVM: ia64: Prepare some structure and routines for kvm use Avi Kivity
2008-04-17  9:10 ` [PATCH 31/45] KVM: ia64: Add header files for kvm/ia64 Avi Kivity
2008-04-17  9:10 ` [PATCH 32/45] KVM: ia64: Add kvm arch-specific core code " Avi Kivity
2008-04-17  9:10 ` [PATCH 33/45] KVM: ia64: Add header files " Avi Kivity
2008-04-17  9:10 ` [PATCH 34/45] KVM: ia64: VMM module interfaces Avi Kivity
2008-04-17  9:10 ` [PATCH 35/45] KVM: ia64: Add TLB virtulization support Avi Kivity
2008-04-17  9:10 ` [PATCH 36/45] KVM: ia64: Add interruption vector table for vmm Avi Kivity
2008-04-17  9:10 ` [PATCH 37/45] KVM: ia64: Add mmio decoder for kvm/ia64 Avi Kivity
2008-04-17  9:10 ` [PATCH 38/45] KVM: ia64: Add trampoline for guest/host mode switch Avi Kivity
2008-04-17  9:10 ` [PATCH 39/45] KVM: ia64: Add processor virtulization support Avi Kivity
2008-04-17  9:10 ` [PATCH 40/45] KVM: ia64: Add optimization for some virtulization faults Avi Kivity
2008-04-17  9:10 ` [PATCH 41/45] KVM: ia64: Generate offset values for assembly code use Avi Kivity
2008-04-17  9:10 ` [PATCH 42/45] KVM: ia64: Add guest interruption injection support Avi Kivity
2008-04-17  9:10 ` [PATCH 43/45] KVM: ia64: Add kvm sal/pal virtulization support Avi Kivity
2008-04-17  9:10 ` [PATCH 44/45] KVM: ia64: Enable kvm build for ia64 Avi Kivity
2008-04-17  9:10 ` [PATCH 45/45] KVM: ia64: Add a guide about how to create kvm guests on ia64 Avi Kivity
2008-04-17 15:15   ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208423450-29415-30-git-send-email-avi@qumranet.com \
    --to=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiantao.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®