public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Stephane Eranian <eranian@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"mingo@elte.hu" <mingo@elte.hu>
Subject: Re: [BUG] perf report: ordered events and flushing bug
Date: Thu, 12 Mar 2015 13:13:16 -0600	[thread overview]
Message-ID: <5501E54C.2090107@gmail.com> (raw)
In-Reply-To: <CABPqkBRx0F5BYhFuTcynvjCwnTVfvHjyGvsbtZKV6iymqjhEtQ@mail.gmail.com>

On 3/12/15 1:05 PM, Stephane Eranian wrote:
> On Thu, Mar 12, 2015 at 5:02 AM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> On 12/03/15 05:32, Stephane Eranian wrote:
>>> Hi,
>>>
>>> I am working on the JIT support to improve the flow and have
>>> perf record inject the MMAPs at the end of the collection. For
>>> that I piggyback on the buildid pass. To avoid rewriting the entire perf.data
>>> file, I simply append the the MMAP records at the end of the file. And that
>>> puts them out-of-order in time systematically. But I thought it would be okay
>>> because perf report would sort them by timestamps again.
>>>
>>> Well, it does not in all cases! Why?
>>>
>>> Because of the round flushing. Based on how far out-of-order an event is,
>>> it may not be processed correctly because of round flushing. I believe this
>>> may only impact MMAP records.  This is a serious issue because
>>> mmaps drive symbolization of samples. If samples are processed without the
>>> proper dso mapping, then samples may not be symbolized or may be wrongly
>>> symbolized.
>>>
>>> So far, the workaround I found was to set the oe->next_flush = 0 for
>>> the ROUND mode.
>>> In other words, do not flush anything until FINAL. To me, this is the
>>> only sensible
>>> way of avoiding this kind of problems. I am not sure I understand the
>>> point of flushing
>>> anyway, except to minimize memory footprint, maybe. But it does not
>>> work with vastly
>>> out-of-order mmaps.

Rounds and flushing after them helps with the user experience -- at 
least for some commands. On systems with 1024 cpus perf data files get 
large quickly and the resulting analysis command can appear to hang for 
long periods (e.g., i have done 1 second data collections that generate 
5GB files and take 30-45 minutes before perf shows any output).

I have a patch to perf-record to allow a user to specify the poll 
timeout. That helps define the maximum time between 'rounds' on the 
record side and then commands that show each event (e.g, perf script) 
will show output much more quickly without the need to consume large 
amounts of memory or process the entire file before displaying events.

>>>
>>> Do you have a better solution?
>>
>> You could hook the ordered event delivery (see Arnaldo's perf/core branch):
>>
>> if (tool->ordered_events) {
>>          inject->deliver = session->ordered_events.deliver;
>>          session->ordered_events.deliver = jit_mmap_deliver;
>> }
>>
>> int jit_mmap_deliver(struct ordered_events *oe, struct ordered_event *event, struct perf_sample *sample)
>> {
>>          struct perf_inject *inject = container_of(oe->tool, struct perf_inject, tool);
>>
>>          if (next_jit_mmap_time < sample->time) {
>>                  <synth mmap event>
>>                  perf_session__deliver_synth_event(...);
>>          }
>>          return inject->deliver(oe, event, sample);
>> }
>>
> I don't quite understand what this does?
> Are you saying that in perf/core there is a new callback mechanism to
> override the deliver phase
> when you need ordered event and that callback could be used to avoid
> the flushing?
>

I think the suggestion is to push the mmap events into the stream at the 
appropriate time slot.

David

  reply	other threads:[~2015-03-12 19:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12  3:32 [BUG] perf report: ordered events and flushing bug Stephane Eranian
2015-03-12  7:57 ` Namhyung Kim
2015-03-12  9:02 ` Adrian Hunter
2015-03-12 19:05   ` Stephane Eranian
2015-03-12 19:13     ` David Ahern [this message]
2015-03-12 19:23       ` Stephane Eranian
2015-03-12 19:34         ` David Ahern
2015-03-12 19:39           ` Stephane Eranian
2015-03-12 19:53             ` David Ahern
2015-03-12 20:06               ` Stephane Eranian
2015-03-12 20:50                 ` Arnaldo Carvalho de Melo
2015-03-16  1:11                   ` Namhyung Kim
2015-03-12 20:16               ` Arnaldo Carvalho de Melo
2015-03-12 20:24                 ` Stephane Eranian
2015-03-12 20:27       ` Adrian Hunter

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=5501E54C.2090107@gmail.com \
    --to=dsahern@gmail.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /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