Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp54957rwd; Wed, 24 May 2023 14:04:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ470UTM/TJ1Onyx9s9jLGmnpnlyqtHlo/T1WdPIm/gDFP1P4vZXzyOx5LmgO/urG3492dTB X-Received: by 2002:a05:6a20:2453:b0:105:6d0e:c046 with SMTP id t19-20020a056a20245300b001056d0ec046mr18166773pzc.26.1684962296144; Wed, 24 May 2023 14:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684962296; cv=none; d=google.com; s=arc-20160816; b=sQuTG7ECqfoHSdT9ygi9o+AsDmZOHac0t2Jk0l38HvbK9ZAHEj5jepZtPhLF9jP1eC 4KoM9iOgeJFCF6rUjwLiJGmzvABdasiKj64EuKkxocCDS1pQLvuoBU31cPG7VubMescQ 2+NvpVJl1yDl/1rkDFwXC5eJ152pTk+zs3m1YRq7vTVuguHwRIYaa5PHMKu6VZP87PA2 uBByflYY6p264YvCv2oPorNRjVyGCs8mK5LffIKslguQBp3ilGJjsI/DFN4W8zM27d6E 8EuGgiXeoRoNpvU5E5c0+xTITXyfDxo7rGY/SpxZRTSkK76NDfmFKzyfNCll2up153Lt 3oMQ== 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:dkim-signature; bh=9TXhZ+RcN2Ognzp8oG5yYSbm5kQG0D1S7pQBiGgog54=; b=lf01VKrsKzW8nNxx/zexk9HlSet4GZzCeFVpZZAkOEKDgpYbbxnCXMx1d/GJudFFxU Y3bUHV6FlCqz3HsfgwZlcHQSsi/iSlGKgZPo9brTLN9nnVLYOshfQgQ2Weyv+M3N2QBx GHnA9G1txJfv/9okdCWj2dPrLcv/Uxq6CUzOztxD4ttfXTyiaccVBTpmbo1n9XV7zdEf XF33yKacTsKOTPm9oSuuAcgTl/PBLMtt+FNux8PYbUfBpGqXyj5KuV99r6xC8Tnshe6i pT1qfKeUhhJ4A/F1oqcT7Plv67JLhvqslXNczx+fWPHQ2dGH0lm6cotVl+lPOZSjIswX Di/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2h8rqjYF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a63e855000000b0053413a82947si8894147pgk.447.2023.05.24.14.04.41; Wed, 24 May 2023 14:04:56 -0700 (PDT) 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=@google.com header.s=20221208 header.b=2h8rqjYF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbjEXUyd (ORCPT + 99 others); Wed, 24 May 2023 16:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbjEXUyb (ORCPT ); Wed, 24 May 2023 16:54:31 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ECCB18D for ; Wed, 24 May 2023 13:54:26 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-528ab71c95cso428618a12.0 for ; Wed, 24 May 2023 13:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684961665; x=1687553665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9TXhZ+RcN2Ognzp8oG5yYSbm5kQG0D1S7pQBiGgog54=; b=2h8rqjYFPpwx20+8Yus2Hv3Lx5qrGrNNiOfzsYxA8jNNXcXLIYMNwFXRSu9nTmloVx b36BMiaIOxdoRW0NliLzsShWH1H+AfN9X1Lg/wDyJr7JpbvRnVYXbDhpMq+Cm2UouQ3w yJ74x2vVorasmuB3ksM/+65kRjrVyg4CHGgisKXxtBY3fMUsoWqZSIwUTAd4x6r2NdO+ 0opK4OzY7ZIDVy/eKGLL/+ICbkH6MqcEImqNubWW/QDDYzqJCazivH2L+0RwFOuUxMFs MOvWyhEwQQKdd1GRrsQcT6+fZbcdMx1V2uh0jisUPwVT9+fDlgGMel1ao5QTl2Owq6fm UvnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684961665; x=1687553665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9TXhZ+RcN2Ognzp8oG5yYSbm5kQG0D1S7pQBiGgog54=; b=BObhb9h/5wjQ1bxFf6JjhmXXQpvJL7ZAmz1crAC/0YXTFCphpVLTsEwf+/82JDfEah KbCluW1l51hi8oqqc88oF3U4lR8XX+ACS7plnZdTgM+Hbw+rIJoXsW9uwoZo209fEtUD jT9oyyChdtHoOoKDB3doVrHKz+ZmJLAtaPn6UpDcY4iB0IKw2XYPjYivb5N16Yg5o8bV Awu94d0J7mIAjYzGpdzlgFzxbn2Bedo9Pl2vQB9d7K29rGoQybgSOp90ZPZIkzT8t2mA GPpy21kHtksmuMq/Elc2wpZJcewWYd879iLVVFQeIvETj1NJqu+0hMoor92KHvwHTpmh pm+A== X-Gm-Message-State: AC+VfDz3JEniivjSwCnaCZPLPH07Kg9hj6/3hhXNZ9DYfVEZKHk9vCNe oMP4Ekcwy6p/M8Yy4QV5g3u4GhseC+Y= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:3349:0:b0:51b:8f87:6da4 with SMTP id z70-20020a633349000000b0051b8f876da4mr4463245pgz.11.1684961665658; Wed, 24 May 2023 13:54:25 -0700 (PDT) Date: Wed, 24 May 2023 13:54:23 -0700 In-Reply-To: <20230310105346.12302-3-likexu@tencent.com> Mime-Version: 1.0 References: <20230310105346.12302-1-likexu@tencent.com> <20230310105346.12302-3-likexu@tencent.com> Message-ID: Subject: Re: [PATCH 2/5] KVM: x86/pmu: Add a helper to check if pmc has PEBS mode enabled From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , Ravi Bangoria , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 10, 2023, Like Xu wrote: > From: Like Xu > > Add a helper to check if pmc has PEBS mode enabled so that more new > code may reuse this part and opportunistically drop a pmu reference. > > No functional change intended. > > Signed-off-by: Like Xu > --- > arch/x86/kvm/pmu.c | 3 +-- > arch/x86/kvm/pmu.h | 7 +++++++ > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > index d1c89a6625a0..01a6b7ffa9b1 100644 > --- a/arch/x86/kvm/pmu.c > +++ b/arch/x86/kvm/pmu.c > @@ -191,7 +191,6 @@ static int pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, u64 config, > bool exclude_user, bool exclude_kernel, > bool intr) > { > - struct kvm_pmu *pmu = pmc_to_pmu(pmc); > struct perf_event *event; > struct perf_event_attr attr = { > .type = type, > @@ -203,7 +202,7 @@ static int pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, u64 config, > .exclude_kernel = exclude_kernel, > .config = config, > }; > - bool pebs = test_bit(pmc->idx, (unsigned long *)&pmu->pebs_enable); > + bool pebs = pebs_is_enabled(pmc); > > attr.sample_period = get_sample_period(pmc, pmc->counter); > > diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h > index cff0651b030b..db4262fe8814 100644 > --- a/arch/x86/kvm/pmu.h > +++ b/arch/x86/kvm/pmu.h > @@ -189,6 +189,13 @@ static inline void kvm_pmu_request_counter_reprogram(struct kvm_pmc *pmc) > kvm_make_request(KVM_REQ_PMU, pmc->vcpu); > } > > +static inline bool pebs_is_enabled(struct kvm_pmc *pmc) pebs_is_enabled() is a bit too generic, e.g. at a glance I would expect it to return true if PEBS as a whole is enabled. What about something like pmc_is_pebs() or pmc_is_pebs_enabled()?