Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2909354ybi; Mon, 17 Jun 2019 12:31:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8eiWyDu7Y3iFgM1nSMhkD+vq39SQwm81xTbML3/aD4JcPW4N7DsB0pqljZoyP6cKcMxny X-Received: by 2002:a17:90a:380d:: with SMTP id w13mr549964pjb.138.1560799888385; Mon, 17 Jun 2019 12:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560799888; cv=none; d=google.com; s=arc-20160816; b=iSY6PPiJt2fFBRmXKCv2G18UKZd1Eqz5rkCWTiry7Cb6NNtbSE3obq9uXm/N8VUybb sTcfGA89rKygqqrsXTWTr7dyrTxaUj+QF5cLi99//lVSuLBlc436W6bLMYX9qzBD7bsW 6Kz9wV42Df2tR/SqvibiPLkbLW0gi80Wyoy7xqNksg9dQ9p2nJscQAUuP6uSGa8Sq005 33WkjomFHBSqBgHJLL1e0N5tqfeHPpEFWqh7BKW3Y32ZeXHXOgHd5VDpFGNRPOgUAtXb iTxCVtSppIChvxH9MXdwV4V6wEp8szfALIrQdzjjYrBXNF0DdmeH4b4i5zpXesGTBlkq AxRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=Wab4JSezjhdoD2MmlO1AeozBl1srNTDPVg+gQh4hrvc=; b=e2pQbE6JiQNfAXezfl1H9AAj1WLEoGvNAfB35SG1xLUwSAgIzQiutwsix+YGF8eiLr IroA/XOKIZokc79+aw1/G2LmXkkWg95tLSPXvTpxRXPyKziU+1vpIBcmRgbA5Sxu+vn5 QR58oj+3IiDyQH8zL02fTdiZHrjhpreRXeYos+IMEQv8dUmFsPpxjXlQTv1AYPfZhMSg +hxNULI5ucUtly1SC56vIwE9WmlAzTiWAcJCJ+2LcOz5xnNonXbW5GNhFQ0dsWIswYSy xm3NWBeHeULbg4Yie2dOVtpdmakeHJPuHGX5RtCSP0miBOINFIWvTjvFHgDg2KpaQPnS K+VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b="RJ/f9p4r"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m15si5759194pff.267.2019.06.17.12.31.10; Mon, 17 Jun 2019 12:31:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b="RJ/f9p4r"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729114AbfFQTaS (ORCPT + 99 others); Mon, 17 Jun 2019 15:30:18 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45271 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfFQTaR (ORCPT ); Mon, 17 Jun 2019 15:30:17 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5HJTuCo3564246 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 17 Jun 2019 12:29:56 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5HJTuCo3564246 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1560799796; bh=Wab4JSezjhdoD2MmlO1AeozBl1srNTDPVg+gQh4hrvc=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=RJ/f9p4rrVumXFmlEv0Dij31us5c1xs4lDQpfVuAn/xVhFuPTTqp9CUVqwF3Ri9Ez ExUOHiIv3G9GiPs4EPSoM6AteRz0OX1l2BNbSOWEWv6hptfZMQVlWZxzkYUUhWpA9R I82+DkIslLdAFVcI08tfkPjH4LGdkrUtFKNsqL8fTYfEaGj5LrDk1rfwbDb5qZYO5l tQ3Pt13OxxaNJ3VzoTJWtKZxY+NtDd85K71C06dNSU46GYiTHBNdm0yT9GfgWbVTKW ujSUJUAEZIIjHUImAGzu2RrsnlCIzhFhdeGCAp0lRgLDK2Qq8JdszqDSCE53W1jHmc NFjPTytHMYuQA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5HJTubn3564243; Mon, 17 Jun 2019 12:29:56 -0700 Date: Mon, 17 Jun 2019 12:29:56 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Mathieu Poirier Message-ID: Cc: mathieu.poirier@linaro.org, mingo@kernel.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, leo.yan@linaro.org, namhyung@kernel.org, acme@redhat.com, suzuki.poulose@arm.com, hpa@zytor.com, tglx@linutronix.de, jolsa@redhat.com Reply-To: tglx@linutronix.de, jolsa@redhat.com, mathieu.poirier@linaro.org, mingo@kernel.org, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, peterz@infradead.org, hpa@zytor.com, namhyung@kernel.org, leo.yan@linaro.org, acme@redhat.com, suzuki.poulose@arm.com In-Reply-To: <20190524173508.29044-16-mathieu.poirier@linaro.org> References: <20190524173508.29044-16-mathieu.poirier@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf cs-etm: Linking PE contextID with perf thread mechanic Git-Commit-ID: 0a6be300eb7b9f6630d565e213a904e5c75a86c0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0a6be300eb7b9f6630d565e213a904e5c75a86c0 Gitweb: https://git.kernel.org/tip/0a6be300eb7b9f6630d565e213a904e5c75a86c0 Author: Mathieu Poirier AuthorDate: Fri, 24 May 2019 11:35:06 -0600 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 10 Jun 2019 15:50:02 -0300 perf cs-etm: Linking PE contextID with perf thread mechanic Link contextID packets received from the decoder with the perf tool thread mechanic so that we know the specifics of the process currently executing. Signed-off-by: Mathieu Poirier Tested-by: Leo Yan Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190524173508.29044-16-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 20 ++++++++++++++++ tools/perf/util/cs-etm.c | 32 ++++++++++++++++++++----- tools/perf/util/cs-etm.h | 10 ++++++++ 3 files changed, 56 insertions(+), 6 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 87264b79de0e..ce85e52f989c 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -402,6 +402,24 @@ cs_etm_decoder__buffer_exception_ret(struct cs_etm_packet_queue *queue, CS_ETM_EXCEPTION_RET); } +static ocsd_datapath_resp_t +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; + + /* Ignore PE_CONTEXT packets that don't have a valid contextID */ + if (!elem->context.ctxt_id_valid) + 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; + + return OCSD_RESP_CONT; +} + static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( const void *context, const ocsd_trc_index_t indx __maybe_unused, @@ -440,6 +458,8 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( trace_chan_id); break; case OCSD_GEN_TRC_ELEM_PE_CONTEXT: + resp = cs_etm_decoder__set_tid(etmq, elem, trace_chan_id); + break; case OCSD_GEN_TRC_ELEM_ADDR_NACC: case OCSD_GEN_TRC_ELEM_TIMESTAMP: case OCSD_GEN_TRC_ELEM_CYCLE_COUNT: diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index afc2491f9f2a..17adf554b679 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -907,13 +907,8 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) } static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, - struct auxtrace_queue *queue, struct cs_etm_traceid_queue *tidq) { - /* CPU-wide tracing isn't supported yet */ - if (queue->tid == -1) - return; - if ((!tidq->thread) && (tidq->tid != -1)) tidq->thread = machine__find_thread(etm->machine, -1, tidq->tid); @@ -922,6 +917,31 @@ static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, tidq->pid = tidq->thread->pid_; } +int cs_etm__etmq_set_tid(struct cs_etm_queue *etmq, + pid_t tid, u8 trace_chan_id) +{ + int cpu, err = -EINVAL; + struct cs_etm_auxtrace *etm = etmq->etm; + struct cs_etm_traceid_queue *tidq; + + tidq = cs_etm__etmq_get_traceid_queue(etmq, trace_chan_id); + if (!tidq) + return err; + + if (cs_etm__get_cpu(trace_chan_id, &cpu) < 0) + return err; + + err = machine__set_current_tid(etm->machine, cpu, tid, tid); + if (err) + return err; + + tidq->tid = tid; + thread__zput(tidq->thread); + + cs_etm__set_pid_tid_cpu(etm, tidq); + return 0; +} + static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq, u64 addr, u64 period) @@ -1866,7 +1886,7 @@ static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, continue; if ((tid == -1) || (tidq->tid == tid)) { - cs_etm__set_pid_tid_cpu(etm, queue, tidq); + cs_etm__set_pid_tid_cpu(etm, tidq); cs_etm__run_decoder(etmq); } } diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index f16082d37ab5..b2a7628620bf 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -181,6 +181,8 @@ 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__etmq_set_tid(struct cs_etm_queue *etmq, + pid_t tid, u8 trace_chan_id); struct cs_etm_packet_queue *cs_etm__etmq_get_packet_queue(struct cs_etm_queue *etmq, u8 trace_chan_id); #else @@ -197,6 +199,14 @@ static inline int cs_etm__get_cpu(u8 trace_chan_id __maybe_unused, return -1; } +static inline int cs_etm__etmq_set_tid( + struct cs_etm_queue *etmq __maybe_unused, + pid_t tid __maybe_unused, + u8 trace_chan_id __maybe_unused) +{ + return -1; +} + static inline struct cs_etm_packet_queue *cs_etm__etmq_get_packet_queue( struct cs_etm_queue *etmq __maybe_unused, u8 trace_chan_id __maybe_unused)