Received: by 10.223.185.82 with SMTP id b18csp32371wrg; Thu, 8 Mar 2018 18:36:06 -0800 (PST) X-Google-Smtp-Source: AG47ELtAmUeDy1xfmDZ7kHhWQgPtKvEKa3L6yxP73V/4FhkSDSwFRprZZaMT70wX0Uw12o0L7GqX X-Received: by 10.98.165.4 with SMTP id v4mr23513508pfm.51.1520562966120; Thu, 08 Mar 2018 18:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520562966; cv=none; d=google.com; s=arc-20160816; b=cn8OFabcaoN7G/ZPuKpm5I6ty9ajmAMEU2zMbYv2CIAE+WsShChy5eRP7k3AP4N4EH FEUxKNyQjxKjj/VmT3Nu7Y3lmFMPgoXno0arjXG7AyQVKG24i9/8ZvW5gzkByV411ngY 8pSteegL+txkI7G/wxgAAoZGcFR6jjvYybGPiONtCc6XfwGG9txcP/q9IvIBxpRGx37o uzAPLVzJ88UszQoHd+Ds1EVZ3+YACiNypLAwCC4wGr6YJ2FFZa3cO2Q9Ne08Vj7py8OF 68RnHhNzAh68hfv0oq+/iArl7nsQ5SekQMnjvcg6nGTpClbzlxa47bks43rKvDnx3pBc dW3g== 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=a4pFwSGHjKNBqC+wp4maUMOKUYRJAvF2q68DvyTpd5s=; b=qJKLfuGL0aKDaROmY2ZhvTstm70a2jEmUUXhmb0lcnA2rb0fYTeJUeOMTjSQI/z4Oj 5lddiU+4U2Yo9yFTJ45l9wWK3mdF5Y1wqwbsLnR3qEHaJxz7cdDwZmG8ZpVKdrlB9AfC 9wS+gZvloBG6hT8aD4GLKpO2y7uL79kkKQ6QOLpzSLcjcLH/O62G65cYvYfUwMAcVGdm 8CbHi4tGQblLXJD919qeIkyQ3U6xs1v18vVJE2YcFQqnVmw8W15nyT+PIjnH3Ss9yyJt Lo86FTiKyGUqIzmLfg/3VvuoTYn0dmnQL6PzSNzOiPIvaOFRWzAbU0wIo9aze0KdMHAv 0Pkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YQGOH40g; 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 h186si1008pge.814.2018.03.08.18.35.51; Thu, 08 Mar 2018 18:36:06 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YQGOH40g; 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 S1750917AbeCICe7 (ORCPT + 99 others); Thu, 8 Mar 2018 21:34:59 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34904 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbeCICe5 (ORCPT ); Thu, 8 Mar 2018 21:34:57 -0500 Received: by mail-oi0-f67.google.com with SMTP id x10so5966890oig.2; Thu, 08 Mar 2018 18:34:57 -0800 (PST) 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=a4pFwSGHjKNBqC+wp4maUMOKUYRJAvF2q68DvyTpd5s=; b=YQGOH40gHat+a92XMBboWBgT85m5myOkjdFqAr5irA1Sj632LxcolYgQ0qAILL4wfj JqO5LXm/asnAFnql9++PnILUensnKTkTc8eg6avcGQFipAv5NoIfN9arZGWZ/atRRmv/ lKfHAxPXlhjVzhvBXyGSPHBgPtD7N6dCCdgeaFoMp4qo2DTLJ5dfFoQjuQR68puqiJEi 2uwF0sQ0u7VGWpam/7F0Ja0AuA1X/es7xdYS2VbAf5HkE/GxIIs1tIFq0rVXscJEMfZb xYDvlfTQKmxq6NM/4u+QBptOGo1O77dJlyRLznlf4AosVQ1KJJMvwjl/Qs4MVLRU+v7K yInA== 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=a4pFwSGHjKNBqC+wp4maUMOKUYRJAvF2q68DvyTpd5s=; b=Cvi/+rfnqwei7VFSgkEvCzt/L0rlAGQ5D0hEOCHRpArWbImeOW61Q+i8Qe5H2yjkPj dx7+j2TBF/tMPjDhlyhJYi6wE4V/dcLCTmt5x9CNvQV5mWukmsS94SXGWde8cJ9KI39p YG2M10rChkn2KDqvAsd1Sc8xAkUmmTyHTIvCKec9L5NNEOa2na5ET6GMVc/P3QGCFZQ5 OcSxdTyTi425LwN7s2OYHk1c0zMdXhs+uXg/xSq5UxJceMFYrhQzGIMdRiHLTKZ+mLpP qjRoQr1mmkgAys8XgPRTNGKEMMaNHdg5bO3eyi281/324h1c47VAjzYpDJ+8yJuqUrGd 20Lg== X-Gm-Message-State: APf1xPCgYPb2HsVhPr0tQjQZ2+Z912G1oHvw2XJu+KpTFooYkJvQUXGz MF9ad6LykeSGVT3TaG/jpaFYHRoh5tKX28OiHJ1xBA== X-Received: by 10.202.26.7 with SMTP id a7mr18719958oia.267.1520562897005; Thu, 08 Mar 2018 18:34:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.208.10 with HTTP; Thu, 8 Mar 2018 18:34:56 -0800 (PST) In-Reply-To: <20180308203132.GJ12290@flask> References: <1519897782-8124-1-git-send-email-wanpengli@tencent.com> <20180308203132.GJ12290@flask> From: Wanpeng Li Date: Fri, 9 Mar 2018 10:34:56 +0800 Message-ID: Subject: Re: [PATCH 1/3] KVM: X86: Provides userspace with a capability to not intercept MWAIT To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: LKML , kvm , Paolo Bonzini 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 2018-03-09 4:31 GMT+08:00 Radim Kr=C4=8Dm=C3=A1=C5=99 : >> To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl = should >> -be used. >> +be used. Blindly passing the KVM_CHECK_EXTENSION result to KVM_ENABLE_C= AP is >> +a valid thing to do when vCPUs are associated to dedicated physical CPU= s. > > This is not true even for x86 KVM_CAP_SPLIT_IRQCHIP and neither is is a > need to limit ourselves. Just leave it be. https://www.spinics.net/lists/kvm/msg159524.html > So I think we should put in the > documentation that blindly passing the KVM_CHECK_EXTENSION result to > KVM_ENABLE_CAP is a valid thing to do when vCPUs are associated to > dedicated physical CPUs. Paolo ask this before, Paolo, what's your opinion? >> +7.13 KVM_CAP_X86_DISABLE_EXITS >> + >> +Architectures: x86 >> +Parameters: args[0] defines which exits are disabled >> +Returns: 0 on success, -EINVAL when args[0] contains invalid exits >> + >> +Valid exits in args[0] are >> + >> +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) >> + >> +Enabling this capability on a VM provides userspace with a way to no >> +longer intercepts some instructions for improved latency in some >> +workloads. Not enable KVM_FEATURE_PV_UNHALT if you block HLT. > > The last sentence belong to the patch that enables HLT. > KVM could in theory handle the case (although it makes no sense), so if > it doesn't currently work, please add a check to kvm_update_cpuid() that > forbids KVM_FEATURE_PV_UNHALT when halt exits are disabled. Agreed. > > Also, it would be nicer to write that as > "Do not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits." > >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> @@ -2780,9 +2780,15 @@ static int msr_io(struct kvm_vcpu *vcpu, struct k= vm_msrs __user *user_msrs, >> return r; >> } >> >> +static inline bool kvm_mwait_can_in_guest(void) > > I think kvm_can_mwait_in_guest would be a better name. Agreed. Regards, Wanpeng Li