Skip to content

Commit

Permalink
perf session: Use perf_evlist__id_hdr_size more extensively
Browse files Browse the repository at this point in the history
Removing perf_session->id_hdr_size, as it can be obtained from the
evsel/evlist.

Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Aug 1, 2012
1 parent 5e56247 commit 7b56cce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static void perf_record__open(struct perf_record *rec)
}
}

perf_session__update_sample_type(session);
perf_session__set_id_hdr_size(session);
}

static int process_buildids(struct perf_record *rec)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ static int __cmd_top(struct perf_top *top)
&top->session->host_machine);
perf_top__start_counters(top);
top->session->evlist = top->evlist;
perf_session__update_sample_type(top->session);
perf_session__set_id_hdr_size(top->session);

/* Wait for a minimal set of events before starting the snapshot */
poll(top->evlist->pollfd, top->evlist->nr_fds, 100);
Expand Down
13 changes: 7 additions & 6 deletions tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ static int perf_session__open(struct perf_session *self, bool force)
return -1;
}

void perf_session__update_sample_type(struct perf_session *self)
void perf_session__set_id_hdr_size(struct perf_session *session)
{
self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist);
self->host_machine.id_hdr_size = self->id_hdr_size;
machines__set_id_hdr_size(&self->machines, self->id_hdr_size);
u16 id_hdr_size = perf_evlist__id_hdr_size(session->evlist);

session->host_machine.id_hdr_size = id_hdr_size;
machines__set_id_hdr_size(&session->machines, id_hdr_size);
}

int perf_session__create_kernel_maps(struct perf_session *self)
Expand Down Expand Up @@ -165,7 +166,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
if (mode == O_RDONLY) {
if (perf_session__open(self, force) < 0)
goto out_delete;
perf_session__update_sample_type(self);
perf_session__set_id_hdr_size(self);
} else if (mode == O_WRONLY) {
/*
* In O_RDONLY mode this will be performed when reading the
Expand Down Expand Up @@ -1054,7 +1055,7 @@ static int perf_session__process_user_event(struct perf_session *session, union
case PERF_RECORD_HEADER_ATTR:
err = tool->attr(event, &session->evlist);
if (err == 0)
perf_session__update_sample_type(session);
perf_session__set_id_hdr_size(session);
return err;
case PERF_RECORD_HEADER_EVENT_TYPE:
return tool->event_type(tool, event);
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/util/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ struct perf_session {
int fd;
bool fd_pipe;
bool repipe;
u16 id_hdr_size;
int cwdlen;
char *cwd;
struct ordered_samples ordered_samples;
Expand Down Expand Up @@ -83,7 +82,7 @@ void perf_event__attr_swap(struct perf_event_attr *attr);

int perf_session__create_kernel_maps(struct perf_session *self);

void perf_session__update_sample_type(struct perf_session *self);
void perf_session__set_id_hdr_size(struct perf_session *session);
void perf_session__remove_thread(struct perf_session *self, struct thread *th);

static inline
Expand Down

0 comments on commit 7b56cce

Please sign in to comment.