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 1E231C48BF8 for ; Thu, 22 Feb 2024 12:25:09 +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=sGwqCTZZVHl95Ujzd3ShEwwvVCCYcfkeke9durcAiJA=; b=X6xF1wVTQziSQc N9I7i5iNew4FU/QbKGLx2AQ+uEt/DPc8BwRlqW9YUYArS9I5XGQs7LJCR6ZQXsIWwZ5yvaOQqEcXX noJbYq+M2XHCwl47CkvAj6Of9UGsxfWxOsZ2PonfUURl5+3lUpGnYfTH3Me4ZHcbp402OPmUtA2PS 2928Z201Zdtwm5xNX6CXbjGmnpEE786pFkd/b9XEzoI4xHQuQ3Qg3vUECI6uidts2aL36vTZAE1el VbUpvcfsED+y1NBrzn1SNfkNA3ppV0DaQtcvxTwbsvFGo5Z4Rvnm/Ibv7r9r/zHVUTVRvNqYUYBnn um/oBJyY+SWDnIHC+ZrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd88B-00000004oSJ-3qyj; Thu, 22 Feb 2024 12:24:51 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd887-00000004oPb-2sGr for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 12:24:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DE612617E7; Thu, 22 Feb 2024 12:24:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C72B5C433C7; Thu, 22 Feb 2024 12:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708604686; bh=vepoCvUA87NndiRWHPhBF1/XeR6TA9jZpkQrmwbjNUM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RxjsYAIPU0mncAH7vf7kcWpQARm8xbPVWHRkKQqPfZ3aujv4lELoWzaa/Wo9KXyc8 g+dlCFRr9WSdoulAVmAb3VYjUVmDU10iRtdRT3GjulsF2J8FJRGdXcFGJONp5WA6iN 03Zxb91VTkWK2KFjpEdxxaohbUWzZD5OygXgwt1evDdGRsi523YqCRspx4Xzb33/+q Hk1qrKY1AmFEkipAgn6xZ3lnkgyKx4Zc+MeYcfy9hylgZQ90uvg1xtUyFV89I5iG/g z2tQDcrBw2wUiE7/WoGATr/LL18XqyzDHCciq3ySsPXiKeygxbO4ulfkltG5fmgFwp FBe53I2NoMv3g== Date: Thu, 22 Feb 2024 12:24:38 +0000 From: Will Deacon To: Xu Yang Cc: Frank.li@nxp.com, mark.rutland@arm.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, john.g.garry@oracle.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, linux-imx@nxp.com, mike.leach@linaro.org, leo.yan@linaro.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, imx@lists.linux.dev Subject: Re: [PATCH v4 5/6] perf: imx_perf: limit counter ID from user space and optimize counter usage Message-ID: <20240222122438.GD8308@willie-the-truck> References: <20240131055811.3035741-1-xu.yang_2@nxp.com> <20240131055811.3035741-5-xu.yang_2@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240131055811.3035741-5-xu.yang_2@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_042447_905100_837133C0 X-CRM114-Status: GOOD ( 25.59 ) 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 Wed, Jan 31, 2024 at 01:58:10PM +0800, Xu Yang wrote: > The user can pass any counter ID to perf app. However, current pmu driver > doesn't judge the validity of the counter ID. This will add necessary > check for counter ID from user space. Besides, this pmu has 10 counters > except cycle counter which can be used to count reference events and > counter specific evnets. This will also add supports to auto allocate > counter if the user doesn't pass it the perf. Then, the usage of counter > will be optimized. > > Signed-off-by: Xu Yang > > --- > Changes in v2: > - limit counter ID from user to 0-10 > - combine dynamic and static allocation of counter > Changes in v3: > - no changes > Changes in v4: > - rename ddr_perf_is_specific_event() > - use macro definitions to parse config attr > --- > drivers/perf/fsl_imx9_ddr_perf.c | 72 +++++++++++++++++++++++++++++++- > 1 file changed, 71 insertions(+), 1 deletion(-) > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > index 94041f06c152..e71496809c52 100644 > --- a/drivers/perf/fsl_imx9_ddr_perf.c > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > @@ -51,6 +51,7 @@ > > #define NUM_COUNTERS 11 > #define CYCLES_COUNTER 0 > +#define CYCLES_EVENT_ID 0 > > #define CONFIG_EVENT_MASK 0x00FF > #define CONFIG_EVENT_OFFSET 0 > @@ -240,6 +241,19 @@ static struct attribute *ddr_perf_events_attrs[] = { > NULL, > }; > > +/* > + * An event is either reference evnet or counter specific event. > + * For counter specific event, the event count will only be incremented > + * on the corresponding counter. > + */ > +static bool ddr_perf_is_counter_specific_event(int event) > +{ > + if (event >= 64 && event <= 73) > + return true; > + else > + return false; Just collapse this to 'return event >= 64 && event <= 73;' Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel