From patchwork Tue Jun 11 18:58:27 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: 166477 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2722289ilk; Tue, 11 Jun 2019 12:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyMjSa6ccf6Qp9iSAwhyHT7s5hX9XJVlDsJk1mfr8kmWFsV65FPXj5Qg8wLlPyy5wBH3Sp X-Received: by 2002:a65:5203:: with SMTP id o3mr21385229pgp.379.1560279749902; Tue, 11 Jun 2019 12:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560279749; cv=none; d=google.com; s=arc-20160816; b=1FDayw7rN9sTx6oGAyp7YmXVUYS9JqQs/x0lsilm1pOswxlhwJKR0SmJ9JfPNCBwco WYVx/iOCH1NuHwfN/wJommQ+NlwnqSpZXZ6iGFVNruGa5RVvBM0jzxQWExPQs3onwfvY v+sdiRFl98cmIQcGuCX3nsgDEcRX3SzHqdJ7C7orPaK6vEpWgQ9QpKgyv53mXCywdyyZ oKnjeAg+B/DbSppo0XV6oQ2LVnwRJlncODM+t5SSOjkjntV37PyF7aOw86WuTvbdnLqc P1TgRD3Yvfxaa6mITBZ9n9GNZvC6yMIbf0h4Zqh0buOddcRJ65Pu4dwr35+ttQxRgex3 rpHA== 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=Hh2JsiFfgHoRhnQRW5Z2dmb5cGKSl2Rd54BoNqWiqtk=; b=Vpbm5RPDuyiIW5KlZRJ+HNGoyJGQdKVNxSYkOElTRK7uHnCZwfhKJyWmSraJQZrG7p VUp8JWmYWyAO2DpQKqkPP7KJL4WkuNo50ccI2rcvyTeIrx3xT3aV9lc5rGGipeDltbVt NgeOLEur7MCieshenc/HU0x0hjOrOQVn9GJgOZa68aQFjkz8dx9VHqo9WY5ZLcEmKB0K CagJD2eJ3oxRXPToFRm4YWQCU5iPY/0v7Ko6a8qKiNw1bjAIVQyq+gWV6fmJDVvVz28C f6s8xvtClw6hsJCNyp07pVj2OJ4aywNLy8hdik6mefnHCpvYRtN96qlz2pXrnN36u4xr L3gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wZNjl5lj; 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 129si13932667pfb.270.2019.06.11.12.02.29; Tue, 11 Jun 2019 12:02:29 -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=wZNjl5lj; 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 S2404972AbfFKTC2 (ORCPT + 30 others); Tue, 11 Jun 2019 15:02:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:38618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392376AbfFKTC1 (ORCPT ); Tue, 11 Jun 2019 15:02:27 -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 B81FB2184C; Tue, 11 Jun 2019 19:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560279746; bh=K0DpfopyNYA6J2Lj0bP5xdn0OdW8Rb4/ZLP0V22+cvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wZNjl5ljl0FvmEz49GGKy5uN2g7cuzDB6cKXM28VVkT0q1WciI4Ju/MdQt7sxWgQz 2z33IsZN/lO0eAbfw3M1GhWJ45tqaPaZJwY6e03QHn9+l3GSu0WI1Qjj2VEh3pycHd nrU76SdaJbsMoLIkwq64hLe2AvtzMRliGAmp+QnA= 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 41/85] perf cs-etm: Add handling of switch-CPU-wide events Date: Tue, 11 Jun 2019 15:58:27 -0300 Message-Id: <20190611185911.11645-42-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 Add handling of SWITCH-CPU-WIDE events in order to add the tid/pid of the incoming process to the perf tools machine infrastructure. This information is later retrieved when a contextID packet is found in the trace stream. 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-6-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 2.20.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 0742c50fce46..5322dcaaf654 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1680,6 +1680,42 @@ static int cs_etm__process_itrace_start(struct cs_etm_auxtrace *etm, return 0; } +static int cs_etm__process_switch_cpu_wide(struct cs_etm_auxtrace *etm, + union perf_event *event) +{ + struct thread *th; + bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT; + + /* + * Context switch in per-thread mode are irrelevant since perf + * will start/stop tracing as the process is scheduled. + */ + if (etm->timeless_decoding) + return 0; + + /* + * SWITCH_IN events carry the next process to be switched out while + * SWITCH_OUT events carry the process to be switched in. As such + * we don't care about IN events. + */ + if (!out) + return 0; + + /* + * Add the tid/pid to the log so that we can get a match when + * we get a contextID from the decoder. + */ + th = machine__findnew_thread(etm->machine, + event->context_switch.next_prev_pid, + event->context_switch.next_prev_tid); + if (!th) + return -ENOMEM; + + thread__put(th); + + return 0; +} + static int cs_etm__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, @@ -1719,6 +1755,8 @@ static int cs_etm__process_event(struct perf_session *session, if (event->header.type == PERF_RECORD_ITRACE_START) return cs_etm__process_itrace_start(etm, event); + else if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE) + return cs_etm__process_switch_cpu_wide(etm, event); return 0; }