From patchwork Mon Jul 22 15:27:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13738911 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 2E0C0C3DA5D for ; Mon, 22 Jul 2024 15:30: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=KRn2GZZ7rqyxxxS3W1yWD0PtlBv3YIhE78qAMXkvguI=; b=tiA5N5kZQDJnp3vbmvBplIUHRv COS/hKV3K/6Ze4QpscVb35WJoIwPQtG1tF9cg1XMfrDUjbA+xl9V/S4yyZw8AdTSRSk4DtPGqODCr EHt0iBMDscNHYOAEQCIZsk70ojFt/LTtvQUw1HM6EhfrCkpTs7f4XkwAIoX3IpRnldb2GEuJ3ews/ 4o6Qtm2HTWLium/JVf9PJ9D2QikYJLFUH9JLwPa9nTUt0Rit4QL4dsuOBs8cl/GPhfQCym7yBqwPi t3h6PNzKt5qIa0bBzTjtYkgs/BJ7fCKHR4zhhYRWNwjM6pdMv3nJzDaUXC9dyAJMw6gQ3mynInvA+ FzdzADHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVuz5-00000009xG4-1QlQ; Mon, 22 Jul 2024 15:29:55 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVuy9-00000009wyJ-42fs for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2024 15:28:59 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3687f8fcab5so1959491f8f.3 for ; Mon, 22 Jul 2024 08:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721662136; x=1722266936; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KRn2GZZ7rqyxxxS3W1yWD0PtlBv3YIhE78qAMXkvguI=; b=YnOOJOgoXpVU1p72Yb/NjMS6mSMBBQBJ09dURb2OZ3DJNfQ0G4QEeyM0JFh91A242r of29bGp9srPfQaxsu6fOUjrL6jvJmaN6qvJLFO8aUalPn7iGe0Cy6vn2LseZV3s/XDTl sLdb5qZ3AMFFpwZoRIFLVuXfKQEsvRrDPcAaIfxxujJoL3RWRNNK3klO0l/xH1qzFAQf lPQAdFHNuJG1TAdMTWRsnR5Es1DgiFZOoOakFF+/dJpwjvSrEFWRH+tkp3Sbq9Ou3PVn 5m+KC20VXYSZJQTsZRz9cT9dMV7HG9fkFqFeOMvX97E0oEwM8F6BiBYqP9dSCVQL4ba7 gPIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721662136; x=1722266936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KRn2GZZ7rqyxxxS3W1yWD0PtlBv3YIhE78qAMXkvguI=; b=ByYuun9+kS5RS+lUlOw9Tg3S7aEBcqtjm3x++jBNkfGEzJ8lZ7HJXZh2KXq2xYxYZb ncx6hu1iXJ47SQWTc+whaJ+W52XkHSUj2XEY+rTOpU6V4UDxTynbz8dBCE3ay3so3kaX pT24+dQ6byUkyduODOptM4x9Bq9wyHXB2odNAGJBgtxqKE/EpUmbgS3zIYC3D/pmnhys qdgqOP9LC8/THuQt/7ap14at0FmwRBggn2+7JrQw7iHSFG1FTy6sQaXjQU8GtiTh2j8Z afuRSCI/eHurU7nwi8fXW9e+t/83H+U2SUqcxXuOHxjPbhqW3WOBKg6JveQSE5JaHrnn cFBQ== X-Forwarded-Encrypted: i=1; AJvYcCUzyPSRiEMOKVFbbazaW6AxQpCGJoUPbu2RhcENud1ZUjc7Yp0V4Z1PpZVrXoQUYgaUDCwM0Nm1UlvdjWePv+pypBLn7RO/z8n6/SW/5S6x5J0BPyI= X-Gm-Message-State: AOJu0YyowRlf8qd2Ts9dz8ktRuIEq+tzlNosHwSFPdWeJuYwEVBBwb7/ xlZqUSaadOyI5R0PVUWYwR2VmkAztqg069uylxzf2VhB/ftN9PPk8MiC1yINymY= X-Google-Smtp-Source: AGHT+IF7tKYq40uDVXznXPqhK+EAGVR7+QJEgApq+9Cj2Yd9pJFFjFsijIYOFzkudhGr0yO3VT9Q2g== X-Received: by 2002:adf:fa0f:0:b0:366:ebd1:3bc1 with SMTP id ffacd0b85a97d-369bae23a8cmr4451255f8f.3.1721662136027; Mon, 22 Jul 2024 08:28:56 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a43598sm160654535e9.1.2024.07.22.08.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 08:28:55 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, gankulkarni@os.amperecomputing.com, mike.leach@linaro.org, leo.yan@arm.com, suzuki.poulose@arm.com Cc: James Clark , John Garry , Will Deacon , James Clark , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] perf cs-etm: Output 0 instead of 0xdeadbeef when exception packets are flushed Date: Mon, 22 Jul 2024 16:27:56 +0100 Message-Id: <20240722152756.59453-2-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722152756.59453-1-james.clark@linaro.org> References: <20240722152756.59453-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240722_082858_106095_A2624DD9 X-CRM114-Status: GOOD ( 17.65 ) 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 Normally exception packets don't directly output a branch sample, but if they're the last record in a buffer then they will. Because they don't have addresses set we'll see the placeholder value CS_ETM_INVAL_ADDR (0xdeadbeef) in the output. Since commit 6035b6804bdf ("perf cs-etm: Support dummy address value for CS_ETM_TRACE_ON packet") we've used 0 as an externally visible "not set" address value. For consistency reasons and to not make exceptions look like an error, change them to use 0 too. This is particularly visible when doing userspace only tracing because trace is disabled when jumping to the kernel, causing the flush and then forcing the last exception packet to be emitted as a branch. With kernel trace included, there is no flush so exception packets don't generate samples until the next range packet and they'll pick up the correct address. Before: $ perf record -e cs_etm//u -- stress -i 1 -t 1 $ perf script -F comm,ip,addr,flags stress syscall ffffb7eedbc0 => deadbeefdeadbeef stress syscall ffffb7f14a14 => deadbeefdeadbeef stress syscall ffffb7eedbc0 => deadbeefdeadbeef After: stress syscall ffffb7eedbc0 => 0 stress syscall ffffb7f14a14 => 0 stress syscall ffffb7eedbc0 => 0 Signed-off-by: James Clark Reviewed-by: Mike Leach --- tools/perf/util/cs-etm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 5e9fbcfad7d4..d3e9c64d17d4 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1267,8 +1267,12 @@ static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq, static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) { - /* Returns 0 for the CS_ETM_DISCONTINUITY packet */ - if (packet->sample_type == CS_ETM_DISCONTINUITY) + /* + * Return 0 for packets that have no addresses so that CS_ETM_INVAL_ADDR doesn't + * appear in samples. + */ + if (packet->sample_type == CS_ETM_DISCONTINUITY || + packet->sample_type == CS_ETM_EXCEPTION) return 0; return packet->start_addr;