From patchwork Mon Jun 26 16:10:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13293163 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 3319EEB64DC for ; Mon, 26 Jun 2023 16:11: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: 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=stlEiT8XDh/gIDtgS61FrNnlxz6atb4MLqCQIU78wn8=; b=w28bxI5iBOiHpJ BXWcfvR8O4SAI9i1TEzsiWHoxO3lmJmGJOVwPjuJSiPKIg9hf05QxNXnl0s8vEC06+N0c3tPCzS0w pc1TyJPPhx9E/ppE+aB/V66MFGavjEi1EsAbLdTeayS4AW2lyEvAxLD/0ZoPnJ8+G2SynjdzvNj1L EHofhnZEWplL11PAjuCNKXvkfzAeMXtNabeYiMBfgk3JG6n78JYpR8HWyHfU3MMy7SwqzpOkyFjf6 u0JDckMf+//t51ZBi9/Q0Z1y4lDS2lhKmFgBQjfJ6szq+ccHqYmoUWaEke3ntbh23860G0/9evPIQ QYkvbplPhVDR7QJKTw/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qDooF-00Aaqa-16; Mon, 26 Jun 2023 16:11:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qDoo9-00AaoK-1C for linux-arm-kernel@lists.infradead.org; Mon, 26 Jun 2023 16:11:18 +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 68E00143D; Mon, 26 Jun 2023 09:11:58 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D39D63F663; Mon, 26 Jun 2023 09:11:11 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] perf report: Don't add to histogram when there is no thread found Date: Mon, 26 Jun 2023 17:10:58 +0100 Message-Id: <20230626161059.324046-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230626161059.324046-1-james.clark@arm.com> References: <20230626161059.324046-1-james.clark@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230626_091117_453630_B8E8B9A4 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 thread__find_map() chooses to exit without assigning a thread to the addr_location in some scenarios, for example when there are samples from a guest and perf_guest == false. This results in a segfault when adding to the histogram because it uses unguarded accesses to the thread member of the addr_location. Fix it by exiting early if no thread is set. This fixes the referenced commit when using perf report with Coresight but probably isn't exclusive to that case. Fixes: 8d3031d39fe8 ("perf cs-etm: Track exception level") Signed-off-by: James Clark Acked-by: Ian Rogers --- tools/perf/builtin-report.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index dcedfe00f04d..1a2caa4ce5c3 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -293,6 +293,9 @@ static int process_sample_event(struct perf_tool *tool, goto out_put; } + if (!al.thread) + goto out_put; + if (rep->stitch_lbr) thread__set_lbr_stitch_enable(al.thread, true);