public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Andi Kleen <andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org>
Cc: KVM <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 17/20] SMP: Implement on_cpu()
Date: Mon, 09 Jul 2007 14:28:41 +0300	[thread overview]
Message-ID: <46921BE9.4040801@qumranet.com> (raw)
In-Reply-To: <46920270.3080309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

Avi Kivity wrote:
> Andi Kleen wrote:
>>> Well, smp_call_function_single() is arch specific whereas on_cpu() is
>>>     
>>
>> Yes, but the few instances should be relatively easy to fix.
>>
>>  
>>> generic code.  Perhaps rename smp_call_function_single() to
>>> __smp_call_function_single() and on_cpu() to 
>>> smp_call_function_single()?
>>>     
>>
>> The low level function checks for this anyways. Instead of erroring
>> it should just DTRT.
>>   
>
> Okay.  I'll make that change.
>
>

Here it is (whitespace-mangled, don't try to apply).

diff --git a/arch/i386/kernel/smpcommon.c b/arch/i386/kernel/smpcommon.c
index 1868ae1..bbfe85a 100644
--- a/arch/i386/kernel/smpcommon.c
+++ b/arch/i386/kernel/smpcommon.c
@@ -47,7 +47,7 @@ int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
 EXPORT_SYMBOL(smp_call_function);
 
 /**
- * smp_call_function_single - Run a function on another CPU
+ * smp_call_function_single - Run a function on a specific CPU
  * @cpu: The target CPU.  Cannot be the calling CPU.
  * @func: The function to run. This must be fast and non-blocking.
  * @info: An arbitrary pointer to pass to the function.
@@ -66,9 +66,11 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
 	int ret;
 	int me = get_cpu();
 	if (cpu == me) {
-		WARN_ON(1);
+		local_irq_disable();
+		func(info);
+		local_irq_enable();
 		put_cpu();
-		return -EBUSY;
+		return 0;
 	}
 
 	ret = smp_call_function_mask(cpumask_of_cpu(cpu), func, info, wait);
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 2ff4685..e6e5017 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -357,7 +357,7 @@ __smp_call_function_single(int cpu, void (*func) (void *info), void *info,
 }
 
 /*
- * smp_call_function_single - Run a function on another CPU
+ * smp_call_function_single - Run a function on a specific CPU
  * @func: The function to run. This must be fast and non-blocking.
  * @info: An arbitrary pointer to pass to the function.
  * @nonatomic: Currently unused.
@@ -372,16 +372,19 @@ __smp_call_function_single(int cpu, void (*func) (void *info), void *info,
 int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
 	int nonatomic, int wait)
 {
+	/* Can deadlock when called with interrupts disabled */
+	WARN_ON(irqs_disabled());
+
 	/* prevent preemption and reschedule on another processor */
 	int me = get_cpu();
 	if (cpu == me) {
+		local_irq_disable();
+		func(info);
+		local_irq_enable();
 		put_cpu();
 		return 0;
 	}
 
-	/* Can deadlock when called with interrupts disabled */
-	WARN_ON(irqs_disabled());
-
 	spin_lock_bh(&call_lock);
 	__smp_call_function_single(cpu, func, info, nonatomic, wait);
 	spin_unlock_bh(&call_lock);
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 613edd2..ed38a3d 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -118,7 +118,11 @@ static inline void smp_send_reschedule(int cpu) { }
 static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
 					   void *info, int retry, int wait)
 {
-	return -EBUSY;
+	WARN_ON(cpuid != 0);
+	local_irq_disable();
+	func(info);
+	local_irq_enable();
+	return 0;
 }
 
 #endif /* !SMP */


If there are no objections, I will push it (split up) through my kvm updates patchset, as other kvm patches depend on it.  I will submit patches to other archs through the arch maintainers as kvm doesn't care about them yet.


-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

  parent reply	other threads:[~2007-07-09 11:28 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-08 11:54 [PATCH 00/20] KVM updates for 2.6.23, part 2 Avi Kivity
     [not found] ` <11838956891287-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-08 11:54   ` [PATCH 01/20] KVM: Implement emulation of "pop reg" instruction (opcode 0x58-0x5f) Avi Kivity
2007-07-08 11:54   ` [PATCH 02/20] KVM: Implement emulation of instruction "ret" (opcode 0xc3) Avi Kivity
2007-07-08 11:54   ` [PATCH 03/20] KVM: Adds support for in-kernel mmio handlers Avi Kivity
2007-07-08 11:54   ` [PATCH 04/20] KVM: VMX: Fix interrupt checking on lightweight exit Avi Kivity
2007-07-08 11:54   ` [PATCH 05/20] KVM: Add support for in-kernel pio handlers Avi Kivity
2007-07-08 11:54   ` [PATCH 06/20] KVM: Fix x86 emulator writeback Avi Kivity
2007-07-08 11:54   ` [PATCH 07/20] KVM: Avoid useless memory write when possible Avi Kivity
2007-07-08 11:54   ` [PATCH 08/20] KVM: VMX: Reinitialize the real-mode tss when entering real mode Avi Kivity
2007-07-08 11:54   ` [PATCH 09/20] KVM: MMU: Fix Wrong tlb flush order Avi Kivity
     [not found]     ` <1183895689306-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-08 12:21       ` Ingo Molnar
     [not found]         ` <20070708122137.GB30226-X9Un+BFzKDI@public.gmane.org>
2007-07-08 12:42           ` Avi Kivity
2007-07-08 11:54   ` [PATCH 10/20] KVM: VMX: Remove unnecessary code in vmx_tlb_flush() Avi Kivity
2007-07-08 11:54   ` [PATCH 11/20] KVM: SVM: Reliably detect if SVM was disabled by BIOS Avi Kivity
     [not found]     ` <11838956892580-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-08 13:43       ` Roland Dreier
     [not found]         ` <aday7hr105d.fsf-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2007-07-08 13:45           ` Avi Kivity
2007-07-08 11:54   ` [PATCH 12/20] KVM: Remove kvmfs in favor of the anonymous inodes source Avi Kivity
2007-07-08 11:54   ` [PATCH 13/20] KVM: Clean up #includes Avi Kivity
2007-07-08 11:54   ` [PATCH 14/20] HOTPLUG: Add CPU_DYING notifier Avi Kivity
2007-07-08 11:54   ` [PATCH 15/20] HOTPLUG: Adapt cpuset hotplug callback to CPU_DYING Avi Kivity
2007-07-08 11:54   ` [PATCH 16/20] HOTPLUG: Adapt thermal throttle " Avi Kivity
2007-07-08 11:54   ` [PATCH 17/20] SMP: Implement on_cpu() Avi Kivity
     [not found]     ` <p73lkdqzpdm.fsf@bingen.suse.de>
     [not found]       ` <p73lkdqzpdm.fsf-KvMlXPVkKihbpigZmTR7Iw@public.gmane.org>
2007-07-09  6:46         ` Avi Kivity
     [not found]           ` <4691D9C1.4050309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-09  7:16             ` Andi Kleen
2007-07-09  9:40               ` Avi Kivity
     [not found]                 ` <46920270.3080309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-09 11:28                   ` Avi Kivity [this message]
     [not found]                     ` <46921BE9.4040801-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-09 19:24                       ` Satyam Sharma
     [not found]                         ` <a781481a0707091224s3fb1a2acr6d3ccce091480f61-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-07-10  6:03                           ` Avi Kivity
     [not found]                             ` <4693211D.4040406-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-10  9:22                               ` Satyam Sharma
2007-07-10 11:03                                 ` Avi Kivity
     [not found]                                   ` <46936766.20900-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-11  0:07                                     ` Satyam Sharma
     [not found]                                       ` <a781481a0707101707w121da1b7hc82dc0e3638e4570-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-07-11  7:26                                         ` Avi Kivity
     [not found]                                           ` <46948626.6050308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-11  7:47                                             ` Satyam Sharma
2007-07-11  9:43                                             ` gcc + kvm + 64 bit ? confused :-/ Benjamin Budts
     [not found]                                               ` <4694A63E.1050606-rJAIWvhRp0CZIoH1IeqzKA@public.gmane.org>
2007-07-11  9:47                                                 ` Avi Kivity
2007-07-11 10:54                                                 ` Andi Kleen
2007-07-08 11:54   ` [PATCH 18/20] KVM: Keep track of which cpus have virtualization enabled Avi Kivity
2007-07-08 11:54   ` [PATCH 19/20] KVM: Tune hotplug/suspend IPIs Avi Kivity
2007-07-08 11:54   ` [PATCH 20/20] KVM: Use CPU_DYING for disabling virtualization Avi Kivity

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=46921BE9.4040801@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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