From patchwork Tue Aug 20 18:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770533 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 B1B2FC3DA4A for ; Tue, 20 Aug 2024 18:49:29 +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=K1qiSj0FBevHg+LFgytEJjwAaqMPPiqCBoV4h8C01ao=; b=nBl6S9GNwIUSPHbmPKyca6WR2W r7587ypWUMtRKrdjfL38uJiWB0M5SF14aI+XDEuMXfHCuqHfZvJJydls6kXcsQ8VOkTOZlfGzugSR mX3Kb8vTF8zyOYB/HOKIyuQjReMpBwdWKymevN+juNtD1vEyr9tw1NkwDuNE2683Jic2E4uLvGAsQ YLpEt+oKXf5pcDeu84qIaCCF0WcR3NeAtu8iuI9vs18nYMBCJjfP+KWVBlwfJzt+ohex+fnJzlGFR AdvnSG+Czu2HBbyYJpWwsTTO82Y2emu1qNqj/4piipjWJznP2oxxEY0uPY51XvrD3R4xXQ/iM3JFJ d5q/2UpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTuu-00000006Mav-1NaM; Tue, 20 Aug 2024 18:49:16 +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 1sgTtW-00000006M8g-0CRw for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:47:52 +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 8B678FEC; Tue, 20 Aug 2024 11:48:15 -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 B82AA3F58B; Tue, 20 Aug 2024 11:47:46 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 1/8] perf/core: Allow multiple AUX PMU events with the same module Date: Tue, 20 Aug 2024 19:47:24 +0100 Message-Id: <20240820184731.2937551-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114750_149324_714546BE X-CRM114-Status: GOOD ( 13.95 ) 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 c973e3c11e03..883c457911a3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12345,9 +12345,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 Tue Aug 20 18:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770534 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 66FCEC531DC for ; Tue, 20 Aug 2024 18:50:08 +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=9b+a9CmegUas0q3MSGDhQI1OSW+nVRy0OTSYwUfUhmw=; b=JPmuxgWJEC8l6LJmMZ5ZNuVORO WDOeHUNEhcUCJUQpX/8vE/dsBcmm5UYbTHI6YIpihzCuFtl+ilAevC53e2WXXc5NppGLr9Nfknudn kZHArxmbJGUIWhNJDigcviLVT+caJSkDp0vI5bssKQMWuXWqvxJWhdpk4LvfoEgzdTDBdqi7aO4SE eq+9EaBmMam4oib057rqZ1HHTBjyLahVnB4moj2jHTDjqnPGLt61N+vdDKBfeN4xOCEpc1+9B3w8Q 4q6R8oCB/nvFL8DduTGNF3IBfTmNHPTHsZQvk9oFapl0X5PoGaVnZPw8cZROAJQg9/M1+vQhVdDpq DZyFACQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTva-00000006Mq7-0NyM; Tue, 20 Aug 2024 18:49:58 +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 1sgTtZ-00000006M9m-16xK for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:47:54 +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 9CC9D1480; Tue, 20 Aug 2024 11:48:18 -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 BFD1B3F58B; Tue, 20 Aug 2024 11:47:49 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 2/8] perf auxtrace: Use evsel__is_aux_event() for checking AUX event Date: Tue, 20 Aug 2024 19:47:25 +0100 Message-Id: <20240820184731.2937551-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114753_373152_FEE47B62 X-CRM114-Status: GOOD ( 12.04 ) 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 cbb773ed6f1a..ca8682966fae 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 Tue Aug 20 18:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770535 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 48446C3DA4A for ; Tue, 20 Aug 2024 18:50:54 +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=X4ZJqZ2B4iTXjQK1/guctDHeWSU9ARc1sqH0SGB8eho=; b=0K7Y7HObvwm8ujb50p8NWxZaud 2Q/VAipw2eJb9/umrY7XaPfUQUCXvyf7JepSjIFhMycXawQ9Sxf3dNEH3936MiXfzupgvnBLWP7kN lyqGLbm33+hwKo6AI4OwfSnIBhoKMqSZQuTyday8YLEqG+BmzBGqEViTxhTIvjvCd6f5tHcB1h58W 0BvfqsJxaBmQigf8o8gvK1zNmZzUijLDyBVSJJdtdSyn9gKhE9rD8diiqRum5ikqpLSH1WNyLhdJg C2LUGvKwet5kg7HgPk5Wd/S0jqKM+mlwS5wYJxeyGY734CEa+nOPuMYoKp/CBvRGk2bNOoCvr3PYB TRiwOUow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTwH-00000006N5c-0jXL; Tue, 20 Aug 2024 18:50:41 +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 1sgTtc-00000006MAn-0e6w for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:47:57 +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 A4E5BDA7; Tue, 20 Aug 2024 11:48:21 -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 D11CB3F58B; Tue, 20 Aug 2024 11:47:52 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 3/8] perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record Date: Tue, 20 Aug 2024 19:47:26 +0100 Message-Id: <20240820184731.2937551-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114756_307371_DA02F85E X-CRM114-Status: UNSURE ( 9.34 ) 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 d405efcd8708..a1895a4f530b 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 Tue Aug 20 18:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770536 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 64E01C3DA4A for ; Tue, 20 Aug 2024 18:51:34 +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=zfGU9gNbzO+7lK9BLPD2yFSmqj+paWh5V5SkAiLRhO8=; b=IZkNvih7BNT1yx0Hr5cFb0OxUt WGUjfczjdbH0bDPHhOy38ifthuuGCubixhJas8ACcNgtT81EPnpOVKhVG2o4AJO30FEwCHaahO91k 7Hqtg16PwdEgE8gFZyscsK0f8eokgfNVrLb0MLZdF8czozsE5nZdSQw+LkCXLyPWJnmFxfPKd1Jc5 7AIyvS6RJ1g3ZPH65sDEJLLTAxxIRCmEri6teDJ+bNB/B3o59BH/KWD2Y3aVPEJiRFoA99MwtI1Oq w8oAB8cVNbW3VSJ9GMlu8x2WezoeghFFqDH5AGTp9uAWsr4KMFJo9CsDXzrK38lI81zlFYNrgDbKX 3fPYd6zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTww-00000006NFd-1ZoE; Tue, 20 Aug 2024 18:51:22 +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 1sgTtf-00000006MBJ-1YTy for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:48:00 +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 B6C09FEC; Tue, 20 Aug 2024 11:48:24 -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 DA1EB3F58B; Tue, 20 Aug 2024 11:47:55 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 4/8] perf auxtrace: Introduce auxtrace_record__validate_events() Date: Tue, 20 Aug 2024 19:47:27 +0100 Message-Id: <20240820184731.2937551-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114759_535105_C470AB08 X-CRM114-Status: GOOD ( 16.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 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 adbaf80b398c..2c618efba97d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -862,6 +862,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 ca8682966fae..87e4f21b6edf 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, const struct perf_tool *tool) { diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index a1895a4f530b..67a74ad0c383 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, const 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 Tue Aug 20 18:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770537 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 8BA42C3DA4A for ; Tue, 20 Aug 2024 18:52: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=k1hxDCdTATeq9Ok5wIxfQnaqO1UGXpEmWZ8TmSJqt6g=; b=G68ll3fwtwP+dZuVWWLeAU8+Wv g0Mb2TqfbiNcXcheeEF+3Y8v/Nqfki148XM+Z9FfCq3S9dzijpvvuS9vKrIw888i0pQsWb7ceRT7Z Vn0Ez3gzKX3yHT4ubu6gGHnH5KtZn+5MX+7POaXRO/QrktkYgey7gE+lMxT7I+f6L51THFcbyy4X/ WtuJBwGA3XolxReBVE0kZ0/AiryhrQBVguGAn0P1R3CDI1QTl/F3lqWfeKRC5GJpr2ZMEal9tOU9e IFLtY00/tAzDvoCoHhSh28MIBY32XuGTJMG5q4ZcaW6b6+tbdL5/z5lq8qASujmNOtPZhXVndP6Pu 58XzQqPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTxb-00000006NM3-0dtW; Tue, 20 Aug 2024 18:52:03 +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 1sgTtk-00000006MDV-1b30 for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:48:05 +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 B4DA1FEC; Tue, 20 Aug 2024 11:48: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 E20B73F58B; Tue, 20 Aug 2024 11:47:58 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 5/8] perf auxtrace: Refactor evlist__enable_event_idx() Date: Tue, 20 Aug 2024 19:47:28 +0100 Message-Id: <20240820184731.2937551-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114804_511051_3FF88947 X-CRM114-Status: GOOD ( 13.40 ) 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 87e4f21b6edf..e7b582d92811 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 Tue Aug 20 18:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770538 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 07F7CC531DC for ; Tue, 20 Aug 2024 18:52:53 +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=x8rtr4H5ehdKsMEUHMNQPrGPt58M0ME9VUgPBzb/ZiE=; b=LlFU79zAozI5LeGMAKZDXFdgiQ UiXHnlktdZfBMx2xvwShPHG/xxVyg61nUon+ahFezC+PvZ+A7bm3VdiQRmo7b4RkqGFSt63Fqa9dW OV6BAS+hpsIZO7MyY26yWPBS1BrZy8dDxHyik794SOSfKbGt6ZzyepkRvhmXEOYrEKppb5AC9oKdU GKM2XGt3Xyrgolw2fxQ/LCQzgaFKo0dhgSYHBl/uqlBozC5i2fzAJyJ+WgZsZUcTPJMrl5ftJ+CbR lYFv7uDuzSdxw7acjWFTHInWmdg06/rR68TauxlHocHh8uwhvlm+2IEdqfMo4uko0rLtZIihBM3lB aucU7D/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTyG-00000006NUp-3WjQ; Tue, 20 Aug 2024 18:52:44 +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 1sgTtl-00000006ME6-1EtT for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:48:06 +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 EE545DA7; Tue, 20 Aug 2024 11:48:30 -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 E9CBF3F58B; Tue, 20 Aug 2024 11:48:01 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 6/8] perf auxtrace: Bails out after finding the event for the map index Date: Tue, 20 Aug 2024 19:47:29 +0100 Message-Id: <20240820184731.2937551-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114805_411860_21ED699B X-CRM114-Status: GOOD ( 13.18 ) 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 e7b582d92811..2acf63efab1d 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 Tue Aug 20 18:47:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770539 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 C0708C531DC for ; Tue, 20 Aug 2024 18:53:34 +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=H6Ui2zM7FbikYZ9dtPFnvkPfL52o+xWxW0tZt4It368=; b=rI9x01DJv4j6r97VEcUvI+9TNi Xi9tfnrxLE+3mc1zzFiw+5Zu01XfQeSnFIs3epjGs5r607iu+hsyL2xbPAcKgH+qbECDiI/0qoRoL 5JbnoktJsR4W8Ik9ySWM+h1teLfUUqAbIS5CdSEyD/pi/axpfaajYAi7By36aWqP2SHMdJMjkZnRO RHDocq+D+KIQ8d3OepsXhfTVt73j4sc3Kd42kXF6npLWfW+kZuFyCFRleCHitChz8f5mI5ax4TwYb wXdse0nxPPBhO2Ge7eBorlcrL4kraTJcfWDAxAlyWohLccInvfTcr0YqWE1xsE9H7ObyhqS3IEGbz pAHU+nNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTyv-00000006Ncl-1YVE; Tue, 20 Aug 2024 18:53:25 +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 1sgTto-00000006MGV-15r7 for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:48:10 +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 CDC621480; Tue, 20 Aug 2024 11:48: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 06F713F7A6; Tue, 20 Aug 2024 11:48:04 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 7/8] perf auxtrace: Iterate all AUX events when finish reading Date: Tue, 20 Aug 2024 19:47:30 +0100 Message-Id: <20240820184731.2937551-8-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114808_370238_A5F8EEA1 X-CRM114-Status: GOOD ( 13.71 ) 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 2acf63efab1d..864ed20794ab 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 Tue Aug 20 18:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13770540 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 B8B17C3DA4A for ; Tue, 20 Aug 2024 18:54:16 +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=mwvsNnCQlNpiFVE6iVNirpRacCOSFuzHmrEQ1Cn+1Kc=; b=UvRGeUbHUbj+qfkgA0QySTBVze iB1d17M9hlAppQj64GnuMAP4jh0yWduYUGCfmNu71ZwieN/VeHY5LWF0NJmF741L+F8ehlehp0Djk Mi/WOmQ/D5HqwRFf4Qdixr+hsyC7exoXRMpfBughTISuMaxX8Klwe7xrAcFtY57Gwela0+bH55+Au EoEXC4s2VIVld8pPsrALhTeeSgjJmsTI/+Ck2WSNrkghcorYVHct8DyLK28brOzlO7ZEJpvGnz566 ffkNQhbUIA/zlYK7ysPfZjt6cbKYjNv3MIV+NZAc3zZtoMeuZ/iwHJFHCmXhTjJdOrqXQR6Jocj80 I1pOwxuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgTzb-00000006Nlr-1yBG; Tue, 20 Aug 2024 18:54:07 +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 1sgTtr-00000006MHZ-0xNN for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 18:48:12 +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 D5516DA7; Tue, 20 Aug 2024 11:48:36 -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 0E5793F58B; Tue, 20 Aug 2024 11:48:07 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Jiri Olsa , "Liang, Kan" , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Mark Rutland , Will Deacon , Besar Wicaksono , Jonathan Cameron , 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 v5 8/8] perf arm-spe: Support multiple events in arm_spe_evsel_is_auxtrace() Date: Tue, 20 Aug 2024 19:47:31 +0100 Message-Id: <20240820184731.2937551-9-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820184731.2937551-1-leo.yan@arm.com> References: <20240820184731.2937551-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-20240820_114811_329078_2E0F4644 X-CRM114-Status: GOOD ( 13.75 ) 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 138ffc71b32d..3f8695fe6a20 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->name, ARM_SPE_PMU_NAME); } static const char * const arm_spe_info_fmts[] = { @@ -1099,7 +1097,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; } @@ -1284,7 +1282,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);