From patchwork Fri May 24 17:34:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 165145 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3885119ili; Fri, 24 May 2019 10:35:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNpgZDrXKzjRTQJiRM7QqJgMUGguPzFdLDp0Kd0bpcdBv3snOPezFqvEhYA9miAObbhvMC X-Received: by 2002:a65:5241:: with SMTP id q1mr12066407pgp.298.1558719316875; Fri, 24 May 2019 10:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558719316; cv=none; d=google.com; s=arc-20160816; b=AFErJioMeONJ1dfcijSVQojyU9i574KivZg5S95kVLQYc/u6DVelh0bEETjKCdiaEp eLYvGvbPIxAbG2ME7dUvTZWIlCkQH5ejlHHWDJRr3Nib8/Hv3UFkkm2fcCsGG4PxKQIE emjmqQYbxuPRPD3DNbWjXPNarzHkCzy/bu1NSQSuo+GrAL1ymMAOViWHhRX4CPve5LdO i6UK7GsvzZrYEGSmer+YZoXUIyJ/NyXhpQfAtIc9KO5hFJlpCNANWlYq6sg2mgkvhdn+ vzdk9oDZRQee1w8PBIjSNgc32IwzMkK6FOJ6Jdz0eLzJMjQdszkhLcGAOWhot53ZBluJ 5FhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=AZrEN/YdY4eKrQn36wY+GaRgnWiV23bSY81bJ8wnh7E=; b=VjA78ZdXO/2yElFBNh/WpaGNLDnUQm/t022bDybutaVeAXS5MhRGkwMEx1zRX0AA3S kjmS2iapwbVOsTTLMzpCCdXJkNjkNGDo2qUmXckNgFxu14r+drPrEEtm4nC2X0kNWBZq e24+SLxq9QwH8BDaXZwmnlnAeYTlnEkRsaqKFrbPyGRBBG7Za2oDoQF4FcKNqKk1fS/Q hLyC74fxiv0Q6wxKfWcLiKvFrK7PUSO2WVS/YwgMZJ9/pJdJKuYeuVrt4WM9Og8zEcMr eFlISfVQQLyme8PGMOdvKsIUPjiJDMB5JB6NS2864yCcogCLYreyd4KZjch7yCOedONx xljQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D22qwMvx; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si5078321pgv.338.2019.05.24.10.35.16; Fri, 24 May 2019 10:35:16 -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=@linaro.org header.s=google header.b=D22qwMvx; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391527AbfEXRfP (ORCPT + 30 others); Fri, 24 May 2019 13:35:15 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44711 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391301AbfEXRfN (ORCPT ); Fri, 24 May 2019 13:35:13 -0400 Received: by mail-pl1-f194.google.com with SMTP id c5so4434417pll.11 for ; Fri, 24 May 2019 10:35:12 -0700 (PDT) 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; bh=AZrEN/YdY4eKrQn36wY+GaRgnWiV23bSY81bJ8wnh7E=; b=D22qwMvxOv68Jbk8yGerAluLOCfagxSd4heu50CTNyczmf41/1BNWjQMJwAiayGx2w qna3aSLLtC3xLyupFWvVT7naW+d+e1y5Jb6lFKfizD75fsj9V76HNrx0EFkc59NmO6kS AURwwe0cV2bsPjZZTMNQhrO5T3YXKt1KvZq41Hs/XBgPWU4PdtApkKWnl/wGSazNJOgL Wq1U7spG/CMFNPo0fFMCCBTYui7aKgYhJG3HsJdYrT2P92gO25WICbl0fmzR1i/oiSjK XcsCe9xrrWhkZDqkGbGB++UPBC1yyr7dpNn5+Qt/s2k3zN40BWcdgkPKJsid2aSBYyFs 6c1w== 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; bh=AZrEN/YdY4eKrQn36wY+GaRgnWiV23bSY81bJ8wnh7E=; b=mh+63u/hw7KYK/jEynp6TOuB5TogfDho47I0NR30hqnbhpVwOAg0htRPPBEhsxOltk cUDZ6hlzMMBXhxwWkmZqdyrJyhQz4kwxMa6j+s0Q2VfQXFwjfImGbWomDUBsI27u5FER TsWfUIriJLvopOM8ZBh9+Q3ZlxrSzX06WYpHIqvUM1NKFHYAB6sVU95CYyxNgqVhVB0o 7WpZr3WX92tydEgSXqDMek+heYXw88U5R1p46bI42cKOi5Amag1mQ+pN1MaN5hTtOofV idxDiht+djkbimPTNYz1/Fl5JF2d9Q/8/D8UNSiSMd/Am0/NThYph+2mZpbAZOgCbCKh 8FBA== X-Gm-Message-State: APjAAAXWmAN2HDHnXEwPEncJu2lCk/pNxb0VBGe1ruNvzQgK93nwEhWQ jhImxyjjRhRjnflZScUjz89guw== X-Received: by 2002:a17:902:a70f:: with SMTP id w15mr38056183plq.222.1558719312533; Fri, 24 May 2019 10:35:12 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k13sm2809575pgr.90.2019.05.24.10.35.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 10:35:11 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org Cc: peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, suzuki.poulose@arm.com, leo.yan@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Subject: [PATCH v2 02/17] perf tools: Configure timestsamp generation in CPU-wide mode Date: Fri, 24 May 2019 11:34:53 -0600 Message-Id: <20190524173508.29044-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190524173508.29044-1-mathieu.poirier@linaro.org> References: <20190524173508.29044-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- tools/perf/arch/arm/util/cs-etm.c | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) -- 2.17.1 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 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr, 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 */