• David Carrillo-Cisneros's avatar
    perf inject: Copy events when reordering events in pipe mode · 1e0d4f02
    David Carrillo-Cisneros authored
    __perf_session__process_pipe_events reuses the same memory buffer to
    process all events in the pipe.
    
    When reordering is needed (e.g. -b option), events are not immediately
    flushed, but kept around until reordering is possible, causing
    memory corruption.
    
    The problem is usually observed by a "Unknown sample error" output. It
    can easily be reproduced by:
    
      perf record -o - noploop | perf inject -b > output
    
    Committer testing:
    
    Before:
    
      $ perf record -o - stress -t 2 -c 2 | perf inject -b > /dev/null
      stress: info: [8297] dispatching hogs: 2 cpu, 0 io, 0 vm, 0 hdd
      stress: info: [8297] successful run completed in 2s
      [ perf record: Woken up 3 times to write data ]
      [ perf record: Captured and wrote 0.000 MB - ]
      Warning:
      Found 1 unknown events!
    
      Is this an older tool processing a perf.data file generated by a more recent tool?
    
      If that is not the case, consider reporting to linux-kernel@vger.kernel.org.
    
      $
    
    After:
    
      $ perf record -o - stress -t 2 -c 2 | perf inject -b > /dev/null
      stress: info: [9027] dispatching hogs: 2 cpu, 0 io, 0 vm, 0 hdd
      stress: info: [9027] successful run completed in 2s
      [ perf record: Woken up 3 times to write data ]
      [ perf record: Captured and wrote 0.000 MB - ]
      no symbols found in /usr/bin/stress, maybe install a debug package?
      no symbols found in /usr/bin/stress, maybe install a debug package?
      $
    Signed-off-by: default avatarDavid Carrillo-Cisneros <davidcc@google.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: He Kuang <hekuang@huawei.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Paul Turner <pjt@google.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Simon Que <sque@chromium.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/r/20170410201432.24807-3-davidcc@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    1e0d4f02
session.c 58.9 KB