From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F523CDB483 for ; Fri, 13 Oct 2023 05:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjJMFnM (ORCPT ); Fri, 13 Oct 2023 01:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjJMFnK (ORCPT ); Fri, 13 Oct 2023 01:43:10 -0400 Received: from out-210.mta0.migadu.com (out-210.mta0.migadu.com [IPv6:2001:41d0:1004:224b::d2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B592DB8 for ; Thu, 12 Oct 2023 22:43:08 -0700 (PDT) Date: Fri, 13 Oct 2023 05:43:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697175786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kNOrYS3RMfC5VKdrToezk3EhKhJLCblPKD1dYpu7e7w=; b=jkgwCzZdgR6Cy7Nxg0J2L6ZbhwD2AYaH05MjAPmavXrL+f/Ted3isynWFPqLew/aumeUEm 0A1hjn4ytpw3uAB3ndcMAWlioMqa34wozVbL7CpE6XgPmcHcZRTdpRd2ru0zGHDlTPekzM amc7Z8vcQfHQ7nsCKnjdzfQtdWaHjNc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Raghavendra Rao Ananta Cc: Marc Zyngier , Alexandru Elisei , James Morse , Suzuki K Poulose , Paolo Bonzini , Zenghui Yu , Shaoqin Huang , Jing Zhang , Reiji Watanabe , Colton Lewis , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v7 06/12] KVM: arm64: PMU: Add a helper to read the number of counters Message-ID: References: <20231009230858.3444834-1-rananta@google.com> <20231009230858.3444834-7-rananta@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 10, 2023 at 10:30:31PM +0000, Oliver Upton wrote: > On Mon, Oct 09, 2023 at 11:08:52PM +0000, Raghavendra Rao Ananta wrote: > > Add a helper, kvm_arm_get_num_counters(), to read the number > > of counters from the arm_pmu associated to the VM. Make the > > function global as upcoming patches will be interested to > > know the value while setting the PMCR.N of the guest from > > userspace. > > > > Signed-off-by: Raghavendra Rao Ananta > > --- > > arch/arm64/kvm/pmu-emul.c | 17 +++++++++++++++++ > > include/kvm/arm_pmu.h | 6 ++++++ > > 2 files changed, 23 insertions(+) > > > > diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c > > index a161d6266a5c..84aa8efd9163 100644 > > --- a/arch/arm64/kvm/pmu-emul.c > > +++ b/arch/arm64/kvm/pmu-emul.c > > @@ -873,6 +873,23 @@ static bool pmu_irq_is_valid(struct kvm *kvm, int irq) > > return true; > > } > > > > +/** > > + * kvm_arm_get_num_counters - Get the number of general-purpose PMU counters. > > + * @kvm: The kvm pointer > > + */ > > +int kvm_arm_get_num_counters(struct kvm *kvm) > > nit: the naming suggests this returns the configured number of PMCs, not > the limit. > > Maybe kvm_arm_pmu_get_max_counters()? Following up on the matter -- please try to avoid sending patches that add helpers without any users. Lifting *existing* logic into a helper and updating the callsites is itself worthy of a separate patch. But adding a new function called by nobody doesn't do much, and can easily be squashed into the patch that consumes the new logic. -- Thanks, Oliver