From patchwork Tue Jun 11 18:58:24 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: 166474 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2721986ilk; Tue, 11 Jun 2019 12:02:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxE7YJ6q7SpGFBcqJys2w+Fl6joCMn31tpygPUtJKIYwc62EjumyJOuA+DTiZ5nWaLmTrFX X-Received: by 2002:a63:184:: with SMTP id 126mr21415495pgb.420.1560279736622; Tue, 11 Jun 2019 12:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560279736; cv=none; d=google.com; s=arc-20160816; b=rCYT6OzeV2Btpo5panI5gUXan+2TytdLHKYiTj+1uaKJChRyuzUs64ZqWQQ27hHAaB DQDF9XFZBXCE3aQwRqSpQC7PnmJFZiPEyO0dkgD6J0TqdNK0TCMSzY9AUvd26RMotJ1X L1Uc76pmYctTfv38EUkdP4u61CN/yhzeWNghmGGiSp392v5pKIQMDXeXA/yWPGkULJRR 0fO9dPAKhpglHRxvCp4rTUe0vaNBjc/ekOGheqiyPpAUxXCqfNniM+6/cb3Li5oR10jR ecnCWHIHXPSHkgOjw/0qWmfu1GUaO8h1hCOjLVhyZJ4sicQtNzVYXJr6F4LDeQAO3F4m 2jVw== 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=6ljZSqRzLoem9DQyd6Ae1YQaIP52VNEA7TXvKcPg2do=; b=TpeZ2JYCoBTqrIwc8fSaVBIBI3HkVsc6MJmaQjTcMx0eDhx7Y4dtnvgOranX6X46NY Oi/oGiO7ZNJyykNz7RvSyx4Efhz98aFCcN1RthRmGzwTZJEL+8nuwusJjfd1OEOiYngo Y8ozgx1SVqnSkEcUiUws3oKAz1h7mfT2rYfEAmxbXwbB5rxuke4whcsKe35n08mo23Mj 3c5th6TBCcelpCDBe63s/i6bDJpd9vU42dwwXVY2NfgtECHFuc9XDl7Oa9rIz0OhiA95 9riTgWm/jRJEydoznebfaJnUFRa4WSNV0bkI/xQLQP40hj3oe0Av59Don9TRhx9AkWJW VH2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m7gJ7Cux; 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 t23si5847285pgu.320.2019.06.11.12.02.16; Tue, 11 Jun 2019 12:02: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=@kernel.org header.s=default header.b=m7gJ7Cux; 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 S2392361AbfFKTCP (ORCPT + 30 others); Tue, 11 Jun 2019 15:02:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:38370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391901AbfFKTCO (ORCPT ); Tue, 11 Jun 2019 15:02:14 -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 20AF12183F; Tue, 11 Jun 2019 19:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560279733; bh=cDrzeJSkXqGaacGcyOg5AohAub8v5Pm5EBqkuiQbOi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7gJ7Cux9lSXuM4wOzBZpNj0jKbOfAcQmw1T1l59P6NrhcHyxkWQ3fEnv6RneNrLF cdBwjHMOMtdEfU5TuzySss7YyCJmvODSTNY8yOSqU8dK6lxyDUXmS+wR5164OjqBS5 pyJ8ldTZ370yyHq40xv2LMz9lwmv1oX7u41+79I0= 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 38/85] perf cs-etm: Configure timestamp generation in CPU-wide mode Date: Tue, 11 Jun 2019 15:58:24 -0300 Message-Id: <20190611185911.11645-39-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 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(+) -- 2.20.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 */