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 D815CC433EF for ; Thu, 9 Jun 2022 13:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343587AbiFINA3 (ORCPT ); Thu, 9 Jun 2022 09:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343630AbiFINAX (ORCPT ); Thu, 9 Jun 2022 09:00:23 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414914A3F0; Thu, 9 Jun 2022 06:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654779614; x=1686315614; h=from:to:cc:subject:date:message-id; bh=MbluhEaJzamnhyK/2T+/wKWSz4GPM1oLHU1upxZh1bA=; b=WPLD68DbZDWaxxpOhDc+kSPDlxypjyKTacj4jkv9MeWUN9QDo1KpyxVm MorHx6Cv/xfktb9sTBIrSy8DkD+m8lGuA6bcKNl7xDkSdzc8EudG1Qa9U 4IPGGIkzGURDcywc/Za4ziw+Nl/E64gMBQZRI8ZyaUmjmt3j5Ns9Vz75K o=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 09 Jun 2022 06:00:10 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 09 Jun 2022 06:00:09 -0700 X-QCInternal: smtphost Received: from hu-c-spathi-hyd.qualcomm.com (HELO hu-sgudaval-hyd.qualcomm.com) ([10.213.108.59]) by ironmsg02-blr.qualcomm.com with ESMTP; 09 Jun 2022 18:29:53 +0530 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 212714) id C53E83E5A; Thu, 9 Jun 2022 18:29:51 +0530 (+0530) From: Srinivasarao Pathipati To: will@kernel.org, mark.rutland@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Srinivasarao Pathipati Subject: [PATCH V6] arm64: perf: Make exporting of pmu events configurable Date: Thu, 9 Jun 2022 18:29:49 +0530 Message-Id: <1654779589-19937-1-git-send-email-quic_c_spathi@quicinc.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The PMU export bit (PMCR_EL0.X) is getting reset during pmu reset, Make it configurable using sysctls to enable/disable at runtime. Signed-off-by: Srinivasarao Pathipati --- Changes since V5: - removed configuring with kernel parameters. Changes since V4: - Registering sysctls dynamically for only arm64 as suggested by Will - Not removed the code to configure with kernel parameters as the sysctl's kernel parameter(sysctl.kernel.export_pmu_events) is not working at early bootup. pmu_reset() getting called before sysctl's kernel parameter is set. Changes since V3: - export bit is now configurable with sysctl - enabling export bit on reset instead of retaining Changes since V2: Done below changes as per Will's comments - enabling pmcr_x now configurable with kernel parameters and by default it is disabled. Changes since V1: - Preserving only PMCR_X bit as per Robin Murphy's comment. --- Documentation/admin-guide/sysctl/kernel.rst | 11 +++++++++++ arch/arm64/kernel/perf_event.c | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index ddccd10..c2ecd84 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -267,6 +267,17 @@ domain names are in general different. For a detailed discussion see the ``hostname(1)`` man page. +export_pmu_events (arm64 only) +============================== + +Controls the PMU export bit (PMCR_EL0.X), which enables the exporting of +events over an IMPLEMENTATION DEFINED PMU event export bus to another device. + +0: disables exporting of events (default). + +1: enables exporting of events. + + firmware_config =============== diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index cb69ff1..a8c32a0 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -298,6 +298,7 @@ PMU_FORMAT_ATTR(long, "config1:0"); PMU_FORMAT_ATTR(rdpmc, "config1:1"); static int sysctl_perf_user_access __read_mostly; +static int sysctl_export_pmu_events __read_mostly; static inline bool armv8pmu_event_is_64bit(struct perf_event *event) { @@ -1047,6 +1048,9 @@ static void armv8pmu_reset(void *info) if (armv8pmu_has_long_event(cpu_pmu)) pmcr |= ARMV8_PMU_PMCR_LP; + if (sysctl_export_pmu_events) + pmcr |= ARMV8_PMU_PMCR_X; + armv8pmu_pmcr_write(pmcr); } @@ -1221,6 +1225,15 @@ static struct ctl_table armv8_pmu_sysctl_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, + { + .procname = "export_pmu_events", + .data = &sysctl_export_pmu_events, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, { } }; -- 2.7.4 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 3B89BC433EF for ; Thu, 9 Jun 2022 13:01:43 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dzalm9IoWN4IobKREaOk6PYoXUQ7ACvhNHO7Mmw3WbY=; b=rXfZsQZB+sZxFX Ebxp8M97myIZ1vOGvLNu4B2VyMsnPXSu4urNDUVP7UI+VVU2xwtN7LiiOPbpshfS6v9wifdYP6/6M eRsmj3zFEWw8eUxD5Wv5SWRYMcLVt8GoLHN5jTJSvBi7ZWc2Oj7srePd+Q3rZ0IGCYJy6UYdPY8VI C8Gie5ybm3vAs24spox6pIArOidIlimCNMZJm6jClOALZmoNTHnVtqa0iFRycCruyBqjiEJbCsDZx zCt2+CiySqfuSF48/ARLSAzb/pkysWSjgYXEd5nPmHB746Z1gyJvk+iWLoym6R9clDZOMQ1uyEu5P WePfB15JPjrxmf3oBVdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzHm1-001xCM-Rw; Thu, 09 Jun 2022 13:00:29 +0000 Received: from alexa-out.qualcomm.com ([129.46.98.28]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzHly-001x6r-HT for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 13:00:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654779626; x=1686315626; h=from:to:cc:subject:date:message-id; bh=MbluhEaJzamnhyK/2T+/wKWSz4GPM1oLHU1upxZh1bA=; b=adOgsBBkz3zqddBpY/PNe6/AJclOMFijjsJih9FHLZou5cbmEydIV6qB QQbNAot7sYK/n5wbrqfV5CD4LKZFI+qGBEo4J5ZrX3LR/z8DMrfadn7Q8 ok8YcUyGDN6fR6dAWI3h4boHV4c1dxQaVEL2OlnBuJp0IDIUm1tab3R1G 0=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 09 Jun 2022 06:00:10 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 09 Jun 2022 06:00:09 -0700 X-QCInternal: smtphost Received: from hu-c-spathi-hyd.qualcomm.com (HELO hu-sgudaval-hyd.qualcomm.com) ([10.213.108.59]) by ironmsg02-blr.qualcomm.com with ESMTP; 09 Jun 2022 18:29:53 +0530 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 212714) id C53E83E5A; Thu, 9 Jun 2022 18:29:51 +0530 (+0530) From: Srinivasarao Pathipati To: will@kernel.org, mark.rutland@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Srinivasarao Pathipati Subject: [PATCH V6] arm64: perf: Make exporting of pmu events configurable Date: Thu, 9 Jun 2022 18:29:49 +0530 Message-Id: <1654779589-19937-1-git-send-email-quic_c_spathi@quicinc.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_060026_659083_4645EB15 X-CRM114-Status: GOOD ( 13.31 ) 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: , MIME-Version: 1.0 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 The PMU export bit (PMCR_EL0.X) is getting reset during pmu reset, Make it configurable using sysctls to enable/disable at runtime. Signed-off-by: Srinivasarao Pathipati --- Changes since V5: - removed configuring with kernel parameters. Changes since V4: - Registering sysctls dynamically for only arm64 as suggested by Will - Not removed the code to configure with kernel parameters as the sysctl's kernel parameter(sysctl.kernel.export_pmu_events) is not working at early bootup. pmu_reset() getting called before sysctl's kernel parameter is set. Changes since V3: - export bit is now configurable with sysctl - enabling export bit on reset instead of retaining Changes since V2: Done below changes as per Will's comments - enabling pmcr_x now configurable with kernel parameters and by default it is disabled. Changes since V1: - Preserving only PMCR_X bit as per Robin Murphy's comment. --- Documentation/admin-guide/sysctl/kernel.rst | 11 +++++++++++ arch/arm64/kernel/perf_event.c | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index ddccd10..c2ecd84 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -267,6 +267,17 @@ domain names are in general different. For a detailed discussion see the ``hostname(1)`` man page. +export_pmu_events (arm64 only) +============================== + +Controls the PMU export bit (PMCR_EL0.X), which enables the exporting of +events over an IMPLEMENTATION DEFINED PMU event export bus to another device. + +0: disables exporting of events (default). + +1: enables exporting of events. + + firmware_config =============== diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index cb69ff1..a8c32a0 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -298,6 +298,7 @@ PMU_FORMAT_ATTR(long, "config1:0"); PMU_FORMAT_ATTR(rdpmc, "config1:1"); static int sysctl_perf_user_access __read_mostly; +static int sysctl_export_pmu_events __read_mostly; static inline bool armv8pmu_event_is_64bit(struct perf_event *event) { @@ -1047,6 +1048,9 @@ static void armv8pmu_reset(void *info) if (armv8pmu_has_long_event(cpu_pmu)) pmcr |= ARMV8_PMU_PMCR_LP; + if (sysctl_export_pmu_events) + pmcr |= ARMV8_PMU_PMCR_X; + armv8pmu_pmcr_write(pmcr); } @@ -1221,6 +1225,15 @@ static struct ctl_table armv8_pmu_sysctl_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, + { + .procname = "export_pmu_events", + .data = &sysctl_export_pmu_events, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, { } }; -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel