From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-198.mta0.migadu.com (out-198.mta0.migadu.com [91.218.175.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 819EB3D022 for ; Fri, 13 Oct 2023 05:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="jkgwCzZd" 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> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT 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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D87FCDB47E for ; Fri, 13 Oct 2023 05:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CL9xVebg4bfcgWpYOTwgKaRLOM4yC7t+8+/rZ2ks5mI=; b=W0X6sFPeaDHwdI DLlAtmmBr0KTvmPvf8SJjXZwtTN/5790eN/nF/hj3oYnLqAeebd7nPNjeR/Nkoild29Dbo9M29Jm6 2r9V8VPEMDUA+Ectw2VFmcKebunUVzf0igwkdr1lE0mJPloxy9NsLyV930LyrfRXD8YMj0qgdVW0+ z1xSc1GxuWe68fFjyV9z/CwsLdblKjwZHlT5peqqzDY8scNPNlk7a/CRWIgXshfIaZQkK7b6CLwNs OE/dxlgiqJK8rDDGvoxi2lBhE03gvqJMYqUWABgtjcXdjMSSrvjlR1g5a8T/7InWzc09RKGTuoY0C 3cCGmaSD5gT0W/b5x7gA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrAxA-002XJa-1H; Fri, 13 Oct 2023 05:43:16 +0000 Received: from out-204.mta0.migadu.com ([2001:41d0:1004:224b::cc]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrAx5-002XId-25 for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 05:43:14 +0000 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-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231012_224311_835612_85CF7E4B X-CRM114-Status: GOOD ( 19.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel