From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH] x86 linux: prevent halted VCPUs from eating up CPU bandwidth Date: Tue, 30 May 2006 10:11:05 +0200 Message-ID: <447C1A39.76E4.0078.0@novell.com> References: <447B22B4.76E4.0078.0@novell.com> <73269221f5db8876639054dfebfa5617@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA0859209.1__=" Return-path: In-Reply-To: <73269221f5db8876639054dfebfa5617@cl.cam.ac.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartA0859209.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline >>> Keir Fraser 29.05.06 16:59 >>> > >On 29 May 2006, at 15:35, Jan Beulich wrote: > >> Since there was no reply to an earlier inquiry regarding this, here's >> a patch. >> >> Signed-off-by: Jan Beulich > >safe_halt() should simply be HYPERVISOR_block() -- the hypercall >implicitly reenables interrupt delivery for the calling VCPU, so no >need to call __sti() explicitly. > >halt() is a bit trickier -- given that it is executed (as far as I can >tell) only in contexts where the CPU has reached "end of life" (it's >crashed, or offlined, or shut down for some other reason) it might make >sense to define halt() as VCPUOP_down. Or, just in case it is used in >places with interrupts still enabled, where the CPU may have a future: >#define halt() (irqs_disabled() ? HYPERVISOR_vcpu_op(VCPUOP_down) : >HYPERVISOR_block()) Indeed, this was the behavior I intended, but somehow I failed to find the VCPUOP_down operation that I was looking for. Here's an updated patch. Jan --=__PartA0859209.1__= Content-Type: text/plain; name="xenlinux-x86-better-halt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xenlinux-x86-better-halt.patch" Index: head-2006-05-26/include/asm-i386/bugs.h =================================================================== --- head-2006-05-26.orig/include/asm-i386/bugs.h 2006-03-20 06:53:29.000000000 +0100 +++ head-2006-05-26/include/asm-i386/bugs.h 2006-05-26 13:55:43.000000000 +0200 @@ -92,6 +92,7 @@ static void __init check_fpu(void) static void __init check_hlt(void) { +#ifndef CONFIG_XEN printk(KERN_INFO "Checking 'hlt' instruction... "); if (!boot_cpu_data.hlt_works_ok) { printk("disabled\n"); @@ -102,6 +103,7 @@ static void __init check_hlt(void) halt(); halt(); printk("OK.\n"); +#endif } /* Index: head-2006-05-26/include/asm-i386/mach-xen/asm/hypervisor.h =================================================================== --- head-2006-05-26.orig/include/asm-i386/mach-xen/asm/hypervisor.h 2006-04-24 11:43:43.000000000 +0200 +++ head-2006-05-26/include/asm-i386/mach-xen/asm/hypervisor.h 2006-05-29 17:37:01.000000000 +0200 @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include Index: head-2006-05-26/include/asm-i386/mach-xen/asm/system.h =================================================================== --- head-2006-05-26.orig/include/asm-i386/mach-xen/asm/system.h 2006-05-29 17:21:52.000000000 +0200 +++ head-2006-05-26/include/asm-i386/mach-xen/asm/system.h 2006-05-29 17:37:31.000000000 +0200 @@ -625,8 +625,11 @@ do { \ preempt_enable_no_resched(); \ } while (0) -#define safe_halt() ((void)0) -#define halt() ((void)0) +#define safe_halt() ((void)HYPERVISOR_block()) +#define halt() ((void) \ + (HYPERVISOR_shared_info->vcpu_info[__vcpu_id].evtchn_upcall_mask \ + ? HYPERVISOR_vcpu_op(VCPUOP_down, __vcpu_id, NULL) \ + : HYPERVISOR_block())) #define __save_and_cli(x) \ do { \ Index: head-2006-05-26/include/asm-x86_64/mach-xen/asm/system.h =================================================================== --- head-2006-05-26.orig/include/asm-x86_64/mach-xen/asm/system.h 2006-05-29 17:21:52.000000000 +0200 +++ head-2006-05-26/include/asm-x86_64/mach-xen/asm/system.h 2006-05-29 17:37:46.000000000 +0200 @@ -424,8 +424,11 @@ do { \ preempt_enable_no_resched(); \ ___x; }) -#define safe_halt() ((void)0) -#define halt() ((void)0) +#define safe_halt() ((void)HYPERVISOR_block()) +#define halt() ((void) \ + (HYPERVISOR_shared_info->vcpu_info[__vcpu_id].evtchn_upcall_mask \ + ? HYPERVISOR_vcpu_op(VCPUOP_down, __vcpu_id, NULL) \ + : HYPERVISOR_block())) void cpu_idle_wait(void); --=__PartA0859209.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartA0859209.1__=--