From mboxrd@z Thu Jan 1 00:00:00 1970 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.3 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 15257C433E0 for ; Sat, 13 Feb 2021 11:34:13 +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 C9EFD64DD8 for ; Sat, 13 Feb 2021 11:34:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9EFD64DD8 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=Cg1Y6HxhfoPetDfGnZR0xx477Xh4tWn7cw1hyvVWeRA=; b=gF3FWsiBeQ4Au3QOwGkmrLqXf AcZtKLGPE3TxSc3kEMLUk0K5Ke5gHW9Cuf2hoDI8T4SoGw3s8LrU44zAW4nh0i2XHTkPYUr0uwTvm KhUDQEA9oQf92ny1jiheIRvZTyNc0jGODjMS7KVEptEoaGDA8B3529G+t62waBvXqE+doBKdnCRIJ lfTWM7luJn7QgzHwfcOl8rVFJ8Xy6OUWDax7WEoONqWFn58iGNxBhUgIf54zyTrmrT9wPwPsCcCS+ Sh2+Z2282nO1T262+wnvb8quEGzh6fV+EzuV3ZKlhbCw2MgnGtIGrIfqJRc3PQiirzC5xlZi1z6NX a8+y4B2NA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lAtAg-0008K7-IK; Sat, 13 Feb 2021 11:33:06 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lAtAO-0008ET-3M for linux-arm-kernel@lists.infradead.org; Sat, 13 Feb 2021 11:32:51 +0000 Received: by mail-pf1-x42a.google.com with SMTP id k13so1199958pfh.13 for ; Sat, 13 Feb 2021 03:32:47 -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=e6PPt6Q0w52SGlwi3jxuH8NHG7/r6cFxIksj0jvT04Q=; b=EK00jZd7fBhtvrpq7rFToPozxX5PBjsyyvinkOIjI1day/gxjnZkqCmytiP4amIwqe gnfIqYMxZn4AOsME89943ha25ss38ujXrb5spdOoYsh25ZIXFltRUddFisUW2HrHg7v/ DSauF4g7TnwfVb29tt/EKxuL4ukugNq4jnwfbyzeCrQxx68DLbYxlVE5TTl6YlYsHGYw dXU+UkwoQQghzTi8iImr5rUYL5QfWbz1NSGVksfbDfsgLE7sFn6KMY820GYv2h5Cx2Od QoHLfbtlZvXO2DVZXrxsRD/iHPh4FAVnO57cXl4vBJY91PaT21Jcrm8KlKZMiiOZi0ba fxNA== 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=e6PPt6Q0w52SGlwi3jxuH8NHG7/r6cFxIksj0jvT04Q=; b=e5hlWc+L26r9Uf2pwoP0iugMx+wSov9lZp+MAtm3Sg1UekmNJbNsqUWnjMgScejrV/ KottRmIww2a3dBXlVdxcGzISFAwnm7EDBZF5BBOHNX9s8QX/z/67HnH8vPTdiEEwaOMy ubiaCxyI1E3a7D+QJKOP+mBX462CcwXUBGWxCTnzlS8yBr9B0N17A2/Q9UM36s842qNS j3jXNcqEpB5UlQqPUM8wglJw4qYH+NZsWaLB5DPkGRR+En99hbCV9gD2Trz6wXITVHjH vj93fXXSdE5qngxIOlR70YBptvpn+y9UwKo+5cobFmu0oqiLXbYgHHMy08zRiiI+l6UU +KAg== X-Gm-Message-State: AOAM532+5g9KsDVwiDaV4LWvbY9JQoVFyz6eD61RY84jypuHjQWZ9Ikr LQPTkXVqxWMRmg8367pxhCFi1A== X-Google-Smtp-Source: ABdhPJwo1LlrC26KOPPXr+TQvOf0ij8fmS73jkfYqITgdzmieo3kXeHK4EIaOYc9g1iYgnYeYkFSqg== X-Received: by 2002:a63:9811:: with SMTP id q17mr7275763pgd.238.1613215965600; Sat, 13 Feb 2021 03:32:45 -0800 (PST) Received: from localhost ([45.137.216.202]) by smtp.gmail.com with ESMTPSA id f28sm13056434pfk.182.2021.02.13.03.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Feb 2021 03:32:45 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 5/5] perf cs-etm: Detect pid in VMID for kernel running at EL2 Date: Sat, 13 Feb 2021 19:32:20 +0800 Message-Id: <20210213113220.292229-6-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210213113220.292229-1-leo.yan@linaro.org> References: <20210213113220.292229-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-20210213_063248_378826_263A8257 X-CRM114-Status: GOOD ( 19.41 ) 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 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: 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 Signed-off-by: Suzuki K Poulose Co-developed-by: Leo Yan Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier --- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 38 +++++++++++++++++-- 1 file changed, 34 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..4052c9ce6e2f 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,42 @@ 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; + static u64 pid_fmt; + int ret; - /* Ignore PE_CONTEXT packets that don't have a valid contextID */ - if (!elem->context.ctxt_id_valid) + /* + * As all the ETMs run at the same exception level, the system should + * have the same PID format crossing CPUs. So cache the PID format + * and reuse it for sequential decoding. + */ + if (!pid_fmt) { + 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): + 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; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel