From patchwork Tue Oct 31 17:02:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 10034967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C2283602B9 for ; Tue, 31 Oct 2017 17:07:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD468285D8 for ; Tue, 31 Oct 2017 17:07:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A178528AFA; Tue, 31 Oct 2017 17:07:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D526285D8 for ; Tue, 31 Oct 2017 17:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753890AbdJaRHQ (ORCPT ); Tue, 31 Oct 2017 13:07:16 -0400 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:5612 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752177AbdJaRHP (ORCPT ); Tue, 31 Oct 2017 13:07:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1509469635; x=1541005635; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=U+jn5aCFyHjwg8U9EFRl5n+RoSBA1RT9iBkG40DksRA=; b=F8F9715eXgkBu1ct1glklwa4gOKUvqyr7T6/bV2jFvzKLUAq+VeRrwlD PV7VfBR/MXfgM2bmxGTtSRPCJ+dXd+/VUDLLnJ5R0A53WIxBzAOLrRU4K jcEu9NJCmcEuSU7r+YwFzj72p4LWVkYhWhnzjMSp8grI9BadpP7icWV+r 0=; X-IronPort-AV: E=Sophos;i="5.44,324,1505779200"; d="scan'208";a="715137071" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Oct 2017 17:04:12 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id v9VH2oUn113291 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 31 Oct 2017 17:02:56 GMT Received: from EX13d09UWA001.ant.amazon.com (10.43.160.247) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Tue, 31 Oct 2017 17:02:55 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13d09UWA001.ant.amazon.com (10.43.160.247) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Tue, 31 Oct 2017 17:02:54 +0000 Received: from localhost (10.85.16.200) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1236.3 via Frontend Transport; Tue, 31 Oct 2017 17:02:54 +0000 Date: Tue, 31 Oct 2017 10:02:54 -0700 From: Eduardo Valentin To: Radim =?utf-8?B?S3LEjW3DocWZ?= CC: Eduardo Valentin , Paolo Bonzini , Jonathan Corbet , Thomas Gleixner , "Ingo Molnar" , "H. Peter Anvin" , , Peter Zijlstra , Waiman Long , , , , "Jan H . Schoenherr" , Anthony Liguori , Subject: Re: [PATCH 1/1] locking/qspinlock/x86: Avoid test-and-set when PV_DEDICATED is set Message-ID: <20171031170254.GA12738@u40b0340c692b58f6553c.ant.amazon.com> References: <1508805867-14583-1-git-send-email-eduval@amazon.com> <20171024111859.GA13316@flask> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171024111859.GA13316@flask> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Radim, On Tue, Oct 24, 2017 at 01:18:59PM +0200, Radim Krčmář wrote: > 2017-10-23 17:44-0700, Eduardo Valentin: > > Currently, the existing qspinlock implementation will fallback to > > test-and-set if the hypervisor has not set the PV_UNHALT flag. > > Where have you detected the main source of overhead with pinned VCPUs? > Makes me wonder if we couldn't improve general PV_UNHALT, This is essentially for cases of non-overcommitted vCPUs in which we want the instance vCPUs to run uninterrupted as much as possible. Here by disabling the PV_UNHALT, we avoid the accounting needed to properly do the PV_UNHALT hypercall, as the lock holder won't be preempted anyway for the 1:1 pin case. > > thanks. > > > This patch gives the opportunity to guest kernels to select > > between test-and-set and the regular queueu fair lock implementation > > based on the PV_DEDICATED KVM feature flag. When the PV_DEDICATED > > flag is not set, the code will still fall back to test-and-set, > > but when the PV_DEDICATED flag is set, the code will use > > the regular queue spinlock implementation. > > Some flag makes sense and we do want to make sure that userspaces don't > enable it in pass-through-cpuid mode. Did you mean something like: But I do not see any other KVM_FEATURE_* being enforced (e.g. PV_UNHALT). Do you mind elaborating a bit here? > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 0099e10..8ceb503 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -211,7 +211,8 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, } for (i = 0; i < cpuid->nent; i++) { vcpu->arch.cpuid_entries[i].function = cpuid_entries[i].function; - vcpu->arch.cpuid_entries[i].eax = cpuid_entries[i].eax; + vcpu->arch.cpuid_entries[i].eax = cpuid_entries[i].eax & + ~KVM_FEATURE_PV_DEDICATED; vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx;