Received: by 10.213.65.68 with SMTP id h4csp3646391imn; Tue, 10 Apr 2018 02:17:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mGEgbFR+yGxPUNn+3A58Nna9tbHt3UrOZnifIFjraJh/5QIPf8ztTFKS0IZXKoKEaHzrb X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr32483850plb.36.1523351832435; Tue, 10 Apr 2018 02:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523351832; cv=none; d=google.com; s=arc-20160816; b=pJ5S+L7a2Spu8OuMr64EWUuRVMnDemjyPcINoVpzwpbRZITJmI6Wolbe5Xn9i2ML/s FGU9M20fb1rOWc71z/aFVZrfc6PsjC9Fyns4XtkPJbKCKLoq6mkuFdJg5cGt7t3TbO9X Y5ND6ubfwPmy6Lzaak5Cxgl3iCVuB4p3sFzofGKG8RCz/UawmJrqvDrWYBSd6taeYliR 13PqeZEloJD9EsmLIMzXirluBf8PZCR8RMtyS4EGqbfkltdR81+gFzPAUj4z2sv32RU1 4xXRdsIJJZXj/5H7E5HpugsqTYpOMt6XdEskwaL9aMoVkMN6smR6c0t2KOHiTBQ2QkTV Gf9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=nj9NFk5hNiJHStHZIrUGAq1r3xm/S1v2YLe+9gy+Mk0=; b=HY2weqOMWBzyjmf5VQXvlI4X6Tz57tb0Q29BNqKeoo2pGO+xftI4kyZCJu8x7pizbz q7bxfJHrebu5UeVhU/HgqCS6MUQyv03gJiFIGxG+wMaLoyzKpS+ojsEWcwHrS5oxvrdu lV0o15kiuuowdtlJ3lVrIPYDWRGAzASEdjbHu345J1mH7YuYnbX/9xzOzuHrtgMbF7KI QMBz5ndPU/fDgMg9V6w58LPt0/Yr2RaSMqQh+xI8652LEhHWRGJEPxIaumHAqCSanoU/ Uav1S2xY9+tMvs+sieK45yC9WeHTPQAnfJIDWEY3zSrpspBtG3sXPAKC5jFhCjzhVK+v 5Geg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K/LGsuy7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg3-v6si2115021plb.118.2018.04.10.02.16.35; Tue, 10 Apr 2018 02:17:12 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K/LGsuy7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbeDJJNY (ORCPT + 99 others); Tue, 10 Apr 2018 05:13:24 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:45516 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbeDJJNW (ORCPT ); Tue, 10 Apr 2018 05:13:22 -0400 Received: by mail-oi0-f67.google.com with SMTP id 71-v6so10459803oie.12; Tue, 10 Apr 2018 02:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=nj9NFk5hNiJHStHZIrUGAq1r3xm/S1v2YLe+9gy+Mk0=; b=K/LGsuy7QBVbWXK3J1XDK1kfus6GBDSwdfE1c+pv2KsWwNYnVwrlqROQ6ZJAIZRkFM 4hiILynQdoZEIGzR3qVn/JKQLqGB+yZaq8DC4Psv7T3ttSs0h+1oyhkVK9l3MIVk3pF/ tuNo0hl9AyIT9/XdkRFpiZAk1qgEMJFkNMqDak1Wu5iAq40o/epjb9maunyC1rF2yUUN 7jbyby+VhUm9U2mYXgyamqO1svLFZJGSyxv3bhy0gmVUhwK9TUgjQl1QhA+CzQB0Up2t 2tyIZwPlaWNm9n9M6ul1UvTH1MCyBbnikZSJnu/SI2H9guHa0Ssrer0P2fLQRsz1Ij3U nyTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=nj9NFk5hNiJHStHZIrUGAq1r3xm/S1v2YLe+9gy+Mk0=; b=XS4g82lBR+zctqC1zOf14r1s4RNMkHFEDfyHF94vs5VyEYMX9Njwg8Z8Dyhe97Pikm LAtm1TubD6asNRHHUjzUl0AWGYlnmMMV+0JtTZGO1h7t0sjlchKlTiI+8IG3ngi4JlFL Yh/eAlOSOpgL+pP9mA9Arr7LjLjMm2wJrXn2Rza+eA2djntdAZXny+MLiAk9VtGsUHsD 5MXLSU99d0m8JUUKoaxq0pXaH4ZJG9kdd/s+YJkQqcOXcib83ADwJ8PxoPcm+QNeYpmR Mm7FaZtJ9Pyw+hzuku8PkLVWfxlL9zl/aLPKEwOu85M0rxUXBl8JamD14GC/bn3ak1gY Z9eg== X-Gm-Message-State: ALQs6tCfFNLMbIxZ2x5jCBJ9eU8yl3PWBgcXyGUBZPgvHiMQDU/JN7TI R8Jk89dEeaAt+xP7oki0Cl60fS/1DAT98/HnU4w= X-Received: by 2002:aca:2804:: with SMTP id 4-v6mr1507789oix.74.1523351601573; Tue, 10 Apr 2018 02:13:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.210.78 with HTTP; Tue, 10 Apr 2018 02:13:21 -0700 (PDT) In-Reply-To: <20180309141653.GA2871@localhost.localdomain> References: <1518185725-69559-1-git-send-email-wanpengli@tencent.com> <20180309141653.GA2871@localhost.localdomain> From: Wanpeng Li Date: Tue, 10 Apr 2018 17:13:21 +0800 Message-ID: Subject: Re: [PATCH v2] target-i386: add KVM_HINTS_DEDICATED performance hint To: Eduardo Habkost Cc: LKML , kvm , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eduardo, 2018-03-09 22:16 GMT+08:00 Eduardo Habkost : > 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=C4=8Dm=C3=A1=C5=99 >> 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_WO= RDS] =3D { >> .cpuid_eax =3D KVM_CPUID_FEATURES, .cpuid_reg =3D R_EAX, >> .tcg_features =3D TCG_KVM_FEATURES, >> }, >> + [FEAT_KVM_HINTS] =3D { >> + .feat_names =3D { >> + "hint-dedicated", NULL, NULL, NULL, > > I suggest naming it "kvm-hint-dedicated", to indicate it's > KVM-specific. I found this feature is enabled by default w/o kvm-hint-dedicated parameter, any idea how to make it disabled by default? Regards, Wanpeng Li > > 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 =3D KVM_CPUID_FEATURES, .cpuid_reg =3D R_EDX, >> + .tcg_features =3D TCG_KVM_FEATURES, >> + }, >> [FEAT_HYPERV_EAX] =3D { >> .feat_names =3D { >> NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_re= fcount_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 Accumu= lation 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 Predi= ction 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, u= int32_t function, >> if (!kvm_irqchip_in_kernel()) { >> ret &=3D ~(1U << KVM_FEATURE_PV_UNHALT); >> } >> + } else if (function =3D=3D KVM_CPUID_FEATURES && reg =3D=3D R_EDX) = { >> + ret |=3D KVM_HINTS_DEDICATED; >> + found =3D 1; >> } >> >> /* fallback for older kernels */ >> @@ -801,6 +804,7 @@ int kvm_arch_init_vcpu(CPUState *cs) >> c =3D &cpuid_data.entries[cpuid_i++]; >> c->function =3D KVM_CPUID_FEATURES | kvm_base; >> c->eax =3D env->features[FEAT_KVM]; >> + c->edx =3D env->features[FEAT_KVM_HINTS]; >> } >> >> cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); >> -- >> 2.7.4 >> > > -- > Eduardo