From patchwork Fri Aug 9 12:14:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758820 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 ED7E4C52D7C for ; Fri, 9 Aug 2024 13:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fN89Q2liYgHGCxi/OgsI7ErWc2vlQOTiYg0SNRcFq2c=; b=h1WasMLTZULsZL8DRp7vFOZ2on GtUpAJH37kU+vk9FBcEThVvaxEnYgpUbwyFMYeu7FpWxClP+TLKYH6gPVtJsAlFaEUPrJRZ1ZYvaq 3sE/87BZlbxopUqR/2F7A2CGZiyiSbNO7bW9LmGlr7+6HW2S/ulsT8L36yVjjKJYQRpP15iEK0twh t32IX2dYuBv/n1b7Rk7ueU90zTaxMYIQxN4MqehywH3SVcvV3irp1nMF8rwPExdhxt7poRAuuk1PU 63iwjOGljWKDMO/x+w/V/Jr5LJiFVZk1Bafbw6nafVy5qtpzZG9E0uX2UJyYLvB4oA6h/oBbfbp5y J+qDnuqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scPhw-0000000BLba-1Fr6; Fri, 09 Aug 2024 13:31:04 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWJ-0000000BA64-3lUp for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:15:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 56DEE1684; Fri, 9 Aug 2024 05:15:25 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B72D93F6A8; Fri, 9 Aug 2024 05:14:57 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 1/8] perf/core: Allow multiple AUX PMU events with the same module Date: Fri, 9 Aug 2024 13:14:40 +0100 Message-Id: <20240809121447.2078084-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051459_998371_7F18C347 X-CRM114-Status: GOOD ( 14.30 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This commit changes the condition from checking the same PMU instance to checking the same .setup_aux() callback pointer. If PMU events have the same callback pointer, it means they share the same PMU driver module. This allows support for multiple PMU events with the same driver module. As a result, more than one AUX event (e.g. arm_spe_0 and arm_spe_1) can record trace into the AUX ring buffer. Signed-off-by: Leo Yan --- kernel/events/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index aa3450bdc227..f450e6a91b1a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12344,9 +12344,16 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event) /* * If both events generate aux data, they must be on the same PMU + * module but can be with different PMU instances. + * + * For a built-in PMU module, the 'pmu->module' pointer is NULL, + * thus it is not feasible to compare the module pointers when + * AUX PMU drivers are built into the kernel image. Instead, + * comparing the .setup_aux() callback pointer can determine if + * the two PMU events come from the same PMU driver. */ if (has_aux(event) && has_aux(output_event) && - event->pmu != output_event->pmu) + event->pmu->setup_aux != output_event->pmu->setup_aux) goto out; /* From patchwork Fri Aug 9 12:14:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758822 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 2041CC3DA4A for ; Fri, 9 Aug 2024 13:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8ZnD3v4N2or7nH/N0UYm4ZMn6xlQU071kTw3ASl2iK0=; b=E69I62QCTDcjLKmqcG3mn2MMQy peflN/XrtU1T8FRJeaUeDJqBmNvpfZDb3foku57bjPs30B8OcOzFmA9uHghDKSysl14LW9vLWGxMX NUODklKcoa59KuDMBaF/ldktzH2Zi/ZcGCKYknpiUBcsr5Z1jkPEHcFo3F7gaEBHM9CkDmrCZvmes +no9wzGKYsCvDrW5/dWRWk5YpzKtJZKsqcSxmVe4IB30g5nV4E2ziswvxySXluY/rhzq8bu8nVMFz LdExQyzBcndU/fMqe2Q4gsbHZqtLnmgA7Bb0pdUTyDWoDMJ8fKRdijajskiXfmAEK3/gAqn4FgYrq pro8XlwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scPhx-0000000BLbx-0XRB; Fri, 09 Aug 2024 13:31:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWM-0000000BA6f-0v0G for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:15:17 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6527E1688; Fri, 9 Aug 2024 05:15:27 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BBAFA3F6A8; Fri, 9 Aug 2024 05:14:59 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 2/8] perf auxtrace: Use evsel__is_aux_event() for checking AUX event Date: Fri, 9 Aug 2024 13:14:41 +0100 Message-Id: <20240809121447.2078084-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051502_338697_918EE859 X-CRM114-Status: GOOD ( 11.81 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use evsel__is_aux_event() to decide if an event is a AUX event, this is a refactoring to replace comparing the PMU type. Signed-off-by: Leo Yan Reviewed-by: Adrian Hunter --- tools/perf/util/auxtrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e2f317063eec..c3f0ef4349fc 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -671,11 +671,11 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) { struct evsel *evsel; - if (!itr->evlist || !itr->pmu) + if (!itr->evlist) return -EINVAL; evlist__for_each_entry(itr->evlist, evsel) { - if (evsel->core.attr.type == itr->pmu->type) { + if (evsel__is_aux_event(evsel)) { if (evsel->disabled) return 0; return evlist__enable_event_idx(itr->evlist, evsel, idx); From patchwork Fri Aug 9 12:14:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758821 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 3FAE5C52D7D for ; Fri, 9 Aug 2024 13:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i8sePTrkjriGl/Xz2kf26JIG8iYn9vQCOqbB8lonJU0=; b=vcZtjlyOH4CWTJ//fIVUq7X9i1 KK1aI6rJz8tkqGyHjFROVLGwx8MoSux1ZAHsxn1WEotZRuIoHZGSrBJ5N4F+AnFkDsTTsi7MzL4Fl OtmZnwiu4rn7QbJI7L/Z3pAtBypDguEbTwwJk1od8l/7wpayATT8CJwM7yd3Lb3NtL2KFKs4v5deJ +YgVK5FGnvG28ExtBrG9cq+BM6VTz3XYXXBwX+0GIq86elGUWaCW94cxKmrIM67O0bmFo3U73Ghqk Ubm5wfLaGQauq72A6ydnRFl0BOSHxKhXJ1IpeUNknbooT/MrjqPHZD1cXVOrbUz2nCkdQJapwwRdS tqmY5r4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scPhx-0000000BLcQ-3Ymz; Fri, 09 Aug 2024 13:31:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWN-0000000BA7X-448y for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:15:49 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A5BC168F; Fri, 9 Aug 2024 05:15:29 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C9D2F3F6A8; Fri, 9 Aug 2024 05:15:01 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 3/8] perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record Date: Fri, 9 Aug 2024 13:14:42 +0100 Message-Id: <20240809121447.2078084-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051504_117991_BD821B59 X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The 'pmu' pointer in the auxtrace_record structure is not used after support multiple AUX events, remove it. Signed-off-by: Leo Yan Reviewed-by: Adrian Hunter --- tools/perf/arch/arm/util/cs-etm.c | 1 - tools/perf/arch/arm64/util/arm-spe.c | 1 - tools/perf/arch/arm64/util/hisi-ptt.c | 1 - tools/perf/arch/x86/util/intel-bts.c | 1 - tools/perf/arch/x86/util/intel-pt.c | 1 - tools/perf/util/auxtrace.h | 1 - 6 files changed, 6 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index da6231367993..96aeb7cdbee1 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -888,7 +888,6 @@ struct auxtrace_record *cs_etm_record_init(int *err) } ptr->cs_etm_pmu = cs_etm_pmu; - ptr->itr.pmu = cs_etm_pmu; ptr->itr.parse_snapshot_options = cs_etm_parse_snapshot_options; ptr->itr.recording_options = cs_etm_recording_options; ptr->itr.info_priv_size = cs_etm_info_priv_size; diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index d59f6ca499f2..2be99fdf997d 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -514,7 +514,6 @@ struct auxtrace_record *arm_spe_recording_init(int *err, } sper->arm_spe_pmu = arm_spe_pmu; - sper->itr.pmu = arm_spe_pmu; sper->itr.snapshot_start = arm_spe_snapshot_start; sper->itr.snapshot_finish = arm_spe_snapshot_finish; sper->itr.find_snapshot = arm_spe_find_snapshot; diff --git a/tools/perf/arch/arm64/util/hisi-ptt.c b/tools/perf/arch/arm64/util/hisi-ptt.c index ba97c8a562a0..eac9739c87e6 100644 --- a/tools/perf/arch/arm64/util/hisi-ptt.c +++ b/tools/perf/arch/arm64/util/hisi-ptt.c @@ -174,7 +174,6 @@ struct auxtrace_record *hisi_ptt_recording_init(int *err, } pttr->hisi_ptt_pmu = hisi_ptt_pmu; - pttr->itr.pmu = hisi_ptt_pmu; pttr->itr.recording_options = hisi_ptt_recording_options; pttr->itr.info_priv_size = hisi_ptt_info_priv_size; pttr->itr.info_fill = hisi_ptt_info_fill; diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 34696f3d3d5d..85c8186300c8 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c @@ -434,7 +434,6 @@ struct auxtrace_record *intel_bts_recording_init(int *err) } btsr->intel_bts_pmu = intel_bts_pmu; - btsr->itr.pmu = intel_bts_pmu; btsr->itr.recording_options = intel_bts_recording_options; btsr->itr.info_priv_size = intel_bts_info_priv_size; btsr->itr.info_fill = intel_bts_info_fill; diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index 4b710e875953..ea510a7486b1 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c @@ -1197,7 +1197,6 @@ struct auxtrace_record *intel_pt_recording_init(int *err) } ptr->intel_pt_pmu = intel_pt_pmu; - ptr->itr.pmu = intel_pt_pmu; ptr->itr.recording_options = intel_pt_recording_options; ptr->itr.info_priv_size = intel_pt_info_priv_size; ptr->itr.info_fill = intel_pt_info_fill; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 8a6ec9565835..95304368103b 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -411,7 +411,6 @@ struct auxtrace_record { int (*read_finish)(struct auxtrace_record *itr, int idx); unsigned int alignment; unsigned int default_aux_sample_size; - struct perf_pmu *pmu; struct evlist *evlist; }; From patchwork Fri Aug 9 12:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758740 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 17FC2C3DA4A for ; Fri, 9 Aug 2024 12:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8Wd49EWX04VUsWQ/d8R8UMLOb7sRCAh4UhjnL5j9ZU0=; b=paN8SGFK4OSMVJX2L4F5i1cZ7d gNB+/Jyi+auu4FF5GR2Jy9TYXbKSewr41IRtGNPIGTj529K+kedP14G5UjyIXJV26jwzuD7a8ntM+ 7VqOJrGQbVqyB8TvbbvNWgHNtWRVN6S9nwvYvvrsaV5DXNAPbusUarD6Dk9FsJ2Ql05lNHrdW5clA kbK7wEqplGdf5OawP3bBAIJTcznnXOp/5jOQcmf58OIsTlN4Bu6/OirkjL6142p1uo4YOFjbwf8Sq GnYYNnrzObm7gy5hKxsOT1arzpy+xT2w4oPNYgKwtT7Lcot1auR+JNhhUKQTUSswkk2Zj0xSss2uY 6grW1wUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOak-0000000BAqd-1dCG; Fri, 09 Aug 2024 12:19:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWQ-0000000BA81-0QES for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:16:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6EF131691; Fri, 9 Aug 2024 05:15:31 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CF3263F6A8; Fri, 9 Aug 2024 05:15:03 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 4/8] perf auxtrace: Introduce auxtrace_record__validate_events() Date: Fri, 9 Aug 2024 13:14:43 +0100 Message-Id: <20240809121447.2078084-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051506_247017_E02BE0C3 X-CRM114-Status: GOOD ( 16.28 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A prerequisite for multiple AUX events is that the AUX events cannot overlap CPU maps. The reason is that every CPU has only one AUX trace buffer and maps it to an unique buffer index for CPU and system tracing mode. To prevent the case of CPU maps overlapping occurring within multiple AUX events, the auxtrace_record__validate_events() function is introduced. It iterates through all AUX events and returns failure if it detects CPU maps overlapping. Signed-off-by: Leo Yan --- tools/perf/builtin-record.c | 4 +++ tools/perf/util/auxtrace.c | 64 +++++++++++++++++++++++++++++++++++++ tools/perf/util/auxtrace.h | 7 ++++ 3 files changed, 75 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 72345d1e54b0..dffb56052219 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -853,6 +853,10 @@ static int record__auxtrace_init(struct record *rec) auxtrace_regroup_aux_output(rec->evlist); + err = auxtrace_validate_events(rec->evlist); + if (err) + return err; + return auxtrace_parse_filters(rec->evlist); } diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index c3f0ef4349fc..b51b98a80acf 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -2828,6 +2828,70 @@ int auxtrace_parse_filters(struct evlist *evlist) return 0; } +int auxtrace_validate_events(struct evlist *evlist) +{ + struct evsel *evsel; + struct perf_cpu_map *cpu_map = NULL; + struct perf_cpu_map *cpu_map_intersect = NULL; + struct perf_cpu_map *cpu_map_merged = NULL; + int ret = 0; + + if (!evlist) + return 0; + + /* + * Currently the tool only supports multiple AUX events without + * overlapping CPU maps and every CPU has its unique AUX buffer + * for CPU or system mode tracing. + * + * Returns failure if detects CPU maps overlapping. + */ + evlist__for_each_entry(evlist, evsel) { + if (!evsel__is_aux_event(evsel)) + continue; + + if (perf_cpu_map__is_empty(evsel->pmu->cpus)) + continue; + + cpu_map_intersect = perf_cpu_map__intersect(cpu_map, evsel->pmu->cpus); + if (cpu_map_intersect) { + perf_cpu_map__put(cpu_map_intersect); + pr_err("Doesn't support AUX events with overlapping CPU masks\n"); + ret = -EINVAL; + break; + } + perf_cpu_map__put(cpu_map_intersect); + + cpu_map_merged = perf_cpu_map__merge(cpu_map, evsel->pmu->cpus); + if (!cpu_map_merged) { + ret = -ENOMEM; + break; + } + + /* Update the CPU maps after merging */ + perf_cpu_map__put(cpu_map); + cpu_map = cpu_map_merged; + } + + if (!ret) + goto out; + + /* If fails, dump CPU maps for debugging */ + evlist__for_each_entry(evlist, evsel) { + char buf[200]; + + if (!evsel__is_aux_event(evsel)) + continue; + + cpu_map__snprint(evsel->pmu->cpus, buf, sizeof(buf)); + pr_debug("AUX event [%s]'s cpu map is: %s\n", evsel->pmu->name, buf); + } + +out: + perf_cpu_map__put(cpu_map); + return ret; +} + int auxtrace__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, struct perf_tool *tool) { diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 95304368103b..93478dd7319b 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -636,6 +636,7 @@ void addr_filters__exit(struct addr_filters *filts); int addr_filters__parse_bare_filter(struct addr_filters *filts, const char *filter); int auxtrace_parse_filters(struct evlist *evlist); +int auxtrace_validate_events(struct evlist *evlist); int auxtrace__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, struct perf_tool *tool); @@ -875,6 +876,12 @@ int auxtrace_parse_filters(struct evlist *evlist __maybe_unused) return 0; } +static inline +int auxtrace_validate_events(struct evlist *evlist __maybe_unused) +{ + return 0; +} + int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, struct auxtrace_mmap_params *mp, void *userpg, int fd); From patchwork Fri Aug 9 12:14:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758736 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 EEB19C3DA4A for ; Fri, 9 Aug 2024 12:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m7/ikKb1ghKAkKc7Nt8FkVUDduA3/WXJQAnKSv3NnOM=; b=Bjl/UBvDmrV9n8TII2dnmC0a1g 2U2cP/j41QTY4L+3fft8gZ4KHZqfpgRWJYqQk9IYUqVO2QJ+QvWFpjVcGngIz5yaAxORwFwakmgGk stw4X6GCtJuQ6XleNVPxM8l3hH/XRidV7+IyGe0yn95bY+IyWNd2GXDUF4B5SnMtTAPFWrpABk/nb /bodSKlLQxMnE2szR08cExgE9EDfSHcRK/jTVwSRA+Tnt9fBflSvDmcuo4npHXBU3WcPjfbojwib6 cer7256Yml2K7m+2k3W4nxrxa41SQ4uWx3wkOxeCtYjEyr1m7kBnBmIQ97C4zS0VvmUc65DtGMny6 fmryNuCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOaC-0000000BAh8-2vah; Fri, 09 Aug 2024 12:19:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWS-0000000BA8n-3nba for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:16:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7435A1692; Fri, 9 Aug 2024 05:15:33 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D44953F6A8; Fri, 9 Aug 2024 05:15:05 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 5/8] perf auxtrace: Refactor evlist__enable_event_idx() Date: Fri, 9 Aug 2024 13:14:44 +0100 Message-Id: <20240809121447.2078084-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051509_307809_5D454822 X-CRM114-Status: GOOD ( 13.27 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This commit splits the evlist__enable_event_idx() function into two steps. The first step uses a new function evlist__find_cpu_map_idx() to find the CPU map index, based on the found CPU map index or a thread map index, it continues to call evlist__enable_event_idx() for enabling the corresponding event. Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 42 +++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index b51b98a80acf..c970024f16db 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -651,20 +651,30 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, return -EINVAL; } -static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx) +static int evlist__find_cpu_map_idx(struct evlist *evlist, struct evsel *evsel, + int idx) { bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); + struct perf_cpu evlist_cpu; + int cpu_map_idx; - if (per_cpu_mmaps) { - struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx); - int cpu_map_idx = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu); + if (!per_cpu_mmaps) + return -EINVAL; - if (cpu_map_idx == -1) - return -EINVAL; - return perf_evsel__enable_cpu(&evsel->core, cpu_map_idx); - } + evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx); + cpu_map_idx = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu); + if (cpu_map_idx == -1) + return -ENOENT; + + return cpu_map_idx; +} - return perf_evsel__enable_thread(&evsel->core, idx); +static int evlist__enable_event_idx(struct evsel *evsel, int cpu_mode, int idx) +{ + if (cpu_mode) + return perf_evsel__enable_cpu(&evsel->core, idx); + else + return perf_evsel__enable_thread(&evsel->core, idx); } int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) @@ -676,9 +686,21 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) evlist__for_each_entry(itr->evlist, evsel) { if (evsel__is_aux_event(evsel)) { + int cpu_map_idx; + if (evsel->disabled) return 0; - return evlist__enable_event_idx(itr->evlist, evsel, idx); + + cpu_map_idx = evlist__find_cpu_map_idx(itr->evlist, + evsel, idx); + /* No map is found in per CPU mmap */ + if (cpu_map_idx == -ENOENT) + return cpu_map_idx; + + if (cpu_map_idx >= 0) + return evlist__enable_event_idx(evsel, 1, cpu_map_idx); + else + return evlist__enable_event_idx(evsel, 0, idx); } } return -EINVAL; From patchwork Fri Aug 9 12:14:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758741 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 C3B8DC3DA4A for ; Fri, 9 Aug 2024 12:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RI69gYO9BN2OeA66it4DPa1TEplZJ7GIr6VmyOdPikk=; b=EP/BDRez8WLmjmbXIk6Dro/GBn 9dARX90pWBeXZzBxssigZ4X2XeRnj9bwY2j0v4iVp1eUVTKy6xe2xZvBeYkZVEcZ/1gWA0VBxI7bM 4+Kw/ja4sNzhVuvT5Cz62I6JiuIzbnHfnT3Sog9B8uWiqXd7e3e2uCahg437BUk9FEDGSQo42DnfB CpNEI2YK0DSNpeng0lG1fxdKXmN1uYIqUvyzG6+r8WPIxesmg6OnLxpRkuK6gz5GtuJhm2An0zotC F9wmK1GcE8kbyl4SfPxVMENsmbHM06qo/pwAK014SadkGr51tcNU+grZDGTmsgkgYrsdR/qD6w4jz Ed5EfTjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scObI-0000000BAvi-05ZC; Fri, 09 Aug 2024 12:20:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWU-0000000BA98-08RE for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:16:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8253516F8; Fri, 9 Aug 2024 05:15:35 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D8D383F6A8; Fri, 9 Aug 2024 05:15:07 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 6/8] perf auxtrace: Bails out after finding the event for the map index Date: Fri, 9 Aug 2024 13:14:45 +0100 Message-Id: <20240809121447.2078084-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051510_132406_7F8274C8 X-CRM114-Status: GOOD ( 13.14 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After finding the corresponding event for the passed buffer index, it is safe to say the found event has been used. Then, the tool can check the event status and bails out if it has been disabled. Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index c970024f16db..ac6e2e428a66 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -688,15 +688,15 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) if (evsel__is_aux_event(evsel)) { int cpu_map_idx; - if (evsel->disabled) - return 0; - cpu_map_idx = evlist__find_cpu_map_idx(itr->evlist, evsel, idx); /* No map is found in per CPU mmap */ if (cpu_map_idx == -ENOENT) return cpu_map_idx; + if (evsel->disabled) + return 0; + if (cpu_map_idx >= 0) return evlist__enable_event_idx(evsel, 1, cpu_map_idx); else From patchwork Fri Aug 9 12:14:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758742 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 311C0C52D7C for ; Fri, 9 Aug 2024 12:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QmSiSPTt5OUpbw6VmiEqGzQY1HctFRb1rJoxuGQfksw=; b=d+aSCZqg4P9DX2u1xOsV7Ii8bs z4JO6AsywMkIwzsKBwxu12/KClnc5cxYCZzosVL7NZX42Zud3G9DUCoM8ktuXIgkv/gV6SmNyBzTO YWOosl54radjTZtD1otZuFZITcrhrztO8zY+u97iOS3/XiJWMkyrE6YoKdmJLivG6QMr3EnMThI0V xWkax3xuIC6YZNYTy89gmndCTzhaUhjvXUQJhBZwdDVYx0vYHqrwmsPiYkBgxmct9RxYiuZ6VeZBk mnqj3GfLZWtiREZuSiEmgqXW1ZX6njqgDl/xvno8igM6fY0OdrKR9sXJjDFQ2LrRKnInxOkv8dKEd iS02/h3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scObo-0000000BB3q-33Oh; Fri, 09 Aug 2024 12:20:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWW-0000000BA9j-0nf0 for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:16:40 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 86F2D1713; Fri, 9 Aug 2024 05:15:37 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E6F1A3F6A8; Fri, 9 Aug 2024 05:15:09 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 7/8] perf auxtrace: Iterate all AUX events when finish reading Date: Fri, 9 Aug 2024 13:14:46 +0100 Message-Id: <20240809121447.2078084-8-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_051512_290062_27E42D2F X-CRM114-Status: GOOD ( 13.58 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When finished to read AUX trace data from mmaped buffer, based on the AUX buffer index the core layer needs to search the corresponding PMU event and re-enable it to continue tracing. However, current code only searches the first AUX event. It misses to search other enabled AUX events, thus, it returns failure if the buffer index does not belong to the first AUX event. This patch changes to continue searching every enabled AUX events for covering the mmaped buffer indexes. Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index ac6e2e428a66..9056bc7bcfce 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -690,9 +690,13 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) cpu_map_idx = evlist__find_cpu_map_idx(itr->evlist, evsel, idx); - /* No map is found in per CPU mmap */ + /* + * No map is found in per CPU mmap. Multiple AUX events + * might be opened in a session, continue to check if + * the next AUX event can cover the mmaped buffer 'idx'. + */ if (cpu_map_idx == -ENOENT) - return cpu_map_idx; + continue; if (evsel->disabled) return 0; From patchwork Fri Aug 9 12:14:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13758735 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 D3F34C3DA4A for ; Fri, 9 Aug 2024 12:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LkUcmh/tK+j+0RwYvZVqDhJ3mEYPJH90XTFrqkmNkLA=; b=gZ1/UnFj/FMSqO8GBNLsFkhtzY FNQUKM4tBFyon0geyfCMl3eNkNJyKJmEWYmQyRxkneNzrVbGHjoueSAXZRKf4KQne4uLPx+0/L51L C3UArD/DhRzUBE/qMaTinCLTPfiaCo0Tnge31uhmImOPly+grnGO13SfiyPmH4QoTWJ1NeaFin0jJ KevFS4pmGalX7hlQX0hrb9dG6M1VKfrZ3JeLAoMHxtxIjj3yz8Wz6b4ayekEMBp7/OW59SA5RLPRs dYFoNEzH8Ze8Xcd/tPYNe//CcvIwfhR+cFaGh7AKGgRmd6unVUgB6vAySmYN0JUbiMFB3W+L/kzrg SE1pIf8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOYZ-0000000BAOQ-2Uai; Fri, 09 Aug 2024 12:17:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWg-0000000BAC4-0lVS for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Aug 2024 12:15:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LkUcmh/tK+j+0RwYvZVqDhJ3mEYPJH90XTFrqkmNkLA=; b=R+/NzZoPzPv0X1fxIKpvQGfnw3 xMpAChR4qptVvVYb7j06RpN0qhNK068fLroQXysc1TUyle3dm2Aad77cUivpC27aE3s5wDV4sdeRj Y+7XGhFpqu/5ZnF5yhtQ1imajInghiqBp6Bu1x+oystWYLC5thbN6bMVMiAxcAz5q9GjjJW3TNB91 ClHfDigDxZzDJAjU7nTlWtl6B9Kxt+t4Lt4W1s0qh33UQs6gxT6lXBY1PPPBJqqpLxpfA9VxV+GcT OifA59f4hE+qI/YsmH/Ac7H8sSfzWHJTNi4DrOg7oVi1B0cgpME95cv5nlH9t+7Cx5gjKXcBkQ86K B4dQ7rYA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scOWb-000000070b7-3LeJ for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 12:15:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8AD7B1756; Fri, 9 Aug 2024 05:15:39 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EB2743F6A8; Fri, 9 Aug 2024 05:15:11 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Namhyung Kim , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 8/8] perf arm-spe: Support multiple events in arm_spe_evsel_is_auxtrace() Date: Fri, 9 Aug 2024 13:14:47 +0100 Message-Id: <20240809121447.2078084-9-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809121447.2078084-1-leo.yan@arm.com> References: <20240809121447.2078084-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_131518_197051_2CF214ED X-CRM114-Status: GOOD ( 13.68 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The 'pmu_type' field is an unique value and cannot support multiple PMU events. The arm_spe_evsel_is_auxtrace() function changes to compare PMU name to decide if it is a Arm SPE event. This leads to the 'pmu_type' field is no longer used, remove it. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index afbd5869f6bf..7c27d5179470 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,6 @@ struct arm_spe { u32 auxtrace_type; struct perf_session *session; struct machine *machine; - u32 pmu_type; u64 midr; struct perf_tsc_conversion tc; @@ -1053,12 +1053,10 @@ static void arm_spe_free(struct perf_session *session) free(spe); } -static bool arm_spe_evsel_is_auxtrace(struct perf_session *session, +static bool arm_spe_evsel_is_auxtrace(struct perf_session *session __maybe_unused, struct evsel *evsel) { - struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, auxtrace); - - return evsel->core.attr.type == spe->pmu_type; + return strstarts(evsel->pmu_name, ARM_SPE_PMU_NAME); } static const char * const arm_spe_info_fmts[] = { @@ -1128,7 +1126,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) int err; evlist__for_each_entry(evlist, evsel) { - if (evsel->core.attr.type == spe->pmu_type) { + if (arm_spe_evsel_is_auxtrace(session, evsel)) { found = true; break; } @@ -1313,7 +1311,6 @@ int arm_spe_process_auxtrace_info(union perf_event *event, spe->session = session; spe->machine = &session->machines.host; /* No kvm support */ spe->auxtrace_type = auxtrace_info->type; - spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE]; spe->midr = midr; spe->timeless_decoding = arm_spe__is_timeless_decoding(spe);