public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
To: avi@redhat.com
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	Gleb Natapov <gleb@redhat.com>,
	linux-kernel@vger.kernel.org, npiggin@suse.de,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	kvm@vger.kernel.org, bharata@in.ibm.com,
	Balbir Singh <balbir@in.ibm.com>,
	Jan Beulich <JBeulich@novell.com>
Subject: [PATCH RFC 2/4] Add yield hypercall for KVM guests
Date: Mon, 26 Jul 2010 11:44:45 +0530	[thread overview]
Message-ID: <20100726061445.GB8402@linux.vnet.ibm.com> (raw)
In-Reply-To: <20100726061150.GB21699@linux.vnet.ibm.com>

Add KVM hypercall for yielding vcpu timeslice.

Signed-off-by: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>

---
 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

  parent reply	other threads:[~2010-07-26  6:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-26  6:11 [PATCH RFC 0/4] Paravirt-spinlock implementation for KVM guests (Version 0) Srivatsa Vaddagiri
2010-07-26  6:13 ` [PATCH RFC 1/4] Debugfs support for reading an array of u32-type integers Srivatsa Vaddagiri
2010-07-26  6:14 ` Srivatsa Vaddagiri [this message]
2010-07-26 17:19   ` [PATCH RFC 2/4] Add yield hypercall for KVM guests Jeremy Fitzhardinge
2010-07-28 14:55     ` Srivatsa Vaddagiri
2010-08-02  8:40       ` Avi Kivity
2010-08-03  5:16         ` Srivatsa Vaddagiri
2010-08-03  5:33           ` Srivatsa Vaddagiri
2010-08-02  8:32     ` Avi Kivity
2010-08-02 14:42       ` Ryan Harper
2010-08-02 14:50         ` Avi Kivity
2010-08-02 15:08       ` Jeremy Fitzhardinge
2010-07-26  6:15 ` [PATCH RFC 3/4] Paravirtualized spinlock implementation " Srivatsa Vaddagiri
2010-08-02  8:48   ` Avi Kivity
2010-08-02 15:20     ` Jeremy Fitzhardinge
2010-08-03  6:59       ` Avi Kivity
2010-08-03 17:47         ` Jeremy Fitzhardinge
2010-08-02  8:53   ` Avi Kivity
2010-07-26  6:16 ` [PATCH RFC 4/4] Add yield hypercall support in Qemu Srivatsa Vaddagiri
2010-07-26 17:18 ` [PATCH RFC 0/4] Paravirt-spinlock implementation for KVM guests (Version 0) Jeremy Fitzhardinge
2010-07-28 14:47   ` Srivatsa Vaddagiri
2010-07-28 22:10 ` Konrad Rzeszutek Wilk
2010-07-28 22:42   ` Konrad Rzeszutek Wilk
2010-08-02  8:50 ` 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=20100726061445.GB8402@linux.vnet.ibm.com \
    --to=vatsa@linux.vnet.ibm.com \
    --cc=JBeulich@novell.com \
    --cc=avi@redhat.com \
    --cc=balbir@in.ibm.com \
    --cc=bharata@in.ibm.com \
    --cc=gleb@redhat.com \
    --cc=jeremy@goop.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=npiggin@suse.de \
    /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