Message ID | 20230214050757.9623-8-likexu@tencent.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2768424wrn; Mon, 13 Feb 2023 21:10:33 -0800 (PST) X-Google-Smtp-Source: AK7set/Ckp94Rl+1eXUr4umdifDysGjER65R/4dH/Aor6x7ZS8zZ+3QtRQn5+h/1COBFbWPP6+0h X-Received: by 2002:a50:d0cd:0:b0:4ac:b600:180e with SMTP id g13-20020a50d0cd000000b004acb600180emr1079761edf.19.1676351432989; Mon, 13 Feb 2023 21:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676351432; cv=none; d=google.com; s=arc-20160816; b=M5Z6SA9YHX+vmxbbG/FnG8+BS3OalJMTN9l30+u5j4vU/lCnUfQw2iTmh3btPMIWPY Z+pGrcQciW0OSI6MT+tpWuRFDnBQ5P7U8mre9TWFwT0URH6q8IFGvuI1qdpzMFC2srBG rTVigqW4b8Anosq6NFR5RNX3cDGSuToxFnN+JkwI6TtBnDi2/ovTTxrkX0BBfLrAzaUu FHN1pFmVzaggH21xNc7YE5aDEzPbih6A+E4CyRrpr/pJlW6Of3eSMJgNPBbp5GqD1T5w K5JKjXWZSUE4dGiHrNI8h+DPjiXxtZUFplDj6Q8+lpcLDvwUbzsTwn0evun0c3f0XjYW dV+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7uzva8eb/mui8pw0PBjhdPuWAzuWwELEXUdu9aOzTQY=; b=qf9dXQJoBcaqTVY2snqwtgrentPaSiiA2M6PF7c7RuTD9TdkT74XD7fnq4AeOAXBw8 VPEpnPFt6+GpCaeT3/c9QSdlNc4zj95hVaQ+n6USMDZ16OhVFAaGDrtsDYFgvURcfkME Z47FF0ddbhhBjvpGdghxYDWTXfAOD9EpRKY8M0lQX+UeeHiZ7yK2z+veVhwRIk/USqbS +Hv4hUmwUqnsv9Ka/hfVwL272/Ny2a8B5qcvWh/gOUf4s1s78GwcoQ5QXjc0EYrgJbz1 PtbwoR6qnWN9ITPQ16XKZkdER7Gh+ol94O/yPfFithgtBa0WlpYlJcz5dGluY6SG/2NF /BXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IJmUd2UQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a056402120700b004acd55596e5si2383160edw.214.2023.02.13.21.10.08; Mon, 13 Feb 2023 21:10:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IJmUd2UQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231419AbjBNFJF (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 00:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231499AbjBNFIi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 00:08:38 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546781C7C9; Mon, 13 Feb 2023 21:08:29 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id r3so4003210pfh.4; Mon, 13 Feb 2023 21:08:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7uzva8eb/mui8pw0PBjhdPuWAzuWwELEXUdu9aOzTQY=; b=IJmUd2UQPqNmMdeuv3yUaBdedV0P89pQVW88PWvTK+PU964FJJ1c7Hp5lMyA5kx09c TPKj/IDK+B5rpl+7iTfo9AFjt8xIEmXDsPbgQ6r6wv1YLJEnrQNDpwhUc4KlEhE741/0 V++53RCTZAPQ14I9bFhtGcZGFSReCD5ifRSN43XnVkLuZYHcq9+gXQzbcBPd9E3INlKb Nv13yl0OeOC7qOuWNlLrQDtSaxHZ77mQFYM85LKJilYPFjezNsr/7ayuZvzUQ11wUkvp LSvEw3lcHtRS2ZK3qeR6LI5rEVmHqapXQohIwiM1OeY7EOQuBJ0vkIWUIxdvRBt2lUMu BwpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7uzva8eb/mui8pw0PBjhdPuWAzuWwELEXUdu9aOzTQY=; b=1FM5JRDHdrVSxkV2JTrzsB8uxs14h429KpssU2b4q4tYKLek8FaX+OkZk7uLmICB7q PTi33IRr6r5e6oTqTWEp57UDExr+HxDUM+gwebiLdhH04o1xIkEdfBsYnMUqSWYl38yS S9UGtiSlbPezB8GGkRJDueD7M4jCmBLIUYitM2xqemA4XxWtHFPWqqK5qcZnSMaPF10D 0R8rjsJIm2YhhHEMTYGgOsRz5unpECJJUFI6ptKlnxwKkmrWNqvCp0jupET783eF5VTS IVHMdteWJXnee0m9IZBbix7jf9igN2a4kAgcKck89FYrRYBlDkkphUZ/pVYeDwPtNf9e 5GLA== X-Gm-Message-State: AO0yUKUZrEaPJWtkzIcOWr2nvjgx486ZPtV588GG9iYj6T0xkp6wH5uN RqgNUL6b/x62RP5NGcxcMFdW4hZYxK9QVfMRNzs= X-Received: by 2002:a05:6a00:4304:b0:5a8:d438:c72 with SMTP id cb4-20020a056a00430400b005a8d4380c72mr2688608pfb.5.1676351308639; Mon, 13 Feb 2023 21:08:28 -0800 (PST) Received: from localhost.localdomain ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b005a79f5d9f53sm8738919pfa.165.2023.02.13.21.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 21:08:28 -0800 (PST) From: Like Xu <like.xu.linux@gmail.com> X-Google-Original-From: Like Xu <likexu@tencent.com> To: Sean Christopherson <seanjc@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/12] KVM: x86/cpuid: Use fast return for cpuid "0xa" leaf when !enable_pmu Date: Tue, 14 Feb 2023 13:07:52 +0800 Message-Id: <20230214050757.9623-8-likexu@tencent.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214050757.9623-1-likexu@tencent.com> References: <20230214050757.9623-1-likexu@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757781880208196053?= X-GMAIL-MSGID: =?utf-8?q?1757781880208196053?= |
Series |
KVM: x86: Add AMD Guest PerfMonV2 PMU support
|
|
Commit Message
Like Xu
Feb. 14, 2023, 5:07 a.m. UTC
From: Like Xu <likexu@tencent.com> Add an explicit !enable_pmu check as relying on kvm_pmu_cap to be zeroed isn't obvious. Although when !enable_pmu, KVM will have zero-padded kvm_pmu_cap to do subsequent cpuid leaf assignments, one extra branch instruction saves a few subsequent zero-assignment instructions, speeding things up a bit. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Like Xu <likexu@tencent.com> --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
KVM: x86: Explicitly zero cpuid "0xa" leaf when PMU is disabled On Tue, Feb 14, 2023, Like Xu wrote: > From: Like Xu <likexu@tencent.com> > > Add an explicit !enable_pmu check as relying on kvm_pmu_cap to be > zeroed isn't obvious. Although when !enable_pmu, KVM will have > zero-padded kvm_pmu_cap to do subsequent cpuid leaf assignments, > one extra branch instruction saves a few subsequent zero-assignment > instructions, speeding things up a bit. Drop the performance blurb, as I stated multiple times, optimizing this code is a non-goal.
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 2a9f1e200dbc..b0bb5f9f5307 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -944,7 +944,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) union cpuid10_eax eax; union cpuid10_edx edx; - if (!static_cpu_has(X86_FEATURE_ARCH_PERFMON)) { + if (!enable_pmu || !static_cpu_has(X86_FEATURE_ARCH_PERFMON)) { entry->eax = entry->ebx = entry->ecx = entry->edx = 0; break; }