From patchwork Tue Jul 10 19:31:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra K T X-Patchwork-Id: 1178791 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 695ED40CDC for ; Tue, 10 Jul 2012 19:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425Ab2GJTd2 (ORCPT ); Tue, 10 Jul 2012 15:33:28 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:60263 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323Ab2GJTdZ (ORCPT ); Tue, 10 Jul 2012 15:33:25 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jul 2012 19:23:44 +1000 Received: from d23relay03.au.ibm.com (202.81.31.245) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Jul 2012 19:23:41 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6AJXJFl29229078; Wed, 11 Jul 2012 05:33:19 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6AJXIh1017492; Wed, 11 Jul 2012 05:33:19 +1000 Received: from [192.168.1.3] ([9.77.201.80]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6AJX8Io017410; Wed, 11 Jul 2012 05:33:11 +1000 From: Raghavendra K T To: "H. Peter Anvin" , Thomas Gleixner , Avi Kivity , Ingo Molnar , Marcelo Tosatti , Rik van Riel Cc: S390 , Carsten Otte , Christian Borntraeger , KVM , Raghavendra K T , chegu vinod , "Andrew M. Theurer" , LKML , X86 , Gleb Natapov , linux390@de.ibm.com, Srivatsa Vaddagiri , Joerg Roedel Date: Wed, 11 Jul 2012 01:01:18 +0530 Message-Id: <20120710193117.16440.42745.sendpatchset@codeblue> In-Reply-To: <20120710193056.16440.40112.sendpatchset@codeblue> References: <20120710193056.16440.40112.sendpatchset@codeblue> Subject: [PATCH RFC V2 1/2] kvm vcpu: Note down pause loop exit x-cbid: 12071009-0260-0000-0000-0000017CEA1D Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Raghavendra K T Noting pause loop exited vcpu helps in filtering right candidate to yield. Yielding to same vcpu may result in more wastage of cpu. Signed-off-by: Raghavendra K T Reviewed-by: Rik van Riel --- arch/x86/include/asm/kvm_host.h | 11 +++++++++++ arch/x86/kvm/svm.c | 1 + arch/x86/kvm/vmx.c | 1 + arch/x86/kvm/x86.c | 4 +++- 4 files changed, 16 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index db7c1f2..386f3e6 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -484,6 +484,17 @@ struct kvm_vcpu_arch { u64 length; u64 status; } osvw; + + /* + * Pause loop exit optimization + * pause_loop_exited: set when a vcpu does a pause loop exit. + * dy_eligible: indicates whether vcpu is eligible for directed yield. + */ + struct { + bool pause_loop_exited; + bool dy_eligible; + } ple; + }; struct kvm_lpage_info { diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f75af40..2b4b4ee 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3264,6 +3264,7 @@ static int interrupt_window_interception(struct vcpu_svm *svm) static int pause_interception(struct vcpu_svm *svm) { + svm->vcpu.arch.ple.pause_loop_exited = true; kvm_vcpu_on_spin(&(svm->vcpu)); return 1; } diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 32eb588..14aa67a 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4945,6 +4945,7 @@ out: static int handle_pause(struct kvm_vcpu *vcpu) { skip_emulated_instruction(vcpu); + vcpu->arch.ple.pause_loop_exited = true; kvm_vcpu_on_spin(vcpu); return 1; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index be6d549..b30c310 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5331,7 +5331,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) if (req_immediate_exit) smp_send_reschedule(vcpu->cpu); - + vcpu->arch.ple.pause_loop_exited = false; kvm_guest_enter(); if (unlikely(vcpu->arch.switch_db_regs)) { @@ -6168,6 +6168,8 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) BUG_ON(vcpu->kvm == NULL); kvm = vcpu->kvm; + vcpu->arch.ple.pause_loop_exited = false; + vcpu->arch.ple.dy_eligible = false; vcpu->arch.emulate_ctxt.ops = &emulate_ops; if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu)) vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;