Received: by 10.223.185.116 with SMTP id b49csp2074221wrg; Mon, 12 Feb 2018 03:59:20 -0800 (PST) X-Google-Smtp-Source: AH8x225ozhJzMHPu4pp775/Zu4tUebnQkRkqNbCQCCfU0E2Z5pPtzUGuWxi21DNo6JDJwjJrUdLl X-Received: by 2002:a17:902:71cb:: with SMTP id t11-v6mr10712559plm.229.1518436760391; Mon, 12 Feb 2018 03:59:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518436760; cv=none; d=google.com; s=arc-20160816; b=Mx6Z+/fS9o97bGs7fSTuoqavxIZwXhJpAmv/lVwmc1FwwMVDyQoA0lwn8onFr4XoVy 2MFYlEmbnsprjPvYU//YB7ByliLd+rAoKZiYPdSViWrpHvRvi/tsrGcXra+2Qwets2CZ 8Zj6iFOm+Xz+2iy1ENOcamHmGqMkxTWWFB5R9p6lg++QHGl6M/F2MRqjeLQQfhCJt39L TROtKJ53o2Hlqf+Rhdo+KaBAotOuMedp7Q+yUBE8hOR8AJxCWPDenu+K628scsL308DA fweEyb0gFy7+E5nP5zlHOSeQ6S0z9QBEvysqrWTsjKy1M9OMSWB1GA7JsT/dNO94q5pr LVkw== 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=KugYTxHTrwG78dbzKd9aky/X5XZL2CqKLab0Mskz0BU=; b=wj+K/s8d3lJX/how5arm2mb4lURjS5AbStAusqUZJ773jmHSCrRxhfHygnfW1bhY0Q lSXz8To7y1xXhfNAcXS2W5eAAAtYeeaDaVQJkwS18kSc6sSJ9/8vlnPUEBrjLSq46sms qoYEDINoW/Je2j0JJVCvhXL1zL/POhz2qEvk9slcLhBWiV6lzy2ik2Tc4pTfA6GBky4u Kjp+7svC52RnmMtRwqcwV6LH2jA9eQRhYX08/RlD8fG6rJgiOb3Vf0voUNGtX6afO5TM ixPWOyAKItL13icOzcMEvCO0K/SgK8YvWjUfBQcerXBR/BmQquUTQr9fCMn8pYptHDSX B4zA== 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 v26si453394pgn.30.2018.02.12.03.59.06; Mon, 12 Feb 2018 03:59:20 -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 S1753879AbeBLJiz (ORCPT + 99 others); Mon, 12 Feb 2018 04:38:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58578 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753849AbeBLJix (ORCPT ); Mon, 12 Feb 2018 04:38:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4FE08182D17; Mon, 12 Feb 2018 09:38:52 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D1EB10FFE73; Mon, 12 Feb 2018 09:38:51 +0000 (UTC) Date: Mon, 12 Feb 2018 10:38:49 +0100 From: Andrew Jones To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Eduardo Habkost Subject: Re: [PATCH v3 1/3] KVM: Introduce dedicated vCPUs hint KVM_HINTS_DEDICATED Message-ID: <20180212093849.e6ahdj62boz5r65v@kamzik.brq.redhat.com> References: <1518319786-1466-1-git-send-email-wanpengli@tencent.com> <1518319786-1466-2-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: <1518319786-1466-2-git-send-email-wanpengli@tencent.com> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Feb 2018 09:38:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Feb 2018 09:38:52 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 11, 2018 at 11:29:44AM +0800, Wanpeng Li wrote: > From: Wanpeng Li > > This patch introduces dedicated vCPUs hint KVM_HINTS_DEDICATED, > guest checks this feature bit to determine if they run on dedicated > vCPUs, allowing optimizations. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Eduardo Habkost > Signed-off-by: Wanpeng Li > --- > Documentation/virtual/kvm/cpuid.txt | 12 +++++++++++- > arch/mips/include/asm/kvm_para.h | 5 +++++ > arch/powerpc/include/asm/kvm_para.h | 5 +++++ > arch/s390/include/asm/kvm_para.h | 5 +++++ > arch/x86/include/asm/kvm_para.h | 6 ++++++ > arch/x86/include/uapi/asm/kvm_para.h | 8 ++++++-- > arch/x86/kernel/kvm.c | 5 +++++ > include/asm-generic/kvm_para.h | 5 +++++ > include/linux/kvm_para.h | 5 +++++ > 9 files changed, 53 insertions(+), 3 deletions(-) > > diff --git a/Documentation/virtual/kvm/cpuid.txt b/Documentation/virtual/kvm/cpuid.txt > index dcab6dc..e283b88 100644 > --- a/Documentation/virtual/kvm/cpuid.txt > +++ b/Documentation/virtual/kvm/cpuid.txt > @@ -23,7 +23,7 @@ This function queries the presence of KVM cpuid leafs. > > > function: define KVM_CPUID_FEATURES (0x40000001) > -returns : ebx, ecx, edx = 0 > +returns : ebx, ecx > eax = and OR'ed group of (1 << flag), where each flags is: Now that the above line is getting repeated, we should fix it: s/and/an/ > > > @@ -62,3 +62,13 @@ KVM_FEATURE_CLOCKSOURCE_STABLE_BIT || 24 || host will warn if no guest-side > || || per-cpu warps are expected in > || || kvmclock. > ------------------------------------------------------------------------------ > + > + edx = and OR'ed group of (1 << flag), where each flags is: And then copy the corrected version here. Thanks, drew > + > + > +flag || value || meaning > +================================================================================ > +KVM_HINTS_DEDICATED || 0 || guest checks this feature bit > + || || to determine if they run on dedicated > + || || vCPUs, allowing optimizations > +--------------------------------------------------------------------------------- > diff --git a/arch/mips/include/asm/kvm_para.h b/arch/mips/include/asm/kvm_para.h > index 60b1aa0..bd1f4ee 100644 > --- a/arch/mips/include/asm/kvm_para.h > +++ b/arch/mips/include/asm/kvm_para.h > @@ -94,6 +94,11 @@ static inline unsigned int kvm_arch_para_features(void) > return 0; > } > > +static inline unsigned int kvm_arch_hint_features(void) > +{ > + return 0; > +} > + > #ifdef CONFIG_MIPS_PARAVIRT > static inline bool kvm_para_available(void) > { > diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h > index 336a91a..8e58c00 100644 > --- a/arch/powerpc/include/asm/kvm_para.h > +++ b/arch/powerpc/include/asm/kvm_para.h > @@ -61,6 +61,11 @@ static inline unsigned int kvm_arch_para_features(void) > return r; > } > > +static inline unsigned int kvm_arch_hint_features(void) > +{ > + return 0; > +} > + > static inline bool kvm_check_and_clear_guest_paused(void) > { > return false; > diff --git a/arch/s390/include/asm/kvm_para.h b/arch/s390/include/asm/kvm_para.h > index 74eeec9..b2c935c 100644 > --- a/arch/s390/include/asm/kvm_para.h > +++ b/arch/s390/include/asm/kvm_para.h > @@ -193,6 +193,11 @@ static inline unsigned int kvm_arch_para_features(void) > return 0; > } > > +static inline unsigned int kvm_arch_hint_features(void) > +{ > + return 0; > +} > + > static inline bool kvm_check_and_clear_guest_paused(void) > { > return false; > diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h > index 7b407dd..2c7d368 100644 > --- a/arch/x86/include/asm/kvm_para.h > +++ b/arch/x86/include/asm/kvm_para.h > @@ -88,6 +88,7 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1, > #ifdef CONFIG_KVM_GUEST > bool kvm_para_available(void); > unsigned int kvm_arch_para_features(void); > +unsigned int kvm_arch_hint_features(void); > void kvm_async_pf_task_wait(u32 token, int interrupt_kernel); > void kvm_async_pf_task_wake(u32 token); > u32 kvm_read_and_reset_pf_reason(void); > @@ -115,6 +116,11 @@ static inline unsigned int kvm_arch_para_features(void) > return 0; > } > > +static inline unsigned int kvm_arch_hint_features(void) > +{ > + return 0; > +} > + > static inline u32 kvm_read_and_reset_pf_reason(void) > { > return 0; > diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h > index 7a2ade4..e8f5dfb 100644 > --- a/arch/x86/include/uapi/asm/kvm_para.h > +++ b/arch/x86/include/uapi/asm/kvm_para.h > @@ -10,8 +10,10 @@ > */ > #define KVM_CPUID_SIGNATURE 0x40000000 > > -/* This CPUID returns a feature bitmap in eax. Before enabling a particular > - * paravirtualization, the appropriate feature bit should be checked. > +/* This CPUID returns two feature bitmaps in eax, edx. Before enabling > + * a particular paravirtualization, the appropriate feature bit should > + * be checked in eax. The performance hint feature bit should be checked > + * in edx. > */ > #define KVM_CPUID_FEATURES 0x40000001 > #define KVM_FEATURE_CLOCKSOURCE 0 > @@ -27,6 +29,8 @@ > #define KVM_FEATURE_PV_UNHALT 7 > #define KVM_FEATURE_PV_TLB_FLUSH 9 > > +#define KVM_HINTS_DEDICATED 0 > + > /* The last 8 bits are used to indicate how to interpret the flags field > * in pvclock structure. If no bits are set, all flags are ignored. > */ > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 4e37d1a..77a0723 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -604,6 +604,11 @@ unsigned int kvm_arch_para_features(void) > return cpuid_eax(kvm_cpuid_base() | KVM_CPUID_FEATURES); > } > > +unsigned int kvm_arch_hint_features(void) > +{ > + return cpuid_edx(kvm_cpuid_base() | KVM_CPUID_FEATURES); > +} > + > static uint32_t __init kvm_detect(void) > { > return kvm_cpuid_base(); > diff --git a/include/asm-generic/kvm_para.h b/include/asm-generic/kvm_para.h > index 18c6abe..93e133d 100644 > --- a/include/asm-generic/kvm_para.h > +++ b/include/asm-generic/kvm_para.h > @@ -19,6 +19,11 @@ static inline unsigned int kvm_arch_para_features(void) > return 0; > } > > +static inline unsigned int kvm_arch_hint_features(void) > +{ > + return 0; > +} > + > static inline bool kvm_para_available(void) > { > return false; > diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h > index 51f6ef2..30503b7 100644 > --- a/include/linux/kvm_para.h > +++ b/include/linux/kvm_para.h > @@ -9,4 +9,9 @@ static inline bool kvm_para_has_feature(unsigned int feature) > { > return !!(kvm_arch_para_features() & (1UL << feature)); > } > + > +static inline bool kvm_hint_has_feature(unsigned int feature) > +{ > + return !!(kvm_arch_hint_features() & (1UL << feature)); > +} > #endif /* __LINUX_KVM_PARA_H */ > -- > 2.7.4 >