From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Coresight ML <coresight@lists.linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>, Leo Yan <leo.yan@linaro.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2 02/17] perf tools: Configure timestsamp generation in CPU-wide mode
Date: Fri, 7 Jun 2019 11:46:32 -0600 [thread overview]
Message-ID: <CANLsYkx6o9xgxTh4s-o7tVxKKLu_SQc5CLtoHzHK=8WtNK4dbQ@mail.gmail.com> (raw)
In-Reply-To: <c1507e8b-9ec8-a5c4-a398-20dcc47acaa8@arm.com>
On Fri, 7 Jun 2019 at 03:41, Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
>
>
> On 24/05/2019 18:34, Mathieu Poirier wrote:
> > 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 <mathieu.poirier@linaro.org>
> > ---
> > 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 @@ 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;
>
> nit: Could we not do this in one shot, say :
>
> cs_etm_set_option(itr, cs_etm_evsel, ETM_OPT_TS | ETM_OPT_CTXTID) ?
>
> rather than iterating over the per-CPU events twice ? The cs_etm_set_option()
> could simply replace the switch() to :
>
> if (option & ETM_OPT_1)
> do_something_for_1()
> if (option & ETM_OPT_2)
> do_something_for_2();
> if (option & ~(ETM_OPT_1 | ETM_OPT_2 |...))
> /* do unsupported option */
>
Yes, that is a good optimization.
Arnaldo, do you prefer a new set or another patch on top of this one?
Thanks,
Mathieu
>
> Cheers
> Suzuki
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-06-07 17:46 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 17:34 [PATCH v2 00/17] perf tools: Coresight: Add CPU-wide trace support Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 01/17] perf tools: Configure contextID tracing in CPU-wide mode Mathieu Poirier
2019-06-07 9:21 ` Suzuki K Poulose
2019-06-07 17:40 ` Mathieu Poirier
2019-06-07 18:20 ` Arnaldo Carvalho de Melo
2019-06-07 19:33 ` Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 02/17] perf tools: Configure timestsamp generation " Mathieu Poirier
2019-06-07 9:41 ` Suzuki K Poulose
2019-06-07 17:46 ` Mathieu Poirier [this message]
2019-06-07 18:34 ` Arnaldo Carvalho de Melo
2019-05-24 17:34 ` [PATCH v2 03/17] perf tools: Configure SWITCH_EVENTS " Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 04/17] perf tools: Add handling of itrace start events Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 05/17] perf tools: Add handling of switch-CPU-wide events Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 06/17] perf tools: Refactor error path in cs_etm_decoder__new() Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 07/17] perf tools: Move packet queue out of decoder structure Mathieu Poirier
2019-05-24 17:34 ` [PATCH v2 08/17] perf tools: Fix indentation in function cs_etm__process_decoder_queue() Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 09/17] perf tools: Introduce the concept of trace ID queues Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 10/17] perf tools: Get rid of unused cpu in struct cs_etm_queue Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 11/17] perf tools: Move thread to traceid_queue Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 12/17] perf tools: Move tid/pid " Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 13/17] perf tools: Use traceID aware memory callback API Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 14/17] perf tools: Add support for multiple traceID queues Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 15/17] perf tools: Linking PE contextID with perf thread mechanic Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 16/17] perf tools: Add notion of time to decoding code Mathieu Poirier
2019-06-06 18:50 ` Arnaldo Carvalho de Melo
2019-06-07 14:38 ` Mathieu Poirier
2019-05-24 17:35 ` [PATCH v2 17/17] perf tools: Add support for CPU-wide trace scenarios Mathieu Poirier
2019-05-31 1:45 ` [PATCH v2 00/17] perf tools: Coresight: Add CPU-wide trace support Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANLsYkx6o9xgxTh4s-o7tVxKKLu_SQc5CLtoHzHK=8WtNK4dbQ@mail.gmail.com' \
--to=mathieu.poirier@linaro.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=jolsa@redhat.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).