perf tools: Introduce tmalloc() and tfree()

The tmalloc() and tfree() are simple allocator interfaces that work
for multi-thread environment.  They'll be used during sample processing.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: define _DEFAULT_SOURCE for glibc_2.20

_BSD_SOURCE was deprecated in favour of _DEFAULT_SOURCE since glibc
2.20[1]. To avoid build warning on glibc2.20, _DEFAULT_SOURCE should
also be defined.

[1]: https://sourceware.org/glibc/wiki/Release/2.20

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1410487817-13403-1-git-send-email-chanho61.park@samsung.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tools: Make perf_data_file__size() returns total size

When multi file support is enabled, the size field is a sum of
each file's size.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Pass perf_data_file and idx to __perf_session__process_events()

So that it can handle multi file case properly.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Update progress bar for whole data files

Currently the progress bar in perf_session__process_events() works
only for a single file.  To support multi-threaded perf report,
protect it with a pthread_mutex and update only after a substantial
progress was made.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Count session's event stat for multi thread

Add ->multi_stats field to struct perf_session to avoid a race between
multple threads.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Count evsel's event stat for multi thread

Add ->multi_stats field to struct hists to avoid a race between
multple threads.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Defer dso loaded flag set

Since other thread can see it before actually loading symbol from a
dso so it needs to be set at last.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
perf tools: Append callchains only when requested

The perf report --children can be called with callchain disabled so no
need to append callchains.  Actually the root of callchain tree is not
initialized properly in this case.

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