From patchwork Tue Feb 2 16:38:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12062255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88D83C433DB for ; Tue, 2 Feb 2021 16:40:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F42A64F54 for ; Tue, 2 Feb 2021 16:40:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F42A64F54 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AE+JTPdISrEMiNgNR7/d949GzZkVVMPIpVlfp0+lT/c=; b=CcZbk+39EOVBoGtVgW4yCOxJB PAR2gIUPhUQtT+Q2/exSv7v6Z2+NbrYBIaZKffQm3JPc2rwIjvmiHCrEfZT5gryGH9sMTeT+Fclyi xdIdCW3Jp25U2oa7AIeDcPWM8hg5E+WwmTpzi9u9U7TarVZ4Y7S7E3Ne2P3UsCOdyTDkZI8MHmjNK QlFyXO9thwzRvIT0zaQhOp35c4dVL2Pb2pvgCHNgmluARLNUc4hEMONKQqx7embF3IXbSGbL73KCg zaCxJdIHBVA4fCIwkytW4RMFTxBTwDkaVM1lepypYI8Y7pOSZ34apHXPgd0jnP92nOqIaYkfkHj7P RRToGHpZg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6yiM-0006J8-Io; Tue, 02 Feb 2021 16:39:42 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6yi9-0006Cv-Af for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2021 16:39:30 +0000 Received: by mail-pj1-x102d.google.com with SMTP id d2so2721918pjs.4 for ; Tue, 02 Feb 2021 08:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AW8CUVNikpRcfCmlQlkKe+p5l74C17GQZxwOIyIje8c=; b=sMKh1VDH4XQ4uNnZpqULVrGrFKyOK1UHUpKnfFvXTOF3DOv9YSlI9v6+EmTG0URk+l rgGFfFLLVSaG+OEpsBqycNJbn8F9JqbeqMjqGb0rmumIlH8fyKWbRJyDIDELigIpcO4w 5cREhHhVvKMluIKxx42crdk0aK9EZboWm0iPJf3UXxHwYXaE5xn56CweqY2pgCNXtl+X Vxx8cyYOBSMFpXmaV8El/CuAxnbm1URG1gZqjYplOQ9ZfJM2h7WZNc09u6Cx/l8NRGuj wyZ9KmWRn1CkaL1OHazf6SXbaf305m92NECrvoj8fiJtk9pC3vSAv2oD+XOUCbRCXvYV oRug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AW8CUVNikpRcfCmlQlkKe+p5l74C17GQZxwOIyIje8c=; b=TBGXg2sQVHZGpuou6H6em7TDCb/oTq5tZUO5YKLcS1Bls9qawYuISA02M9gP0tPvsM hQrFPYJD+a1hobRRJGh8cMWCw6ozqDFZWBaq5z8iKPchWZlnW2Z14HV/nSRLD/gFnlNy dPCiWMLTbDNdr3ZN/Liugh2FiDqJufneAmobSaHfsvidfbFPU3RL59omy3Y5Bn+nXYeE 48OR4tYlUjI52e4i42DqfqMId46oPvFR5sPKwEh+vpLQTVzkaVIWbEz/LSqUahS+HSuH o7TcMSi7Welm3war1ipBoB00RsQyFug1cTKngTU3t1C/YWhean1qwnQQwdwDPq6eZrh/ 86KQ== X-Gm-Message-State: AOAM532HAKUx8CqJ4+blZ+HQIcYyDxRzelHUXZJxkUlNMMFA+J2/m3gm IvXX3N8SUiNvOibvFs+dBQc6Cw== X-Google-Smtp-Source: ABdhPJxiAKNBNJDKgM6MXUFZjUxFiAN8UPHm4njx5CDHH1RDm+7QarExdpmAQyLvyYB9j3cl7Xcduw== X-Received: by 2002:a17:90b:1a8b:: with SMTP id ng11mr5468385pjb.160.1612283967292; Tue, 02 Feb 2021 08:39:27 -0800 (PST) Received: from localhost ([45.137.216.202]) by smtp.gmail.com with ESMTPSA id x3sm23344320pfp.98.2021.02.02.08.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 08:39:26 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Jonathan Corbet , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , Daniel Kiss , Denis Nikitin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] perf cs-etm: Detect pid in VMID for kernel running at EL2 Date: Wed, 3 Feb 2021 00:38:41 +0800 Message-Id: <20210202163842.134734-7-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210202163842.134734-1-leo.yan@linaro.org> References: <20210202163842.134734-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210202_113929_514090_DDBAB18E X-CRM114-Status: GOOD ( 19.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Al Grant , Leo Yan Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Suzuki K Poulose The PID of the task could be traced as VMID when the kernel is running at EL2. Teach the decoder to look for VMID when the CONTEXTIDR (Arm32) or CONTEXTIDR_EL1 (Arm64) is invalid but we have a valid VMID. Cc: Mike Leach Cc: Mathieu Poirier Cc: Al Grant Co-developed-by: Leo Yan Signed-off-by: Suzuki K Poulose Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose --- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 3f4bc4050477..fb2a163ff74e 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -6,6 +6,7 @@ * Author: Mathieu Poirier */ +#include #include #include #include @@ -491,13 +492,36 @@ cs_etm_decoder__set_tid(struct cs_etm_queue *etmq, const ocsd_generic_trace_elem *elem, const uint8_t trace_chan_id) { - pid_t tid; + pid_t tid = -1; + u64 pid_fmt; + int ret; - /* Ignore PE_CONTEXT packets that don't have a valid contextID */ - if (!elem->context.ctxt_id_valid) + ret = cs_etm__get_pid_fmt(trace_chan_id, &pid_fmt); + if (ret) + return OCSD_RESP_FATAL_SYS_ERR; + + /* + * Process the PE_CONTEXT packets if we have a valid contextID or VMID. + * If the kernel is running at EL2, the PID is traced in CONTEXTIDR_EL2 + * as VMID, Bit ETM_OPT_CTXTID2 is set in this case. + */ + switch (pid_fmt) { + case BIT(ETM_OPT_CTXTID): + if (elem->context.ctxt_id_valid) + tid = elem->context.context_id; + break; + case BIT(ETM_OPT_CTXTID2) | BIT(ETM_OPT_CTXTID): + case BIT(ETM_OPT_CTXTID2): + if (elem->context.vmid_valid) + tid = elem->context.vmid; + break; + default: + break; + } + + if (tid == -1) return OCSD_RESP_CONT; - tid = elem->context.context_id; if (cs_etm__etmq_set_tid(etmq, tid, trace_chan_id)) return OCSD_RESP_FATAL_SYS_ERR;