From: Ingo Molnar <mingo@kernel.org>
To: Joseph Schuchart <joseph.schuchart@tu-dresden.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
thomas.ilsche@tu-dresden.de, linux-kernel@vger.kernel.org,
Fr??d??ric Weisbecker <fweisbec@gmail.com>,
David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH] Perf: Correct Assumptions about Sample Timestamps in Passes
Date: Thu, 14 Nov 2013 11:05:52 +0100 [thread overview]
Message-ID: <20131114100552.GA5064@gmail.com> (raw)
In-Reply-To: <528490DE.4080204@tu-dresden.de>
* Joseph Schuchart <joseph.schuchart@tu-dresden.de> wrote:
> > Just a quick side note, while I realize that you are
> > (rightfully!) concerned about correctness primarily, if that loop
> > over MAX_NR_CPUS executes often enough then this might hurt
> > performance:
> >
> > perf.h:#define MAX_NR_CPUS 256
> >
> > So it might be better to maintain a rolling min_max_timestamp in
> > this place:
> >
> > + os->max_timestamps[sample->cpu] = timestamp;
> >
> > ?
> >
> > If done that way then AFAICS we could even eliminate the
> > ->max_timestamps[NR_CPUS] array.
>
> I can understand your performance concerns. However, I am not
> sure how we can determine the minimal max_timestamp of all cpus
> without storing the information on a per-cpu basis first.
> Accumulating it on the fly would only lead to a global
> max_timestamp. [...]
Ok. So this:
+static inline void set_next_flush(struct perf_session *session)
+{
+ int i;
+ u64 min_max_timestamp = session->ordered_samples.max_timestamps[0];
+ for (i = 1; i < MAX_NR_CPUS; i++) {
+ if (min_max_timestamp > session->ordered_samples.max_timestamps[i])
+ min_max_timestamp = session->ordered_samples.max_timestamps[i];
+ }
+ session->ordered_samples.next_flush = min_max_timestamp;
+}
which should IMHO be written in a bit clearer form as:
static inline void set_next_flush(struct perf_session *session)
{
u64 *timestamps = session->ordered_samples.max_timestamps;
u64 min_timestamp = timestamps[0];
int i;
for (i = 1; i < MAX_NR_CPUS; i++) {
if (min_timestamp > timestamps[i])
min_timestamp = timestamps[i];
}
session->ordered_samples.next_flush = min_timestamp;
}
calculates the minimum of the max_timestamps[] array, right?
Now, the max_timestamps[] array gets modified only in a single
place, from the sample timestamps, via:
os->max_timestamps[sample->cpu] = timestamp;
My suggestion was an identity transformation: to calculate the
minimum of the array when the max_timestamps[] array is modified.
A new minimum happens if the freshly written value is smaller
than the current minimum.
I.e. the max_timestamps[] array itself is redundant, and we just
have to update a rolling minimum - which is a (session-) global
minimum - which is equivalent to the more complex minimum
calculation in your patch.
What am I missing?
Thanks,
Ingo
next prev parent reply other threads:[~2013-11-14 10:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 8:07 Joseph Schuchart
2013-11-14 8:39 ` Ingo Molnar
2013-11-14 8:59 ` Joseph Schuchart
2013-11-14 10:05 ` Ingo Molnar [this message]
2013-11-14 14:26 ` David Ahern
2013-11-14 14:44 ` Peter Zijlstra
2013-11-14 15:02 ` David Ahern
2013-11-14 15:25 ` Peter Zijlstra
2013-11-21 14:55 ` Joseph Schuchart
2013-11-27 13:51 ` Ingo Molnar
2013-12-20 12:27 ` Joseph Schuchart
2013-12-20 17:09 ` David Ahern
2013-12-23 13:10 ` Frederic Weisbecker
2013-12-23 14:44 ` David Ahern
2013-12-26 15:14 ` Frederic Weisbecker
2013-12-26 15:24 ` David Ahern
2013-12-26 15:30 ` Frederic Weisbecker
2014-01-01 18:37 ` David Ahern
2014-01-03 22:07 ` Frederic Weisbecker
2014-01-03 22:45 ` David Ahern
2014-01-04 15:05 ` Frederic Weisbecker
2014-01-08 21:48 ` David Ahern
2014-01-09 15:19 ` Frederic Weisbecker
2014-01-12 15:46 ` David Ahern
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=20131114100552.GA5064@gmail.com \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=joseph.schuchart@tu-dresden.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=thomas.ilsche@tu-dresden.de \
/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
Powered by JetHome