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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 1AC32C433DB for ; Tue, 2 Feb 2021 16:43:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA55664F7F for ; Tue, 2 Feb 2021 16:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236773AbhBBQmv (ORCPT ); Tue, 2 Feb 2021 11:42:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236751AbhBBQkE (ORCPT ); Tue, 2 Feb 2021 11:40:04 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 473F2C061786 for ; Tue, 2 Feb 2021 08:39:24 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id z21so15250661pgj.4 for ; Tue, 02 Feb 2021 08:39:24 -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=V2lSRSt7N2kcQ0+pfELKM7JZFhVM2Dwdlyux9eP2c0c=; b=sayQXgMDWznfBbxktPHzwshYZhmop5peILAxFgiQn94AIcgnL/xRLNVph3GW6XuCT3 GB0Z3A8HWWs7pWAD2gGXwIUQoLn3hB7yQxYRJP3K4vGvfAurjIWNHhTWn7a2BmuOwsGO EpPo9HRIhO2Aa61VVThHtGtr5AE3UFy6imSWxpeS3hMHXzrB9/QInfPdz7hKEkD24AwO 2wGLsOy+5p0IsgZZogeWQfxti+mhErSZAf2IZpf2A72uZnytyrmKMyqeQ1E3TDQCqHET EaGe5l4rHnIb/d+YdIE9xi4ezl+Y3Np8mufbnhR5lSrJeyuXj07GW3iAwD7BFzt3jK0q JISA== 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=V2lSRSt7N2kcQ0+pfELKM7JZFhVM2Dwdlyux9eP2c0c=; b=l7ZwLC6sBar3/pWNbVihqfchX4V4IPfiumX/zXX4BXkFUxvp/dYhbhAp9WlHDTADIv dbPRSuz8ssZTrsHjWU9/H+DNNxG/OgOVPnwWaNu3eMNUvyKE86Wdq5DnwgG4pZbZ00pv qpxies+chvBK3rAYWcpFwswc0qUPLfNqdpFromKt8xO9CaJIel28J4/QDkeWskJLE/es 3TiKpZHu+LbXlgtXoe4n10y/MTkygf7wk5aMDXf2V22iTLilcdI1CZf4faFDv3pIA3AC Ts0Krox2QuSza4nxxWa03v68jHlFAkgO54WHTB2o48OKH7vnZCqSi/D6azCTg9ThvRUv 1QvA== X-Gm-Message-State: AOAM532rJe5QFG/KJSf8sMBbUkbzUJgU8ZNI/ciKDt2C2RUHltenj1eE XvVX0TY7CS5RLOsa8o7NEeSX1A== X-Google-Smtp-Source: ABdhPJyS6ootz5/MUIbpCq0nnbh/qg8NapSJATnyWajH1UfDBRNOOGycEMGhBKOnWlDY9XhgE5qz6w== X-Received: by 2002:aa7:83c2:0:b029:1a5:daa9:f22f with SMTP id j2-20020aa783c20000b02901a5daa9f22fmr21612501pfn.48.1612283963844; Tue, 02 Feb 2021 08:39:23 -0800 (PST) Received: from localhost ([45.137.216.202]) by smtp.gmail.com with ESMTPSA id a37sm21936861pgm.79.2021.02.02.08.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 08:39:23 -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 Cc: Leo Yan Subject: [PATCH v2 5/7] perf cs-etm: Add helper cs_etm__get_pid_fmt() Date: Wed, 3 Feb 2021 00:38:40 +0800 Message-Id: <20210202163842.134734-6-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds helper function cs_etm__get_pid_fmt(), by passing parameter "traceID", it returns the PID format. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 43 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/cs-etm.h | 1 + 2 files changed, 44 insertions(+) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index a2a369e2fbb6..8194ddbd01e5 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -156,6 +157,48 @@ int cs_etm__get_cpu(u8 trace_chan_id, int *cpu) return 0; } +/* + * The returned PID format is presented by two bits: + * + * Bit ETM_OPT_CTXTID: CONTEXTIDR or CONTEXTIDR_EL1 is traced; + * Bit ETM_OPT_CTXTID2: CONTEXTIDR_EL2 is traced. + * + * It's possible that these two bits are set together, this means the tracing + * contains PIDs for both CONTEXTIDR_EL1 and CONTEXTIDR_EL2. + */ +int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt) +{ + struct int_node *inode; + u64 *metadata, val; + + inode = intlist__find(traceid_list, trace_chan_id); + if (!inode) + return -EINVAL; + + metadata = inode->priv; + + if (metadata[CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { + val = metadata[CS_ETM_ETMCR]; + /* CONTEXTIDR is traced */ + if (val & BIT(ETM_OPT_CTXTID)) + *pid_fmt = BIT(ETM_OPT_CTXTID); + } else { + val = metadata[CS_ETMV4_TRCCONFIGR]; + + *pid_fmt = 0; + + /* CONTEXTIDR_EL2 is traced */ + if (val & (BIT(ETM4_CFG_BIT_VMID) | BIT(ETM4_CFG_BIT_VMID_OPT))) + *pid_fmt = BIT(ETM_OPT_CTXTID2); + + /* CONTEXTIDR_EL1 is traced */ + if (val & BIT(ETM4_CFG_BIT_CTXTID)) + *pid_fmt |= BIT(ETM_OPT_CTXTID); + } + + return 0; +} + void cs_etm__etmq_set_traceid_queue_timestamp(struct cs_etm_queue *etmq, u8 trace_chan_id) { diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index 4ad925d6d799..7cc3bba0017d 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -173,6 +173,7 @@ struct cs_etm_packet_queue { int cs_etm__process_auxtrace_info(union perf_event *event, struct perf_session *session); int cs_etm__get_cpu(u8 trace_chan_id, int *cpu); +int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt); int cs_etm__etmq_set_tid(struct cs_etm_queue *etmq, pid_t tid, u8 trace_chan_id); bool cs_etm__etmq_is_timeless(struct cs_etm_queue *etmq); -- 2.25.1