perf ordered_events: Add 'struct ordered_events_buffer' layer
authorJiri Olsa <jolsa@kernel.org>
Fri, 7 Sep 2018 10:24:54 +0000 (12:24 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 19 Sep 2018 13:24:57 +0000 (10:24 -0300)
commitd5ceb62b36545b597e89adb5eb778c3e15431c10
tree96026a0f2fe1e42fb43ddf1f3d0b2a517fa5a831
parent2e85d5979e8d2866db6185de231461b21159ef6f
perf ordered_events: Add 'struct ordered_events_buffer' layer

When ordering events, we use preallocated buffers to store separate
events.  Those buffers currently don't have their own struct, but since
they are basically an array of 'struct ordered_event' objects, we use
the first event to hold buffers data - list head, that holds all buffers
together:

   struct ordered_events {
     ...
     struct ordered_event *buffer;
     ...
   };

   struct ordered_event {
     u64               timestamp;
     u64               file_offset;
     union perf_event  *event;
     struct list_head  list;
   };

This is quite convoluted and error prone as demonstrated by free-ing
issue discovered and fixed by Stephane in here [1].

This patch adds the 'struct ordered_events_buffer' object, that holds
the buffer data and frees it up properly.

[1] - https://marc.info/?l=linux-kernel&m=153376761329335&w=2

Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Stephane Eranian <eranian@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180907102455.7030-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/ordered-events.c
tools/perf/util/ordered-events.h