From patchwork Tue Jun 11 18:58:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 166484 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2722945ilk; Tue, 11 Jun 2019 12:03:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwES6lbKylzM2h988d3aAa7ipbIaoq6najJa+foF45i4QzY1jl+aRHdIfd3peOeOCHOJ0UO X-Received: by 2002:a63:4c1f:: with SMTP id z31mr22159484pga.334.1560279782026; Tue, 11 Jun 2019 12:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560279782; cv=none; d=google.com; s=arc-20160816; b=MTUcUmACY5YHxB1FNb1eZ9PvMhn9Asg1kR4xAs30bSHpMjFHGofKkefkBffqMLNsjd BKgNhdhg9D2FKHT2RZdSZZIuAE6rUxwXE7yIEClgjEvpq1Zp6NIbJdOy3hzhEsU47OR7 PcMVJFwYwurmQRIwpKxdzd1ltn9J67dtfpJhkbhIDSuKzdbodXXZ9SBng4iJMQ0Mgpai vTvQDkaBy9LAAQCqITtMbjCXtfwXPdRBpgRzhuKKAVw8dMK9JcRfSIgUilOCDF9/OZ7O twAB0Coy3l7n89qL7Ri00kOBx3g1ZKPPlA7+ZzVQPw0pZhqIW0o+ZhA5/Z/Duj8LoB9I FXnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qeXOlMtvQT/+J6v5KuI7aKeV7E0gk8EQoe9XrODec3c=; b=hbHp+AauOgxadGDI32zjEkHyi3v2+OOzo81nhF6o0gxFYmXVx2BOSLowUK1lsyw9yV fupd693NzwJNBbV9G2hw8DsYYZb0PXThlg90YeBsMY4aIvCbiTN3OsmB4zmSRAR6qhZY RphFTvKD1YqOlGT04V3r4cF0aEGQoQuQhbJFGHyI8xliPb25cDF2R0VFla2uhK5FH/NK 7z8Wi46zU1O+2wHCLq91QCTqx/xtUmUSwqUeH9I7OkBe5oxTBreGw2tDe+QWCKLHXTx5 jUfA2ozHg2c3Rl9dQ7nhN2ar+oYoDAoEpxSlnnA0MIOcI7Oh4cxIcI5oP/A1yXqiEJS3 XWeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aXic+bdS; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si14307129pfg.286.2019.06.11.12.03.01; Tue, 11 Jun 2019 12:03:02 -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=@kernel.org header.s=default header.b=aXic+bdS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392435AbfFKTDA (ORCPT + 30 others); Tue, 11 Jun 2019 15:03:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:39136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391474AbfFKTC6 (ORCPT ); Tue, 11 Jun 2019 15:02:58 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.35.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 368AC2184B; Tue, 11 Jun 2019 19:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560279777; bh=B6Q4bDYKlyzC/S0jqBgL7/O6Uc7TYaH3j4vbbLJ6NSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aXic+bdSHOMGjIYFN/r4KPMK3VzPGSh1eICxTh4TG5ObcEJF87uQ3682s8/hx4yZX MJDjJjmBnOICGE49hz3nObsScRHZktlMRhpBUbovtMeEMzInL7ECSqqWdRzT4PK9iH 4aFVbamTDJo4ar0Bgav145a9h0NkID42NVEUaSZw= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Leo Yan , Alexander Shishkin , Jiri Olsa , Peter Zijlstra , Suzuki Poulouse , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 48/85] perf cs-etm: Move tid/pid to traceid_queue Date: Tue, 11 Jun 2019 15:58:34 -0300 Message-Id: <20190611185911.11645-49-acme@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611185911.11645-1-acme@kernel.org> References: <20190611185911.11645-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier The tid/pid fields of structure cs_etm_queue are CPU dependent and as such need to be part of the cs_etm_traceid_queue in order to support CPU-wide trace scenarios. 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-13-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 44 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) -- 2.20.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 0d51d6d9a594..7e3b4d10f5c4 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -62,6 +62,7 @@ struct cs_etm_auxtrace { struct cs_etm_traceid_queue { u8 trace_chan_id; + pid_t pid, tid; u64 period_instructions; size_t last_branch_pos; union perf_event *event_buf; @@ -78,7 +79,6 @@ struct cs_etm_queue { struct cs_etm_decoder *decoder; struct auxtrace_buffer *buffer; unsigned int queue_nr; - pid_t pid, tid; u64 offset; const unsigned char *buf; size_t buf_len, buf_used; @@ -159,10 +159,14 @@ static int cs_etm__init_traceid_queue(struct cs_etm_queue *etmq, u8 trace_chan_id) { int rc = -ENOMEM; + struct auxtrace_queue *queue; struct cs_etm_auxtrace *etm = etmq->etm; cs_etm__clear_packet_queue(&tidq->packet_queue); + queue = &etmq->etm->queues.queue_array[etmq->queue_nr]; + tidq->tid = queue->tid; + tidq->pid = -1; tidq->trace_chan_id = trace_chan_id; tidq->packet = zalloc(sizeof(struct cs_etm_packet)); @@ -598,8 +602,6 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, queue->priv = etmq; etmq->etm = etm; etmq->queue_nr = queue_nr; - etmq->tid = queue->tid; - etmq->pid = -1; etmq->offset = 0; out: @@ -817,23 +819,19 @@ 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 auxtrace_queue *queue, + struct cs_etm_traceid_queue *tidq) { - struct cs_etm_traceid_queue *tidq; - struct cs_etm_queue *etmq = queue->priv; - - tidq = cs_etm__etmq_get_traceid_queue(etmq, CS_ETM_PER_THREAD_TRACEID); - /* CPU-wide tracing isn't supported yet */ if (queue->tid == -1) return; - if ((!tidq->thread) && (etmq->tid != -1)) + if ((!tidq->thread) && (tidq->tid != -1)) tidq->thread = machine__find_thread(etm->machine, -1, - etmq->tid); + tidq->tid); if (tidq->thread) - etmq->pid = tidq->thread->pid_; + tidq->pid = tidq->thread->pid_; } static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, @@ -850,8 +848,8 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, event->sample.header.size = sizeof(struct perf_event_header); sample.ip = addr; - sample.pid = etmq->pid; - sample.tid = etmq->tid; + sample.pid = tidq->pid; + sample.tid = tidq->tid; sample.id = etmq->etm->instructions_id; sample.stream_id = etmq->etm->instructions_id; sample.period = period; @@ -909,8 +907,8 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq, event->sample.header.size = sizeof(struct perf_event_header); sample.ip = ip; - sample.pid = etmq->pid; - sample.tid = etmq->tid; + sample.pid = tidq->pid; + sample.tid = tidq->tid; sample.addr = cs_etm__first_executed_instr(tidq->packet); sample.id = etmq->etm->branches_id; sample.stream_id = etmq->etm->branches_id; @@ -1758,9 +1756,19 @@ static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, for (i = 0; i < queues->nr_queues; i++) { struct auxtrace_queue *queue = &etm->queues.queue_array[i]; struct cs_etm_queue *etmq = queue->priv; + struct cs_etm_traceid_queue *tidq; + + if (!etmq) + continue; + + tidq = cs_etm__etmq_get_traceid_queue(etmq, + CS_ETM_PER_THREAD_TRACEID); + + if (!tidq) + continue; - if (etmq && ((tid == -1) || (etmq->tid == tid))) { - cs_etm__set_pid_tid_cpu(etm, queue); + if ((tid == -1) || (tidq->tid == tid)) { + cs_etm__set_pid_tid_cpu(etm, queue, tidq); cs_etm__run_decoder(etmq); } }