Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2902218ybi; Mon, 17 Jun 2019 12:22:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFzm/xSHNnK/0RaPn7NcEb/bAj6GEImidbm4+/CO7hCQkQSglgbxZCbv6TW0hoZ+e2CLrb X-Received: by 2002:a62:3103:: with SMTP id x3mr33901602pfx.107.1560799372895; Mon, 17 Jun 2019 12:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560799372; cv=none; d=google.com; s=arc-20160816; b=p/tBDyC2AUh8CMZLKAM9tAJVNcd7iQ4LASbxbqhsohQOLHQSeTUzD6E4A6KniYO1fV Self3QxiddZkO3/ftWZzSxSyegzRODHnzC3s2NEylKOYv7/Iy5Ij6BVSl8GSV5OouLQx 8lxGacuID4ag14FEGt5zUckB5bKaARYdZnziEDbA0Xjtb6jSjR0SQnAJLDDDswmVJUjV eafvwhVSL0/bK2VmfzcLvf2d1JcfOF7aXYG3YiskmP5Gsrif8yM4PH8qrxe9Nbt4COM3 RiWdalFNgtZh3BZuKnIb8JwcFZrbR/y1l7DGX8VSk5Gdgzy+rn8HIwHkdQhiSqjE0Vxj Q5VA== 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=KA5D41dpDaw8lXCMv2MsVclwjNxtdAVn+2wXzflv/Nc=; b=oPHH7YVEc7hSokVzEWKMxUChPBU0h8hQDBadBLYkYrsSroD6/h6I55UGHFWYk7YvRL yMYvvzyWqNGhMQGAvXjdoSmRQb1SGNm+oGz1sLj0TboXKdXC4n4b9PpBkbldURPctnJV 0KyxzbWUkYjWim2sE08VuOGxsecgiT27HqsIYf89U28bZyjvAnAq+8/uD1Xe5J8rQHOR wYZ0AC6KYs35of2NB/YsvCSP+7B4Pj2mbI2lH+pnuMBVz+PJmacKehdNnpp1eGOV2J0Z P3Ssq1H0e/US7120US+88BUFmSsqdMGgh15dQYkvP+Et4pp2lzgeLf08TnTrfCVjqIFc TvfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=BY2+6jqa; 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 a11si11617291pgj.537.2019.06.17.12.22.38; Mon, 17 Jun 2019 12:22:52 -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=BY2+6jqa; 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 S1727732AbfFQTVP (ORCPT + 99 others); Mon, 17 Jun 2019 15:21:15 -0400 Received: from terminus.zytor.com ([198.137.202.136]:51485 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbfFQTVO (ORCPT ); Mon, 17 Jun 2019 15:21:14 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5HJKro83560486 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 17 Jun 2019 12:20:53 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5HJKro83560486 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1560799254; bh=KA5D41dpDaw8lXCMv2MsVclwjNxtdAVn+2wXzflv/Nc=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=BY2+6jqa8AVw1+3swP9iM+kKIxd4HcfbI3xoyUUr0Em5FGyY1ZUIX+2CCc1hmsN3+ 0QJKds6b//UcbDpUEuy++fpPO8hO0OpML2Ta8WFt42qmp3xchM9yDQz81m8DWMYXf2 qF1jZNI45TpMo/0aHqanrOFyn5eVhxTLZNaII13ihbw5X3lH95r4h4zcBZRDDyn/75 lYAE7w/Piu9vdnKv1FVLzUwKtL2BRQhBw/e0jXSqtB03x6ft3RgQamDLJImBIJLCn2 72wiVtY4PjWwq97vPZMDgydnZho+yMTN3ny0hISnwtd/LsJVQQNSlOhobsVK+IoGCw Vvft0nuQX+ZYQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5HJKrAb3560483; Mon, 17 Jun 2019 12:20:53 -0700 Date: Mon, 17 Jun 2019 12:20:53 -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: peterz@infradead.org, suzuki.poulose@arm.com, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, mathieu.poirier@linaro.org, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, leo.yan@linaro.org, acme@redhat.com, alexander.shishkin@linux.intel.com Reply-To: jolsa@redhat.com, mingo@kernel.org, tglx@linutronix.de, suzuki.poulose@arm.com, peterz@infradead.org, hpa@zytor.com, mathieu.poirier@linaro.org, namhyung@kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, acme@redhat.com In-Reply-To: <20190524173508.29044-3-mathieu.poirier@linaro.org> References: <20190524173508.29044-3-mathieu.poirier@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf cs-etm: Configure timestamp generation in CPU-wide mode Git-Commit-ID: 1c839a5a4061bf4554430037b04a115efc9dd8a1 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: 1c839a5a4061bf4554430037b04a115efc9dd8a1 Gitweb: https://git.kernel.org/tip/1c839a5a4061bf4554430037b04a115efc9dd8a1 Author: Mathieu Poirier AuthorDate: Fri, 24 May 2019 11:34:53 -0600 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 10 Jun 2019 15:50:01 -0300 perf cs-etm: Configure timestamp generation in CPU-wide mode When operating in CPU-wide mode tracers need to generate timestamps in order to correlate the code being traced on one CPU with what is executed on other CPUs. 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-3-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/cs-etm.c | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 3912f0bf04ed..be1e4f20affa 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -99,6 +99,54 @@ out: return err; } +static int cs_etm_set_timestamp(struct auxtrace_record *itr, + struct perf_evsel *evsel, int cpu) +{ + struct cs_etm_recording *ptr; + struct perf_pmu *cs_etm_pmu; + char path[PATH_MAX]; + int err = -EINVAL; + u32 val; + + ptr = container_of(itr, struct cs_etm_recording, itr); + cs_etm_pmu = ptr->cs_etm_pmu; + + if (!cs_etm_is_etmv4(itr, cpu)) + goto out; + + /* Get a handle on TRCIRD0 */ + snprintf(path, PATH_MAX, "cpu%d/%s", + cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR0]); + err = perf_pmu__scan_file(cs_etm_pmu, path, "%x", &val); + + /* There was a problem reading the file, bailing out */ + if (err != 1) { + pr_err("%s: can't read file %s\n", + CORESIGHT_ETM_PMU_NAME, path); + goto out; + } + + /* + * TRCIDR0.TSSIZE, bit [28-24], indicates whether global timestamping + * is supported: + * 0b00000 Global timestamping is not implemented + * 0b00110 Implementation supports a maximum timestamp of 48bits. + * 0b01000 Implementation supports a maximum timestamp of 64bits. + */ + val &= GENMASK(28, 24); + if (!val) { + err = -EINVAL; + goto out; + } + + /* All good, let the kernel know */ + evsel->attr.config |= (1 << ETM_OPT_TS); + err = 0; + +out: + return err; +} + static int cs_etm_set_option(struct auxtrace_record *itr, struct perf_evsel *evsel, u32 option) { @@ -118,6 +166,11 @@ static int cs_etm_set_option(struct auxtrace_record *itr, if (err) goto out; break; + case ETM_OPT_TS: + err = cs_etm_set_timestamp(itr, evsel, i); + if (err) + goto out; + break; default: goto out; } @@ -343,6 +396,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, err = cs_etm_set_option(itr, cs_etm_evsel, ETM_OPT_CTXTID); if (err) goto out; + + err = cs_etm_set_option(itr, cs_etm_evsel, ETM_OPT_TS); + if (err) + goto out; } /* Add dummy event to keep tracking */