From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Leo Yan <leo.yan@linaro.org>
Cc: Jon Corbet <corbet@lwn.net>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Coresight ML <coresight@lists.linaro.org>,
"Suzuki K. Poulose" <suzuki.poulose@arm.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Mike Leach <mike.leach@arm.com>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 4/5] perf tools: Properly set the value of 'old' in snapshot mode
Date: Tue, 7 May 2019 11:59:46 -0600 [thread overview]
Message-ID: <CANLsYkyBLivODPtSLXA7UjYxJBzDAzADRNVCU8k+0ouCeAzfAQ@mail.gmail.com> (raw)
In-Reply-To: <20190507084404.GD21730@leoy-ThinkPad-X240s>
On Tue, 7 May 2019 at 02:44, Leo Yan <leo.yan@linaro.org> wrote:
>
> On Wed, May 01, 2019 at 11:50:51AM -0600, Mathieu Poirier wrote:
> > In snapshot mode the value of the 'old' pointer needs to be adjusted when
> > 'head' has wrapped around in order to get the latest information in the
> > buffer and be compatible with the generic AUX ring buffer mechanic.
> >
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> > ---
> > tools/perf/arch/arm/util/cs-etm.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
> > index 911426721170..4e73fe1a6978 100644
> > --- a/tools/perf/arch/arm/util/cs-etm.c
> > +++ b/tools/perf/arch/arm/util/cs-etm.c
> > @@ -541,11 +541,19 @@ static int cs_etm_find_snapshot(struct auxtrace_record *itr __maybe_unused,
> > unsigned char *data __maybe_unused,
> > u64 *head, u64 *old)
> > {
> > + bool wrapped;
> > +
> > pr_debug3("%s: mmap index %d old head %zu new head %zu size %zu\n",
> > __func__, idx, (size_t)*old, (size_t)*head, mm->len);
> >
> > - *old = *head;
> > - *head += mm->len;
> > + /*
> > + * If the last byte in the ring buffer isn't zero, the head has
> > + * wrapped around.
> > + */
> > + wrapped = !!(data[mm->len - 1]);
>
> This is confused for me since I can think out two cases might break
> this checking.
>
> The first case is the trace data stream might be zero at the end of the
> buffer;
I just realized there is a better way to do this - since "*head" is
continiously incrementing I will simply compare it to mm->len. If it
is equal of bigger, the head has wrapped around.
>the second case is that the buffer is not really wrapped around
> at this time but the end of buffer contains the stale data by previous
> time.
That would mean the snapshots were really close together. In that
case we'd simply get the tail end of the previous snapshot, which is
fine since it is was close enough that we do want that data.
>
> Could you confirm both cases will not happen?
>
> Will do more testing for this patch set.
>
> Thanks,
> Leo Yan
>
> > +
> > + if (wrapped)
> > + *old = *head - mm->len;
> >
> > return 0;
> > }
> > --
> > 2.17.1
> >
_______________________________________________
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-05-07 18:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-01 17:50 [PATCH 0/5] coresight: Fix snapshot mode Mathieu Poirier
2019-05-01 17:50 ` [PATCH 1/5] coresight: Fix buffer size in " Mathieu Poirier
2019-05-07 7:38 ` Leo Yan
2019-05-07 17:24 ` Mathieu Poirier
2019-05-07 8:50 ` Suzuki K Poulose
2019-05-07 20:22 ` Mathieu Poirier
2019-05-01 17:50 ` [PATCH 2/5] coresight: tmc-etf: Fix snapshot mode update function Mathieu Poirier
2019-05-07 8:13 ` Leo Yan
2019-05-07 17:16 ` Mathieu Poirier
2019-05-07 9:22 ` Suzuki K Poulose
2019-05-01 17:50 ` [PATCH 3/5] coresight: perf: Don't set the truncated flag in snapshot mode Mathieu Poirier
2019-05-07 8:29 ` Leo Yan
2019-05-07 17:44 ` Mathieu Poirier
2019-05-01 17:50 ` [PATCH 4/5] perf tools: Properly set the value of 'old' " Mathieu Poirier
2019-05-07 8:44 ` Leo Yan
2019-05-07 17:59 ` Mathieu Poirier [this message]
2019-05-01 17:50 ` [PATCH 5/5] docs: coresight: Document " Mathieu Poirier
2019-05-11 7:32 ` Leo Yan
2019-05-13 8:37 ` Suzuki K Poulose
2019-05-13 11:16 ` Leo Yan
2019-05-13 20:01 ` Mathieu Poirier
2019-05-13 20:12 ` Mathieu Poirier
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=CANLsYkyBLivODPtSLXA7UjYxJBzDAzADRNVCU8k+0ouCeAzfAQ@mail.gmail.com \
--to=mathieu.poirier@linaro.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mike.leach@arm.com \
--cc=mingo@redhat.com \
--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).