Received: by 10.223.185.111 with SMTP id b44csp363051wrg; Fri, 9 Mar 2018 06:18:08 -0800 (PST) X-Google-Smtp-Source: AG47ELvuFlf/uFMnFODZXIkNL9fBLBSC1Vr9qVYexDhri3ZrdZ0BHbipADyxRTiBhaq3QRuyVK2v X-Received: by 2002:a17:902:529:: with SMTP id 38-v6mr27414010plf.327.1520605088520; Fri, 09 Mar 2018 06:18:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520605088; cv=none; d=google.com; s=arc-20160816; b=NlXy7DTDVERiHR/zygOIQ2s2IPtulFipzAeysVqi8ukgHuilDW9S7oHuuInq85PMu1 czUpcP77pAbeVHIxuffZ2kVHwd0uqiK3vg7TG+NWRDtOMefP2YCYyU/RaVyNI5vCQRAB 9gT3eJt/sYG/+mxlRa8EeeFYzl1Nm6ecWcz1cJ9J2BSVSTs1Yr1A2c6qgphdIbO2Cn5m 2oHA6b9EEA/dEW6A04hocdcLsElsyBjgltv5/aZHm6f0WiLiDbfN73G9NmmkGIpHJ3Oo 2Ps5/qubIgjcaCryI8iiSsuTkowPxanr5C5e47NVAvhJN8glI/13vQ4m7wUb+yG9l1kD 5MHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=Dxk4QmGCDl+6NVBRRzc20i9d0Ta1w9Tg1a8aNIGfIHI=; b=EI6cVguQ0SRRV3okqdi7FGYWI6n9/kJ0I+YvEe2U9N+EBXH+R0nWZeZyby1di9AggZ Jgv+9zF1LA6OBA/8eMLrDi5KGZfy/gSs2r6nLgsepO6wYzVl72nM4A1KxNtts1rjRywi pJOkIvDHL76ZZ231Hd5YQGv7QNQzUkeJNPNYqje7y33Ay+XhBX+CRJDzn0CphmtUrrV6 OPMf/732Z21RT7IC7+/xq9LN+g8/zFUH7GYrvMNbnts7/N6YKYpsUhlR9tJiqDNHIvqo 0aXC5Ymn1M6/VHaSX0+UnmyIhUkBX/umgTY5iD++1BoTVU9sQZ19OuKrX/Mu0PNV3CeP PGRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6-v6si960235plo.525.2018.03.09.06.17.53; Fri, 09 Mar 2018 06:18:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932067AbeCIOQ7 (ORCPT + 99 others); Fri, 9 Mar 2018 09:16:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58102 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751068AbeCIOQ4 (ORCPT ); Fri, 9 Mar 2018 09:16:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 544092BBE15; Fri, 9 Mar 2018 14:16:56 +0000 (UTC) Received: from localhost (ovpn-116-64.gru2.redhat.com [10.97.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4835578A17; Fri, 9 Mar 2018 14:16:55 +0000 (UTC) Date: Fri, 9 Mar 2018 11:16:53 -0300 From: Eduardo Habkost To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Peter Zijlstra Subject: Re: [PATCH v2] target-i386: add KVM_HINTS_DEDICATED performance hint Message-ID: <20180309141653.GA2871@localhost.localdomain> References: <1518185725-69559-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1518185725-69559-1-git-send-email-wanpengli@tencent.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.9.2 (2017-12-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 09 Mar 2018 14:16:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 09, 2018 at 06:15:25AM -0800, Wanpeng Li wrote: > From: Wanpeng Li > > Add KVM_HINTS_DEDICATED performance hint, guest checks this feature bit > to determine if they run on dedicated vCPUs, allowing optimizations such > as usage of qspinlocks. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Eduardo Habkost > Signed-off-by: Wanpeng Li > --- > v1 -> v2: > * add a new feature word > > target/i386/cpu.c | 14 ++++++++++++++ > target/i386/cpu.h | 3 +++ > target/i386/kvm.c | 4 ++++ > 3 files changed, 21 insertions(+) > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index d70954b..e2974ad 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -358,6 +358,20 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { > .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX, > .tcg_features = TCG_KVM_FEATURES, > }, > + [FEAT_KVM_HINTS] = { > + .feat_names = { > + "hint-dedicated", NULL, NULL, NULL, I suggest naming it "kvm-hint-dedicated", to indicate it's KVM-specific. If there are no objections, I can rename it while applying. With the rename: Reviewed-by: Eduardo Habkost > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL, NULL, > + }, > + .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EDX, > + .tcg_features = TCG_KVM_FEATURES, > + }, > [FEAT_HYPERV_EAX] = { > .feat_names = { > NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_refcount_access */, > diff --git a/target/i386/cpu.h b/target/i386/cpu.h > index f91e37d..9f73692 100644 > --- a/target/i386/cpu.h > +++ b/target/i386/cpu.h > @@ -475,6 +475,7 @@ typedef enum FeatureWord { > FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ > FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ > FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ > + FEAT_KVM_HINTS, /* CPUID[4000_0001].EDX */ > FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */ > FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */ > FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ > @@ -670,6 +671,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; > #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */ > #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Speculation Control */ > > +#define KVM_HINTS_DEDICATED (1U << 0) > + > #define CPUID_8000_0008_EBX_IBPB (1U << 12) /* Indirect Branch Prediction Barrier */ > > #define CPUID_XSAVE_XSAVEOPT (1U << 0) > diff --git a/target/i386/kvm.c b/target/i386/kvm.c > index ad4b159..44ee524 100644 > --- a/target/i386/kvm.c > +++ b/target/i386/kvm.c > @@ -383,6 +383,9 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, > if (!kvm_irqchip_in_kernel()) { > ret &= ~(1U << KVM_FEATURE_PV_UNHALT); > } > + } else if (function == KVM_CPUID_FEATURES && reg == R_EDX) { > + ret |= KVM_HINTS_DEDICATED; > + found = 1; > } > > /* fallback for older kernels */ > @@ -801,6 +804,7 @@ int kvm_arch_init_vcpu(CPUState *cs) > c = &cpuid_data.entries[cpuid_i++]; > c->function = KVM_CPUID_FEATURES | kvm_base; > c->eax = env->features[FEAT_KVM]; > + c->edx = env->features[FEAT_KVM_HINTS]; > } > > cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); > -- > 2.7.4 > -- Eduardo