From patchwork Mon Jun 26 16:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13293162 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 52A94EB64DA for ; Mon, 26 Jun 2023 16:11: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: 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=amK2VLMXoFb49IKqOHkI700Ym+fjRDgPOXyVNdV5mDk=; b=tEbhv5i0/MH3NF 9EAillH1r4kUW0lEH3mGK8k5zZ2ggzNdaHMQeZgVRMPNytP1/WBv1qCPf/SOFywc8s3G6AdJIVhT/ RYIzAJxOfoWsq1xwES2U7Oi81zaeZI3JR/tflhRzLXaUo/lBpxMczzcrRMmkuLfw19GLgBLPpzQ9C 3vwh+YLE3jp6uSc7q7JuNwP/T/iaPwt45zqf0ou94MjIJOpwKGvyirnwIADtlBx2xfZpzorIjOpfT o6Hw/o7TSJJfSJyInvCfUHqKOs93lTfvj9Ja7BS4gSuc2lnoxO8UMpMS7DTpR+VPf6k/CbIRJ9/+N KLO/osrWb/fV3oomJ39g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qDooE-00Aaq4-2h; Mon, 26 Jun 2023 16:11:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qDoo6-00Aamd-2N for linux-arm-kernel@lists.infradead.org; Mon, 26 Jun 2023 16:11:16 +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 6774A13D5; Mon, 26 Jun 2023 09:11:55 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF9653F663; Mon, 26 Jun 2023 09:11:08 -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 1/2] perf cs-etm: Handle per-thread mode on EL1 host kernel case Date: Mon, 26 Jun 2023 17:10:57 +0100 Message-Id: <20230626161059.324046-2-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_091114_821406_1AF5D1CE X-CRM114-Status: GOOD ( 14.41 ) 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 In per-thread mode there are no context packets so no way to determine which type of context packets exist. But because it's only possible to trace host processes in per-thread mode without context packets then assume host in this case. This fixes the per-thread test case failures when running on nVHE: 98: Check Arm CoreSight trace data recording and synthesized samples: --- start --- ... Recording trace with '-e cs_etm/timestamp=0/ --per-thread' Looking at perf.data file for dumping branch samples: CoreSight basic testing with '-e cs_etm/timestamp=0/ --per-thread': FAIL Recording trace with '-e cs_etm/timestamp=1/ --per-thread' Looking at perf.data file for dumping branch samples: CoreSight basic testing with '-e cs_etm/timestamp=1/ --per-thread': FAIL ... Fixes: 8d3031d39fe8 ("perf cs-etm: Track exception level") Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 1419b40dfbe8..85821cc5650e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -900,10 +900,17 @@ static struct machine *cs_etm__get_machine(struct cs_etm_queue *etmq, /* * For any virtualisation based on nVHE (e.g. pKVM), or host kernels - * running at EL1 assume everything is the host. + * running at EL1, or no context IDs (per-thread mode) assume everything + * is the host. */ - if (pid_fmt == CS_ETM_PIDFMT_CTXTID) + switch (pid_fmt) { + case CS_ETM_PIDFMT_CTXTID: + case CS_ETM_PIDFMT_NONE: return &etmq->etm->session->machines.host; + case CS_ETM_PIDFMT_CTXTID2: + default: + break; + } /* * Not perfect, but otherwise assume anything in EL1 is the default