Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753517Ab0GZGOv (ORCPT ); Mon, 26 Jul 2010 02:14:51 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:45911 "EHLO e2.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753146Ab0GZGOt (ORCPT ); Mon, 26 Jul 2010 02:14:49 -0400 Date: Mon, 26 Jul 2010 11:44:45 +0530 From: Srivatsa Vaddagiri To: avi@redhat.com Cc: Marcelo Tosatti , Gleb Natapov , linux-kernel@vger.kernel.org, npiggin@suse.de, Jeremy Fitzhardinge , kvm@vger.kernel.org, bharata@in.ibm.com, Balbir Singh , Jan Beulich Subject: [PATCH RFC 2/4] Add yield hypercall for KVM guests Message-ID: <20100726061445.GB8402@linux.vnet.ibm.com> Reply-To: vatsa@linux.vnet.ibm.com References: <20100726061150.GB21699@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100726061150.GB21699@linux.vnet.ibm.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2838 Lines: 84 Add KVM hypercall for yielding vcpu timeslice. Signed-off-by: Srivatsa Vaddagiri --- arch/x86/include/asm/kvm_para.h | 1 + arch/x86/kvm/x86.c | 7 ++++++- include/linux/kvm.h | 1 + include/linux/kvm_para.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) Index: current/arch/x86/include/asm/kvm_para.h =================================================================== --- current.orig/arch/x86/include/asm/kvm_para.h +++ current/arch/x86/include/asm/kvm_para.h @@ -16,6 +16,7 @@ #define KVM_FEATURE_CLOCKSOURCE 0 #define KVM_FEATURE_NOP_IO_DELAY 1 #define KVM_FEATURE_MMU_OP 2 +#define KVM_FEATURE_YIELD 4 /* This indicates that the new set of kvmclock msrs * are available. The use of 0x11 and 0x12 is deprecated */ Index: current/arch/x86/kvm/x86.c =================================================================== --- current.orig/arch/x86/kvm/x86.c +++ current/arch/x86/kvm/x86.c @@ -1618,6 +1618,7 @@ int kvm_dev_ioctl_check_extension(long e case KVM_CAP_PCI_SEGMENT: case KVM_CAP_DEBUGREGS: case KVM_CAP_X86_ROBUST_SINGLESTEP: + case KVM_CAP_YIELD_HYPERCALL: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -1993,7 +1994,8 @@ static void do_cpuid_ent(struct kvm_cpui entry->eax = (1 << KVM_FEATURE_CLOCKSOURCE) | (1 << KVM_FEATURE_NOP_IO_DELAY) | (1 << KVM_FEATURE_CLOCKSOURCE2) | - (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); + (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) | + (1 << KVM_FEATURE_YIELD); entry->ebx = 0; entry->ecx = 0; entry->edx = 0; @@ -4245,6 +4247,9 @@ int kvm_emulate_hypercall(struct kvm_vcp case KVM_HC_MMU_OP: r = kvm_pv_mmu_op(vcpu, a0, hc_gpa(vcpu, a1, a2), &ret); break; + case KVM_HC_YIELD: + ret = 0; + yield(); default: ret = -KVM_ENOSYS; break; Index: current/include/linux/kvm.h =================================================================== --- current.orig/include/linux/kvm.h +++ current/include/linux/kvm.h @@ -524,6 +524,7 @@ struct kvm_enable_cap { #define KVM_CAP_PPC_OSI 52 #define KVM_CAP_PPC_UNSET_IRQ 53 #define KVM_CAP_ENABLE_CAP 54 +#define KVM_CAP_YIELD_HYPERCALL 55 #ifdef KVM_CAP_IRQ_ROUTING Index: current/include/linux/kvm_para.h =================================================================== --- current.orig/include/linux/kvm_para.h +++ current/include/linux/kvm_para.h @@ -17,6 +17,7 @@ #define KVM_HC_VAPIC_POLL_IRQ 1 #define KVM_HC_MMU_OP 2 +#define KVM_HC_YIELD 3 /* * hypercalls use architecture specific -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/