perf tools: Create separate mmaps for a dummy event

A dummy event will be used to track metadata (like task, mmap events)
for a session and actual samples will be recorded in separate files.
So it needs its own mmap.  Now it always use 132K (32 + 1 pages) as it
seems not require more memory than samples.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: FIXME use SW alignment faults event for dummy

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf record: Process build-id for a multi file session

Introduce ___perf_session__process_events() and use it for processing
build-ids in a multi file record session.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Introduce rm_rf() function

As the name tells, it recursively delete directory entries and finally
remove the directory.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Remove directory when backup perf.data.dir

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf session: Handle multi file in perf_session__process_events()

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf session: Init multi-file session properly

Call perf_data_file__open_multi() when perf detects a multi-file
session so that it can process samples in a multiple files.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf report: Skip the dummy event

The dummy event is only for tracking task/mmap events so has no sample
data.  No need to report, just skip it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Introduce thread__comm_time() helpers

Sort thread's comm by time so that it can find appropriate comm at the
time.  This is a preparation of multi-thread support.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Add a test case for thread comm handling

The new test case checks various thread comm handling like overridding
and time sorting.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Maintain map groups list in a leader thread

To support multi-threaded perf report, we need to maintain time-sorted
map groups.  Add ->mg_list member to struct thread and sort the list
by time.  Now leader threads have one more refcnt for map groups in
the list so also update the thread-mg-share test case.

Currently only add a new map groups when an exec (comm) event is
received.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Introduce thread__find_addr_location_time() and friends

The *_time() variants are for find appropriate map (and symbol) at the
given time.  This is based on the fact that map_groups list is sorted
by time in the previous patch.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Add a test case for timed map groups handling

A test case for verifying thread->mg and ->mg_list handling during
time change and new thread__find_addr_map_time() and friends.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Protect dso__load using pthread_mutex

With multi-thread support, dso__load can be called in parallel during
the sample processing so protect it using a mutex.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Use thread specific rb root to add hist entries

To support parellel insertion, hist entries need to be added into
per-thread root.  Add symbol_conf.multi_thread to signal that.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Introduce hists__thread_resort()

The hists_thread_resort() function is to collect per-thread
entries into the central hists root for later processing.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf report: Process sample events using multi thread

Now perf report can run in multi threaded mode to speed up the sample
processing if it's recorded in a multi-file format.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Introduce 'data' builtin command

The 'perf data' command is for converting data file to a multi file
format so that it can speedup the processing using multi threads.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Properly copy feature bitmaps and data

The perf_header__copy_feats() is for copying original feature data
into perf.header file with modified offsets.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
XXX: add perf data dump command

Signed-off-by: Namhyung Kim <namhyung@kernel.org>