From patchwork Sun Jul 21 20:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738094 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 5BD9EC3DA61 for ; Sun, 21 Jul 2024 20:22:31 +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=hau6ZNUSRnLBbU2RrAwrK804PnwlKFqUbEOp59khKMU=; b=P2gJAWvmTsj88K0lBd5wTTbQWg 46oNOjfv5o/DaMZDgJjO1o/r7sPS/0QYft6MB7mKimX+ZJ0juekhlwSRseRgASWrLXh64gD29GGfm moAlXyQ0+LjDIujptWqgOnFzqWRdAsp76Ad9PjPGXCUqhnK+xK3A0DzTpaTaw8dKUh+tDXqa/5F5l veBSelZGDwWOR8wq7IOGuLYDJDVnYtALXQxG6gzSU2JLckZUR6a+iNKBR8DA4NAPCg0Pc5z0Z6/KY +wnrWclnDGFCVR0rUDB8PYqqVlr8/uSmjDd62zPjz79vaQfdBy53uks3qlrU6g3jFCdV+ZQTrO++B xjjnWtXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd4T-00000007Uq2-2h4P; Sun, 21 Jul 2024 20:22:17 +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 1sVd3n-00000007Ueq-1WNw for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:37 +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 28E481007; Sun, 21 Jul 2024 13:21:58 -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 3099C3F73F; Sun, 21 Jul 2024 13:21:30 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 1/6] perf pmu: Directly use evsel's PMU pointer Date: Sun, 21 Jul 2024 21:21:08 +0100 Message-Id: <20240721202113.380750-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-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-20240721_132135_472340_48E7B5EC X-CRM114-Status: GOOD ( 11.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rather than iterating the whole PMU list for finding the associated PMU device for an evsel, this commit optimizes to directly use evsel's 'pmu' pointer for accessing PMU device. Signed-off-by: Leo Yan --- tools/perf/util/pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 986166bc7c78..798cd5a2ebc4 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1199,7 +1199,7 @@ void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu) bool evsel__is_aux_event(const struct evsel *evsel) { - struct perf_pmu *pmu = evsel__find_pmu(evsel); + struct perf_pmu *pmu = evsel->pmu; return pmu && pmu->auxtrace; } From patchwork Sun Jul 21 20:21:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738095 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 4FA81C3DA5D for ; Sun, 21 Jul 2024 20:22:48 +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=UQEAnIEiQleUM3IJwd3hx59D4mhMbWAcjEoFWGBSrTg=; b=XYMpx1z9QjQGsvP3wCczBwEcRg Kp8eZtBJAjL+fYGxiXS54UU1UNNDxwU0PW4McoPo0mfvbtZd1PhU4xAJTP9ze3EjnNdc0x4skXAIr twhRSQaC7KeSal1oCFWu33DcYc3+QkpjnznC95FcKJm5ZzlU8sZGVVW4uEQ7WQ0OR+X11+QwSFiYr 5Ial4nnXKdizTQ2XJd84YjQa+W2uqdPNC7fM5s99+SKvtBGRPzu3IAFsm79sNp0dhO9CuItfitjmU nI8Qjd4lWImF/94xVmEKyJuka8mAG0jBQLlapZR1qnD2zzbqJ2wo99taIk9GmJqm/ONodXa31vCmv wruo4gCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd4n-00000007Uyp-3i0o; Sun, 21 Jul 2024 20:22:37 +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 1sVd3o-00000007Ufb-0vg7 for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:37 +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 08A2511FB; Sun, 21 Jul 2024 13:22:01 -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 0CF023F73F; Sun, 21 Jul 2024 13:21:32 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 2/6] perf auxtrace arm: Set the 'auxtrace' flag for AUX events Date: Sun, 21 Jul 2024 21:21:09 +0100 Message-Id: <20240721202113.380750-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-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-20240721_132136_334831_069E5085 X-CRM114-Status: GOOD ( 10.96 ) 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 Originally, the 'auxtrace' flag in the PMU event is used for AUX area sampling. It indicates a PMU event is for AUX tracing. Set this flag for AUX trace events on Arm. Signed-off-by: Leo Yan Acked-by: Adrian Hunter --- tools/perf/arch/arm/util/pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c index 1c9541d01722..b7fa1245e242 100644 --- a/tools/perf/arch/arm/util/pmu.c +++ b/tools/perf/arch/arm/util/pmu.c @@ -25,6 +25,7 @@ void perf_pmu__arch_init(struct perf_pmu *pmu) /* add ETM default config here */ pmu->selectable = true; pmu->perf_event_attr_init_default = cs_etm_get_default_config; + pmu->auxtrace = true; #if defined(__aarch64__) } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) { pmu->selectable = true; @@ -32,8 +33,10 @@ void perf_pmu__arch_init(struct perf_pmu *pmu) pmu->perf_event_attr_init_default = arm_spe_pmu_default_config; if (strstarts(pmu->name, "arm_spe_")) pmu->mem_events = perf_mem_events_arm; + pmu->auxtrace = true; } else if (strstarts(pmu->name, HISI_PTT_PMU_NAME)) { pmu->selectable = true; + pmu->auxtrace = true; #endif } #endif From patchwork Sun Jul 21 20:21:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738096 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 AD8B3C3DA5D for ; Sun, 21 Jul 2024 20:23:07 +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=vf0eo941wcNgHTLngQMkiKEH7oMh7U5ZVJarea/MzuE=; b=PqhdpNdocEJEiv3apJpFT6CyvC irsgGr1SRkVbBNaNvgKRNX7z9ZDInh6KBijTrrG4WW+Cl9dDuJP7DRJ1NAI1HsJCbaEakQSWoLLkC 3N7IirNmbxRgPzjIjBddMZAj6UI7qjG93y5IfuJJNELB5fUIe6CIDeVcxvF9rZ8mg9IlJ9CypdZTG IhR2gF+rAtNOiS6NW848emradJXoTNqpoCx6IYcQ29t+vhFpyEd86U1sKoBegGc/PlhvdS9RJlGJX sW7wO1jn3Yexnbwj95n3EmWT6UZZw8SDqzyS6C3iUqgwrKjRnLdEH9RoQWYhoSbsGMd9toLYmoTn+ GwNjqYFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd57-00000007V6C-1ppY; Sun, 21 Jul 2024 20:22:57 +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 1sVd3r-00000007UgJ-2CeN for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:41 +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 D3B3A12FC; Sun, 21 Jul 2024 13:22:03 -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 DAE0B3F73F; Sun, 21 Jul 2024 13:21:35 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 3/6] perf auxtrace s390: Set the 'auxtrace' flag for AUX events Date: Sun, 21 Jul 2024 21:21:10 +0100 Message-Id: <20240721202113.380750-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-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-20240721_132139_631368_9AD295D4 X-CRM114-Status: UNSURE ( 9.42 ) 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 Set the 'auxtrace' flag for AUX events on s390. Signed-off-by: Leo Yan --- tools/perf/arch/s390/util/auxtrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/arch/s390/util/auxtrace.c b/tools/perf/arch/s390/util/auxtrace.c index 5068baa3e092..d7e72413b262 100644 --- a/tools/perf/arch/s390/util/auxtrace.c +++ b/tools/perf/arch/s390/util/auxtrace.c @@ -99,6 +99,7 @@ struct auxtrace_record *auxtrace_record__init(struct evlist *evlist, if (pos->core.attr.config == PERF_EVENT_CPUM_SF_DIAG) { diagnose = 1; pos->needs_auxtrace_mmap = true; + pos->pmu->auxtrace = true; break; } } From patchwork Sun Jul 21 20:21:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738097 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 98C05C3DA5D for ; Sun, 21 Jul 2024 20:23:27 +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=P8AxCup+qi1rBagPvvcQUgFVS03u9/5ZoMRnfXwa1WQ=; b=gF7AITblXmPwYs0sF9+s2blcBH 7Mvg39U2YjzMV84l4i6DmQmsHbxI1Sdcu9+Jq2AXc+Mo2wyJEQDrsK/LKq78atExxyXGTYiPERC7P UMdDsJhmZoE6498ULamKizvQM5yHLoWwjHYx5AisgGcw7VVQii/jVtIrfBx8/7hMqncHnuvZrQbmH Nt9tR2q/GXz4TOHiYfvc7CWssXxuuv1oJWgenV75zbCTmNFwt3vRNo+PSUIvbIrsg7zhZ1r0qRsYG +sjdFEAzcFV52RVBuBnaqUIcDva+DxnvlhJg/71xYqW5WvIWmwUa1Sk3/OZbcW9lJpb1iAfZ+Upxq GYTGdphw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd5S-00000007VFo-0ls5; Sun, 21 Jul 2024 20:23:18 +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 1sVd3v-00000007Ugl-08zH for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:44 +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 A51D6FEC; Sun, 21 Jul 2024 13:22:06 -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 B51033F73F; Sun, 21 Jul 2024 13:21:38 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 4/6] perf auxtrace: Iterate all AUX events when finish reading Date: Sun, 21 Jul 2024 21:21:11 +0100 Message-Id: <20240721202113.380750-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-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-20240721_132143_144106_42A9DE21 X-CRM114-Status: GOOD ( 14.61 ) 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 extends the auxtrace_record__read_finish() function to search for every enabled AUX events, so all the mmaped buffer indexes can be covered. Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e2f317063eec..95be330d7e10 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -670,18 +670,25 @@ static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) { struct evsel *evsel; + int ret = -EINVAL; if (!itr->evlist || !itr->pmu) 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); + continue; + ret = evlist__enable_event_idx(itr->evlist, evsel, idx); + if (ret >= 0) + return ret; } } - return -EINVAL; + + if (ret < 0) + pr_err("Failed to event enable event (idx=%d): %d\n", idx, ret); + + return ret; } /* From patchwork Sun Jul 21 20:21:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738098 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 E5533C3DA5D for ; Sun, 21 Jul 2024 20:23:49 +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=WLZbjlB9he8qtxjsEl5nbKIPgANFOYwAr7P7CQLpNRs=; b=fMTyrMJ0cu76ADrO8Az85gfzww Md64FZtFzGOhch3zXxvB52mtvc9BJLY6WgdwOZznAxuwCkPieEGNee7ZFVAXTN5cRXh5RMzK903HM YqD08SH+1URCxPoHaXchLOPXtvdQ1l0IOOrSXYX6qJvCx7FzrP1a3pN3mvvVwzOlEED0olU1ZUyaA fnh7vqXRIPqOfFzB08APsNGdhTqrr4yIZPqwFA83Et0rTEKYlvHwo8A0/WDFucEq/td0x7hG3rCLl 1QqlXGsCSUWkczu4IOPaoNaHUEEZkIxFJUbbZv3ru/QTxSUOsNjzD24tXSYlDbMK/hXbz3CSLGXxX C6wTKuxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd5n-00000007VMy-0MqV; Sun, 21 Jul 2024 20:23:39 +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 1sVd3w-00000007UhA-48lx for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:46 +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 82FFB1007; Sun, 21 Jul 2024 13:22:09 -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 865DA3F73F; Sun, 21 Jul 2024 13:21:41 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 5/6] perf arm-spe: Extract evsel setting up Date: Sun, 21 Jul 2024 21:21:12 +0100 Message-Id: <20240721202113.380750-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-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-20240721_132145_149955_BFE8A4CB X-CRM114-Status: GOOD ( 16.96 ) 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 evsel for Arm SPE PMU needs to be set up. Extract the setting up into a function arm_spe_setup_evsel(). Signed-off-by: Leo Yan --- tools/perf/arch/arm64/util/arm-spe.c | 74 +++++++++++++++------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 0b52e67edb3b..fe7942824113 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -132,6 +132,45 @@ static __u64 arm_spe_pmu__sample_period(const struct perf_pmu *arm_spe_pmu) return sample_period; } +static void arm_spe_setup_evsel(struct evsel *evsel, struct perf_cpu_map *cpus) +{ + u64 bit; + + evsel->core.attr.freq = 0; + evsel->core.attr.sample_period = arm_spe_pmu__sample_period(evsel->pmu); + evsel->needs_auxtrace_mmap = true; + + /* + * To obtain the auxtrace buffer file descriptor, the auxtrace event + * must come first. + */ + evlist__to_front(evsel->evlist, evsel); + + /* + * In the case of per-cpu mmaps, sample CPU for AUX event; + * also enable the timestamp tracing for samples correlation. + */ + if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) { + evsel__set_sample_bit(evsel, CPU); + evsel__set_config_if_unset(evsel->pmu, evsel, "ts_enable", 1); + } + + /* + * Set this only so that perf report knows that SPE generates memory info. It has no effect + * on the opening of the event or the SPE data produced. + */ + evsel__set_sample_bit(evsel, DATA_SRC); + + /* + * The PHYS_ADDR flag does not affect the driver behaviour, it is used to + * inform that the resulting output's SPE samples contain physical addresses + * where applicable. + */ + bit = perf_pmu__format_bits(evsel->pmu, "pa_enable"); + if (evsel->core.attr.config & bit) + evsel__set_sample_bit(evsel, PHYS_ADDR); +} + static int arm_spe_recording_options(struct auxtrace_record *itr, struct evlist *evlist, struct record_opts *opts) @@ -144,7 +183,6 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, bool privileged = perf_event_paranoid_check(-1); struct evsel *tracking_evsel; int err; - u64 bit; sper->evlist = evlist; @@ -154,9 +192,6 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, pr_err("There may be only one " ARM_SPE_PMU_NAME "x event\n"); return -EINVAL; } - evsel->core.attr.freq = 0; - evsel->core.attr.sample_period = arm_spe_pmu__sample_period(arm_spe_pmu); - evsel->needs_auxtrace_mmap = true; arm_spe_evsel = evsel; opts->full_auxtrace = true; } @@ -222,36 +257,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, opts->auxtrace_snapshot_size); - /* - * To obtain the auxtrace buffer file descriptor, the auxtrace event - * must come first. - */ - evlist__to_front(evlist, arm_spe_evsel); - - /* - * In the case of per-cpu mmaps, sample CPU for AUX event; - * also enable the timestamp tracing for samples correlation. - */ - if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) { - evsel__set_sample_bit(arm_spe_evsel, CPU); - evsel__set_config_if_unset(arm_spe_pmu, arm_spe_evsel, - "ts_enable", 1); - } - - /* - * Set this only so that perf report knows that SPE generates memory info. It has no effect - * on the opening of the event or the SPE data produced. - */ - evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); - - /* - * The PHYS_ADDR flag does not affect the driver behaviour, it is used to - * inform that the resulting output's SPE samples contain physical addresses - * where applicable. - */ - bit = perf_pmu__format_bits(arm_spe_pmu, "pa_enable"); - if (arm_spe_evsel->core.attr.config & bit) - evsel__set_sample_bit(arm_spe_evsel, PHYS_ADDR); + arm_spe_setup_evsel(arm_spe_evsel, cpus); /* Add dummy event to keep tracking */ err = parse_event(evlist, "dummy:u"); From patchwork Sun Jul 21 20:21:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738099 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 DE126C3DA61 for ; Sun, 21 Jul 2024 20:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: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=vHoKAHZZ3l41uOsm63G/o3j4A0GYeDhilxWPuUj/m7I=; b=PVAjOeSBze4jnPHJEC5scC9fQo onzRPejDu0lg4RennKM3+ZgYikbUjWe7YXkhxeAhIrcSte4PRQkV0/ERPand1DcTWZpMJ27pFBi8L dv8HJkI2eAfKLPhQazeT31+GyFZwg+we3L1l8H9Tn1xnW1aMIyw7eb5LiKCRF+9mRXkT0RakC04Jq oj2Ul367NEL95gamJKs258Viy93A052JHn7oZodo4UxwLvyMdkOU9oqeinSnHNFg+0jPjlsFdjcIj AG1+VYC7X0v3yHOIeTOg2UzIOe6mUC8BJ2Wnk98U1ylERAww3Gf8GcSNx/Cn9gMjzYiGtoDonksBE g45M2P+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd67-00000007VSF-2muY; Sun, 21 Jul 2024 20:23:59 +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 1sVd3z-00000007Uhi-1elS for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:48 +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 5C695FEC; Sun, 21 Jul 2024 13:22:12 -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 66BFB3F73F; Sun, 21 Jul 2024 13:21:44 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 6/6] perf arm-spe: Support multiple Arm SPE events Date: Sun, 21 Jul 2024 21:21:13 +0100 Message-Id: <20240721202113.380750-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-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-20240721_132147_535354_33FC61E7 X-CRM114-Status: GOOD ( 15.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 As the flag 'auxtrace' has been set for Arm SPE events, now it is ready to use evsel__is_aux_event() to check if an event is AUX trace event or not. Use this function to replace the old checking for only the first Arm SPE event. Signed-off-by: Leo Yan --- tools/perf/arch/arm64/util/arm-spe.c | 37 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index fe7942824113..d59f6ca499f2 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -177,8 +178,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, { struct arm_spe_recording *sper = container_of(itr, struct arm_spe_recording, itr); - struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; - struct evsel *evsel, *arm_spe_evsel = NULL; + struct evsel *evsel, *tmp; struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; bool privileged = perf_event_paranoid_check(-1); struct evsel *tracking_evsel; @@ -187,12 +187,12 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, sper->evlist = evlist; evlist__for_each_entry(evlist, evsel) { - if (evsel->core.attr.type == arm_spe_pmu->type) { - if (arm_spe_evsel) { - pr_err("There may be only one " ARM_SPE_PMU_NAME "x event\n"); + if (evsel__is_aux_event(evsel)) { + if (!strstarts(evsel->pmu_name, ARM_SPE_PMU_NAME)) { + pr_err("Found unexpected auxtrace event: %s\n", + evsel->pmu_name); return -EINVAL; } - arm_spe_evsel = evsel; opts->full_auxtrace = true; } } @@ -257,7 +257,10 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, opts->auxtrace_snapshot_size); - arm_spe_setup_evsel(arm_spe_evsel, cpus); + evlist__for_each_entry_safe(evlist, tmp, evsel) { + if (evsel__is_aux_event(evsel)) + arm_spe_setup_evsel(evsel, cpus); + } /* Add dummy event to keep tracking */ err = parse_event(evlist, "dummy:u"); @@ -307,12 +310,16 @@ static int arm_spe_snapshot_start(struct auxtrace_record *itr) struct arm_spe_recording *ptr = container_of(itr, struct arm_spe_recording, itr); struct evsel *evsel; + int ret = -EINVAL; evlist__for_each_entry(ptr->evlist, evsel) { - if (evsel->core.attr.type == ptr->arm_spe_pmu->type) - return evsel__disable(evsel); + if (evsel__is_aux_event(evsel)) { + ret = evsel__disable(evsel); + if (ret < 0) + return ret; + } } - return -EINVAL; + return ret; } static int arm_spe_snapshot_finish(struct auxtrace_record *itr) @@ -320,12 +327,16 @@ static int arm_spe_snapshot_finish(struct auxtrace_record *itr) struct arm_spe_recording *ptr = container_of(itr, struct arm_spe_recording, itr); struct evsel *evsel; + int ret = -EINVAL; evlist__for_each_entry(ptr->evlist, evsel) { - if (evsel->core.attr.type == ptr->arm_spe_pmu->type) - return evsel__enable(evsel); + if (evsel__is_aux_event(evsel)) { + ret = evsel__enable(evsel); + if (ret < 0) + return ret; + } } - return -EINVAL; + return ret; } static int arm_spe_alloc_wrapped_array(struct arm_spe_recording *ptr, int idx)