Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1548051rda; Mon, 23 Oct 2023 16:41:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNmRwnTolvnza49DHRxr5r6JIpysNATLR8kLEw8hhIZFnGnpcFEdqs85yMMdP71Pp3ACSu X-Received: by 2002:a05:6a00:1354:b0:6be:20d5:e8f8 with SMTP id k20-20020a056a00135400b006be20d5e8f8mr9356052pfu.1.1698104500187; Mon, 23 Oct 2023 16:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698104500; cv=none; d=google.com; s=arc-20160816; b=tqdEMIwUjMMMaWUPbVReq8mnK4osidw6dUjf1phV+T2I3KTVorz+LBC69l3HFAu8Do ya4cvk3ueza5Tn/95MFzISW8PRpbAuZgTT4aibFvLF6WDyHqmLW4m8TfcgTyeqUXWZ7v D43Aaa/ihhDRMFvr3vC1RLp98gbBcjRJxjTHttWnBtFc+I9fOaVDw1aIK59UsBr1euDc AVul/KHiKqWfy8JCkEPvePvfK8fnxlDeKxw4agaNLFtHi5QLPiBByp7/yD14YarlExo+ T31MQfmobO1WAMY25X1SdmgpVD61t4vBYrXZ/acjBk0Mms54Impprvn8sArTvrLRovOS Nzgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=ncl3FNsJPI8hbq8cXsw5giqcYGS/9dRNgfVScKM3w+8=; fh=t7gFcWLRyAqmyldGbr6d3KgIXGxOYU/i61iCoIU6S88=; b=olIwp80J4WuXPiheme0//0ukg6BkfMx2dRehhYEIYFXUNVBrRZyF4MQ3Aa1l/I+Oh/ eGIRoeoqf9B4+63aCYn228QazXyYy1aw6rCojk7EKS5UhlsR7HnRjB6/oR1uY6Hqyt7a 8vdggV7kfanJaQZvWUsAUjK8yi5hf6EDy8rviXFkVPtrke/zntTL5mlM77xiKtzKCmjM kVNaipNmIQbg8fheP95VUJdTD+EiGRg1UmF6rGt6Jqz31TZGTLwxaT9W+SBaa4VANbZw mimhO6rf7GzmcWPeMM80XCApvlgooVHlE8rT4D5fhmsB/+iOH5Loz3wPnVhXe5PRS0EL t0mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yeeyb2VU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y20-20020aa78f34000000b006b69f056508si7239654pfr.149.2023.10.23.16.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 16:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yeeyb2VU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6012B8087246; Mon, 23 Oct 2023 16:40:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjJWXkT (ORCPT + 99 others); Mon, 23 Oct 2023 19:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbjJWXkQ (ORCPT ); Mon, 23 Oct 2023 19:40:16 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D225CD6E for ; Mon, 23 Oct 2023 16:40:09 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da033914f7cso402280276.0 for ; Mon, 23 Oct 2023 16:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698104409; x=1698709209; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=ncl3FNsJPI8hbq8cXsw5giqcYGS/9dRNgfVScKM3w+8=; b=yeeyb2VUbRC6r8+YnM933njw2wWKCNaYXJlvdtAaMjBumtjXFJ2M8DWsK1Vg1MwJ3K of4zsWTQOaBWpSr+Fsh4XGmIQoD1b01zl6U0SvlvzBMF4k+fxT0W/S/x3yDv6AvjV1dV 9UYNXThheTPDfat+5BBDkQ7AD3PfeZ3szkxbfFFRriwBsI3klBK7RXLDf8LkyXq6brms 9HHL+qDX2LT9NBL5W91rFXpANPLz2HoR4x2T39Cx5qlBjLXXaD47mPDnbBHRSlXO+Xfk uDc4MfXDkxBGndLs6ZKgzi6Q/BsD+BIJNbpfLfBV+kxW1rRPnnz2sAaRPPriPq8bJOoD qd8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698104409; x=1698709209; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ncl3FNsJPI8hbq8cXsw5giqcYGS/9dRNgfVScKM3w+8=; b=Jg+AddEkRTdsWpnZL/wAJecBFoTDImTLfmyF9aBb1M2FOFmYrwcihbiGPWrMK92ml1 wTl+eYDrnucWKHAVlAocOTsA3W3lBYbZWeBzWYywYt5KjwQH7FxRiCxvAi1qkJ7kqukg 1WoZFmKWEM8KEB9UOv3F35/AtdWe6onfMukLi4r9DO7U6qNzA9Ks2BQYgs+e6hpAtiXj snSV4Dkueagm03hMn6BmhwRs1JgwtoOUjIeb7o5vBtu8A1cksMybYRlbFmFQwJ9iX/A5 uc1IZUEKolBd3BaBlHmW7Qu7kkj70+0Tv2h3j6QPOzhJInKBNffRM5+ulCIYKKeggyjx vfgw== X-Gm-Message-State: AOJu0Ywy1WxmNorxKH4B975Mi2WtrtGQUbFONpQCc4J/eFcF3NkIttzu ssoxRxR2yJxAq4AR4pEGIPG5fyyw9zw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1083:b0:d9a:c3b8:4274 with SMTP id v3-20020a056902108300b00d9ac3b84274mr279845ybu.7.1698104409129; Mon, 23 Oct 2023 16:40:09 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 23 Oct 2023 16:39:57 -0700 In-Reply-To: <20231023234000.2499267-1-seanjc@google.com> Mime-Version: 1.0 References: <20231023234000.2499267-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Message-ID: <20231023234000.2499267-4-seanjc@google.com> Subject: [PATCH 3/6] KVM: x86/pmu: Stop calling kvm_pmu_reset() at RESET (it's redundant) From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mingwei Zhang , Roman Kagan , Jim Mattson , Dapeng Mi , Like Xu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 16:40:36 -0700 (PDT) Drop kvm_vcpu_reset()'s call to kvm_pmu_reset(), the call is performed only for RESET, which is really just the same thing as vCPU creation, and kvm_arch_vcpu_create() *just* called kvm_pmu_init(), i.e. there can't possibly be any work to do. Unlike Intel, AMD's amd_pmu_refresh() does fill all_valid_pmc_idx even if guest CPUID is empty, but everything that is at all dynamic is guaranteed to be '0'/NULL, e.g. it should be impossible for KVM to have already created a perf event. Signed-off-by: Sean Christopherson --- arch/x86/kvm/pmu.c | 2 +- arch/x86/kvm/pmu.h | 1 - arch/x86/kvm/x86.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index dc8e8e907cfb..458e836c6efe 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -657,7 +657,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) return 0; } -void kvm_pmu_reset(struct kvm_vcpu *vcpu) +static void kvm_pmu_reset(struct kvm_vcpu *vcpu) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); struct kvm_pmc *pmc; diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h index a46aa9b25150..db9a12c0a2ef 100644 --- a/arch/x86/kvm/pmu.h +++ b/arch/x86/kvm/pmu.h @@ -243,7 +243,6 @@ bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr); int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info); int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info); void kvm_pmu_refresh(struct kvm_vcpu *vcpu); -void kvm_pmu_reset(struct kvm_vcpu *vcpu); void kvm_pmu_init(struct kvm_vcpu *vcpu); void kvm_pmu_cleanup(struct kvm_vcpu *vcpu); void kvm_pmu_destroy(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0c9686207996..c8ac83a7764e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12207,7 +12207,6 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) } if (!init_event) { - kvm_pmu_reset(vcpu); vcpu->arch.smbase = 0x30000; vcpu->arch.msr_misc_features_enables = 0; -- 2.42.0.758.gaed0368e0e-goog