From patchwork Thu Jul 12 19:18:01 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: 1190361 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 4BC8340B20 for ; Thu, 12 Jul 2012 19:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757860Ab2GLTUT (ORCPT ); Thu, 12 Jul 2012 15:20:19 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:38279 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755843Ab2GLTUN (ORCPT ); Thu, 12 Jul 2012 15:20:13 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jul 2012 19:13:26 +1000 Received: from d23relay04.au.ibm.com (202.81.31.246) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Jul 2012 19:13:22 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6CJCDNa63832286; Fri, 13 Jul 2012 05:12:13 +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 q6CJK5mU018393; Fri, 13 Jul 2012 05:20:07 +1000 Received: from [192.168.1.3] ([9.124.212.243]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6CJJt9n018178; Fri, 13 Jul 2012 05:19:58 +1000 From: Raghavendra K T To: "H. Peter Anvin" , Thomas Gleixner , Marcelo Tosatti , Ingo Molnar , Avi Kivity , 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: Fri, 13 Jul 2012 00:48:01 +0530 Message-Id: <20120712191800.30440.16406.sendpatchset@codeblue> In-Reply-To: <20120712191712.30440.68944.sendpatchset@codeblue> References: <20120712191712.30440.68944.sendpatchset@codeblue> Subject: [PATCH RFC V3 2/3] kvm: Note down when cpu relax intercepted or pause loop exited x-cbid: 12071209-7014-0000-0000-0000018CD8DC 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 or cpu relax intercepted vcpu helps in filtering right candidate to yield. Wrong selection of vcpu; i.e., a vcpu that just did a pl-exit or cpu relax intercepted may contribute to performance degradation. Signed-off-by: Raghavendra K T --- v2 patches were Reviewed-by: Rik van Riel include/linux/kvm_host.h | 12 ++++++++++++ virt/kvm/kvm_main.c | 4 ++++ 2 files changed, 16 insertions(+), 0 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/include/linux/kvm_host.h b/include/linux/kvm_host.h index c446435..4ec1cf0 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -183,6 +183,18 @@ struct kvm_vcpu { } async_pf; #endif +#ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT + /* + * Cpu relax intercept or pause loop exit optimization + * cpu_relax_intercepted: set when a vcpu does a pause loop exit + * or cpu relax intercepted. + * dy_eligible: indicates whether vcpu is eligible for directed yield. + */ + struct { + bool cpu_relax_intercepted; + bool dy_eligible; + } ple; +#endif struct kvm_vcpu_arch arch; }; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 7e14068..4ec0120 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -235,6 +235,8 @@ int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id) goto fail; } vcpu->run = page_address(page); + vcpu->ple.cpu_relax_intercepted = false; + vcpu->ple.dy_eligible = false; r = kvm_arch_vcpu_init(vcpu); if (r < 0) @@ -1577,6 +1579,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me) int pass; int i; + me->ple.cpu_relax_intercepted = true; /* * We boost the priority of a VCPU that is runnable but not * currently running, because it got preempted by something @@ -1602,6 +1605,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me) } } } + me->ple.cpu_relax_intercepted = false; } EXPORT_SYMBOL_GPL(kvm_vcpu_on_spin);