perf tools: Introduce perf_session class
That does all the initialization boilerplate, opening the file, reading the header, checking if it is valid, etc. And that will as well have the threads list, kmap (now) global variable, etc, so that we can handle two (or more) perf.data files describing sessions to compare. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1260573842-19720-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:

committed by
Ingo Molnar

parent
ea08d8cbd1
commit
94c744b6c0
@@ -22,6 +22,7 @@
|
||||
#include "perf.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/header.h"
|
||||
#include "util/session.h"
|
||||
|
||||
#include "util/parse-options.h"
|
||||
#include "util/parse-events.h"
|
||||
@@ -52,7 +53,7 @@ static int exclude_other = 1;
|
||||
|
||||
static char callchain_default_opt[] = "fractal,0.5";
|
||||
|
||||
static struct perf_header *header;
|
||||
static struct perf_session *session;
|
||||
|
||||
static u64 sample_type;
|
||||
|
||||
@@ -701,7 +702,7 @@ static int process_read_event(event_t *event)
|
||||
{
|
||||
struct perf_event_attr *attr;
|
||||
|
||||
attr = perf_header__find_attr(event->read.id, header);
|
||||
attr = perf_header__find_attr(event->read.id, &session->header);
|
||||
|
||||
if (show_threads) {
|
||||
const char *name = attr ? __event_name(attr->type, attr->config)
|
||||
@@ -766,6 +767,10 @@ static int __cmd_report(void)
|
||||
struct thread *idle;
|
||||
int ret;
|
||||
|
||||
session = perf_session__new(input_name, O_RDONLY, force);
|
||||
if (session == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
idle = register_idle_thread();
|
||||
thread__comm_adjust(idle);
|
||||
|
||||
@@ -774,14 +779,14 @@ static int __cmd_report(void)
|
||||
|
||||
register_perf_file_handler(&file_handler);
|
||||
|
||||
ret = mmap_dispatch_perf_file(&header, input_name, force,
|
||||
full_paths, &event__cwdlen, &event__cwd);
|
||||
ret = perf_session__process_events(session, full_paths,
|
||||
&event__cwdlen, &event__cwd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out_delete;
|
||||
|
||||
if (dump_trace) {
|
||||
event__print_totals();
|
||||
return 0;
|
||||
goto out_delete;
|
||||
}
|
||||
|
||||
if (verbose > 3)
|
||||
@@ -796,7 +801,8 @@ static int __cmd_report(void)
|
||||
|
||||
if (show_threads)
|
||||
perf_read_values_destroy(&show_threads_values);
|
||||
|
||||
out_delete:
|
||||
perf_session__delete(session);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user