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 C44EAC433F5 for ; Fri, 26 Nov 2021 02:36: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sGao4LSjXqfYN9nos227ZihiFz2OhNIFCsbRnLLpkes=; b=v64PEesAPc9CVe 68SKJWwWu0isIVJBxmOgNcOLR6ej/U7XQgmoQ/a8sCD6tKZttbBovR0tvf+U8WiCGKo5C3GD7r0Hk dlneU1tw0zdYUbtOkY8xgXKX1EGyj5AWOua8qi9pFyIMJTnlCI5D+wNuGhxG7DOtD9iaL6qNU68F4 hnRcObhuadkZBbJGLMmDsIoqEt/EWLnUlJHQlwEHQ+eTIEktO+pqvu7tdDm2ojnSVpszCDm+TvUHw G+6uFFBKEgAgFrPfDF6fPSr04y5TuhKj10taD5K2t+FQ3nySYIwKBdUdQR5/fn6ZSYVpZMA9DWKuK VHqh/ZOAcFfif6uQ5PBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqR4U-00921n-H4; Fri, 26 Nov 2021 02:34:43 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqR4O-0091zr-Rg for linux-arm-kernel@lists.infradead.org; Fri, 26 Nov 2021 02:34:38 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6984C611BF; Fri, 26 Nov 2021 02:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637894076; bh=UIpFhI+ZxW78Zsk2Sx6TEyfvqhS6JuBdNd2I6o9pxl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0Go85qJO5mdTSyfMp1LcJnlNAuQu5lWfiNeQ31C0K7QjruTCrX8cq1zad3j/qALb Xt67YxxuCOGG5Ac/KpoXbcNbX+LVNnqJ7T9Eq5HBWjUioFlYvF3QqYD20/IHsUoxmZ tNolMo+htm9ZuPnBJNv6/6+iahRdNflGHpm3N/FD5lqMLrEUGg+3C/HWDHa4N0Hy0i 8LKqHb6cOViSg2HkRoTMjvY6kuu+OasyiFu9DFyilSvR+el8/eM1hFppBRZmAztu3D UymSlEqOrWMHSnCbQ9+8XMYfY+b0YU3oEWKHqe2/NIgBuCN2nzNSxGpOyAO7mOf6pv DTPD/fbu8MJIw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: German Gomez , James Clark , Alexander Shishkin , Jiri Olsa , John Garry , Leo Yan , Mark Rutland , Mathieu Poirier , Namhyung Kim , Will Deacon , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Sasha Levin , peterz@infradead.org, mingo@redhat.com, acme@kernel.org, andrew.kilroy@arm.com, linux-perf-users@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 26/28] perf inject: Fix ARM SPE handling Date: Thu, 25 Nov 2021 21:33:41 -0500 Message-Id: <20211126023343.442045-26-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211126023343.442045-1-sashal@kernel.org> References: <20211126023343.442045-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_183436_990781_639B02D7 X-CRM114-Status: GOOD ( 14.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: German Gomez [ Upstream commit 9e1a8d9f683260d50e0a14176d3f7c46a93b2700 ] 'perf inject' is currently not working for Arm SPE. When you try to run 'perf inject' and 'perf report' with a perf.data file that contains SPE traces, the tool reports a "Bad address" error: # ./perf record -e arm_spe_0/ts_enable=1,store_filter=1,branch_filter=1,load_filter=1/ -a -- sleep 1 # ./perf inject -i perf.data -o perf.inject.data --itrace # ./perf report -i perf.inject.data --stdio 0x42c00 [0x8]: failed to process type: 9 [Bad address] Error: failed to process sample As far as I know, the issue was first spotted in [1], but 'perf inject' was not yet injecting the samples. This patch does something similar to what cs_etm does for injecting the samples [2], but for SPE. [1] https://patchwork.kernel.org/project/linux-arm-kernel/cover/20210412091006.468557-1-leo.yan@linaro.org/#24117339 [2] https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/cs-etm.c?h=perf/core&id=133fe2e617e48ca0948983329f43877064ffda3e#n1196 Reviewed-by: James Clark Signed-off-by: German Gomez Cc: Alexander Shishkin Cc: Jiri Olsa Cc: John Garry Cc: Leo Yan Cc: Mark Rutland Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20211105104130.28186-2-german.gomez@arm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/arm-spe.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 3882a5360ada4..0350020acb96f 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -48,6 +48,7 @@ struct arm_spe { u8 timeless_decoding; u8 data_queued; + u64 sample_type; u8 sample_flc; u8 sample_llc; u8 sample_tlb; @@ -244,6 +245,12 @@ static void arm_spe_prep_sample(struct arm_spe *spe, event->sample.header.size = sizeof(struct perf_event_header); } +static int arm_spe__inject_event(union perf_event *event, struct perf_sample *sample, u64 type) +{ + event->header.size = perf_event__sample_event_size(sample, type, 0); + return perf_event__synthesize_sample(event, type, 0, sample); +} + static inline int arm_spe_deliver_synth_event(struct arm_spe *spe, struct arm_spe_queue *speq __maybe_unused, @@ -252,6 +259,12 @@ arm_spe_deliver_synth_event(struct arm_spe *spe, { int ret; + if (spe->synth_opts.inject) { + ret = arm_spe__inject_event(event, sample, spe->sample_type); + if (ret) + return ret; + } + ret = perf_session__deliver_synth_event(spe->session, event, sample); if (ret) pr_err("ARM SPE: failed to deliver event, error %d\n", ret); @@ -809,6 +822,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) else attr.sample_type |= PERF_SAMPLE_TIME; + spe->sample_type = attr.sample_type; + attr.exclude_user = evsel->core.attr.exclude_user; attr.exclude_kernel = evsel->core.attr.exclude_kernel; attr.exclude_hv = evsel->core.attr.exclude_hv; -- 2.33.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel