perf ordered_samples: Remove references to perf_{evlist,tool} and machines

As these can be obtained from the ordered_events pointer, via
container_of, reducing the cross section of ordered_samples.

These were added to ordered_samples in:

 commit b7b61cbe
 Author: Arnaldo Carvalho de Melo <acme@redhat.com>
 Date:   Tue Mar 3 11:58:45 2015 -0300

    perf ordered_events: Shorten function signatures

    By keeping pointers to machines, evlist and tool in ordered_events.

But that was more a transitional patch while moving stuff out from
perf_session.c to ordered_events.c and possibly not even needed by then,
as we could use the container_of() method and instead of having the
nr_unordered_samples stats in events_stats, we can have it in
ordered_samples.
Based-on-a-patch-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-4lk0t9js82g0tfc0x1onpkjt@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent aae59fab
...@@ -242,7 +242,6 @@ struct events_stats { ...@@ -242,7 +242,6 @@ struct events_stats {
u32 nr_invalid_chains; u32 nr_invalid_chains;
u32 nr_unknown_id; u32 nr_unknown_id;
u32 nr_unprocessable_samples; u32 nr_unprocessable_samples;
u32 nr_unordered_events;
}; };
struct attr_event { struct attr_event {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/string.h> #include <linux/string.h>
#include "ordered-events.h" #include "ordered-events.h"
#include "evlist.h"
#include "session.h" #include "session.h"
#include "asm/bug.h" #include "asm/bug.h"
#include "debug.h" #include "debug.h"
...@@ -167,7 +166,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event, ...@@ -167,7 +166,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n", pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
oe->last_flush_type); oe->last_flush_type);
oe->evlist->stats.nr_unordered_events++; oe->nr_unordered_events++;
} }
oevent = ordered_events__new_event(oe, timestamp, event); oevent = ordered_events__new_event(oe, timestamp, event);
...@@ -187,7 +186,6 @@ static int __ordered_events__flush(struct ordered_events *oe) ...@@ -187,7 +186,6 @@ static int __ordered_events__flush(struct ordered_events *oe)
{ {
struct list_head *head = &oe->events; struct list_head *head = &oe->events;
struct ordered_event *tmp, *iter; struct ordered_event *tmp, *iter;
struct perf_sample sample;
u64 limit = oe->next_flush; u64 limit = oe->next_flush;
u64 last_ts = oe->last ? oe->last->timestamp : 0ULL; u64 last_ts = oe->last ? oe->last->timestamp : 0ULL;
bool show_progress = limit == ULLONG_MAX; bool show_progress = limit == ULLONG_MAX;
...@@ -206,15 +204,9 @@ static int __ordered_events__flush(struct ordered_events *oe) ...@@ -206,15 +204,9 @@ static int __ordered_events__flush(struct ordered_events *oe)
if (iter->timestamp > limit) if (iter->timestamp > limit)
break; break;
ret = oe->deliver(oe, iter);
ret = perf_evlist__parse_sample(oe->evlist, iter->event, &sample);
if (ret) if (ret)
pr_err("Can't parse sample, err = %d\n", ret); return ret;
else {
ret = oe->deliver(oe, iter, &sample);
if (ret)
return ret;
}
ordered_events__delete(oe, iter); ordered_events__delete(oe, iter);
oe->last_flush = iter->timestamp; oe->last_flush = iter->timestamp;
...@@ -292,18 +284,13 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how) ...@@ -292,18 +284,13 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
return err; return err;
} }
void ordered_events__init(struct ordered_events *oe, struct machines *machines, void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver)
struct perf_evlist *evlist, struct perf_tool *tool,
ordered_events__deliver_t deliver)
{ {
INIT_LIST_HEAD(&oe->events); INIT_LIST_HEAD(&oe->events);
INIT_LIST_HEAD(&oe->cache); INIT_LIST_HEAD(&oe->cache);
INIT_LIST_HEAD(&oe->to_free); INIT_LIST_HEAD(&oe->to_free);
oe->max_alloc_size = (u64) -1; oe->max_alloc_size = (u64) -1;
oe->cur_alloc_size = 0; oe->cur_alloc_size = 0;
oe->evlist = evlist;
oe->machines = machines;
oe->tool = tool;
oe->deliver = deliver; oe->deliver = deliver;
} }
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
#include <linux/types.h> #include <linux/types.h>
struct perf_tool;
struct perf_evlist;
struct perf_sample; struct perf_sample;
struct machines;
struct ordered_event { struct ordered_event {
u64 timestamp; u64 timestamp;
...@@ -25,8 +22,7 @@ enum oe_flush { ...@@ -25,8 +22,7 @@ enum oe_flush {
struct ordered_events; struct ordered_events;
typedef int (*ordered_events__deliver_t)(struct ordered_events *oe, typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
struct ordered_event *event, struct ordered_event *event);
struct perf_sample *sample);
struct ordered_events { struct ordered_events {
u64 last_flush; u64 last_flush;
...@@ -39,13 +35,11 @@ struct ordered_events { ...@@ -39,13 +35,11 @@ struct ordered_events {
struct list_head to_free; struct list_head to_free;
struct ordered_event *buffer; struct ordered_event *buffer;
struct ordered_event *last; struct ordered_event *last;
struct machines *machines;
struct perf_evlist *evlist;
struct perf_tool *tool;
ordered_events__deliver_t deliver; ordered_events__deliver_t deliver;
int buffer_idx; int buffer_idx;
unsigned int nr_events; unsigned int nr_events;
enum oe_flush last_flush_type; enum oe_flush last_flush_type;
u32 nr_unordered_events;
bool copy_on_queue; bool copy_on_queue;
}; };
...@@ -53,9 +47,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event, ...@@ -53,9 +47,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
struct perf_sample *sample, u64 file_offset); struct perf_sample *sample, u64 file_offset);
void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
void ordered_events__init(struct ordered_events *oe, struct machines *machines, void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver);
struct perf_evlist *evlsit, struct perf_tool *tool,
ordered_events__deliver_t deliver);
void ordered_events__free(struct ordered_events *oe); void ordered_events__free(struct ordered_events *oe);
static inline static inline
......
...@@ -93,11 +93,20 @@ static void perf_session__set_comm_exec(struct perf_session *session) ...@@ -93,11 +93,20 @@ static void perf_session__set_comm_exec(struct perf_session *session)
} }
static int ordered_events__deliver_event(struct ordered_events *oe, static int ordered_events__deliver_event(struct ordered_events *oe,
struct ordered_event *event, struct ordered_event *event)
struct perf_sample *sample)
{ {
return machines__deliver_event(oe->machines, oe->evlist, event->event, struct perf_sample sample;
sample, oe->tool, event->file_offset); struct perf_session *session = container_of(oe, struct perf_session,
ordered_events);
int ret = perf_evlist__parse_sample(session->evlist, event->event, &sample);
if (ret) {
pr_err("Can't parse sample, err = %d\n", ret);
return ret;
}
return machines__deliver_event(&session->machines, session->evlist, event->event,
&sample, session->tool, event->file_offset);
} }
struct perf_session *perf_session__new(struct perf_data_file *file, struct perf_session *perf_session__new(struct perf_data_file *file,
...@@ -109,9 +118,9 @@ struct perf_session *perf_session__new(struct perf_data_file *file, ...@@ -109,9 +118,9 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
goto out; goto out;
session->repipe = repipe; session->repipe = repipe;
session->tool = tool;
machines__init(&session->machines); machines__init(&session->machines);
ordered_events__init(&session->ordered_events, &session->machines, ordered_events__init(&session->ordered_events, ordered_events__deliver_event);
session->evlist, tool, ordered_events__deliver_event);
if (file) { if (file) {
if (perf_data_file__open(file)) if (perf_data_file__open(file))
...@@ -940,7 +949,7 @@ static s64 perf_session__process_user_event(struct perf_session *session, ...@@ -940,7 +949,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
u64 file_offset) u64 file_offset)
{ {
struct ordered_events *oe = &session->ordered_events; struct ordered_events *oe = &session->ordered_events;
struct perf_tool *tool = oe->tool; struct perf_tool *tool = session->tool;
int fd = perf_data_file__fd(session->file); int fd = perf_data_file__fd(session->file);
int err; int err;
...@@ -981,7 +990,7 @@ int perf_session__deliver_synth_event(struct perf_session *session, ...@@ -981,7 +990,7 @@ int perf_session__deliver_synth_event(struct perf_session *session,
struct perf_sample *sample) struct perf_sample *sample)
{ {
struct perf_evlist *evlist = session->evlist; struct perf_evlist *evlist = session->evlist;
struct perf_tool *tool = session->ordered_events.tool; struct perf_tool *tool = session->tool;
events_stats__inc(&evlist->stats, event->header.type); events_stats__inc(&evlist->stats, event->header.type);
...@@ -1059,7 +1068,7 @@ static s64 perf_session__process_event(struct perf_session *session, ...@@ -1059,7 +1068,7 @@ static s64 perf_session__process_event(struct perf_session *session,
union perf_event *event, u64 file_offset) union perf_event *event, u64 file_offset)
{ {
struct perf_evlist *evlist = session->evlist; struct perf_evlist *evlist = session->evlist;
struct perf_tool *tool = session->ordered_events.tool; struct perf_tool *tool = session->tool;
struct perf_sample sample; struct perf_sample sample;
int ret; int ret;
...@@ -1116,10 +1125,12 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se ...@@ -1116,10 +1125,12 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
return thread; return thread;
} }
static void perf_tool__warn_about_errors(const struct perf_tool *tool, static void perf_session__warn_about_errors(const struct perf_session *session)
const struct events_stats *stats)
{ {
if (tool->lost == perf_event__process_lost && const struct events_stats *stats = &session->evlist->stats;
const struct ordered_events *oe = &session->ordered_events;
if (session->tool->lost == perf_event__process_lost &&
stats->nr_events[PERF_RECORD_LOST] != 0) { stats->nr_events[PERF_RECORD_LOST] != 0) {
ui__warning("Processed %d events and lost %d chunks!\n\n" ui__warning("Processed %d events and lost %d chunks!\n\n"
"Check IO/CPU overload!\n\n", "Check IO/CPU overload!\n\n",
...@@ -1155,8 +1166,8 @@ static void perf_tool__warn_about_errors(const struct perf_tool *tool, ...@@ -1155,8 +1166,8 @@ static void perf_tool__warn_about_errors(const struct perf_tool *tool,
stats->nr_unprocessable_samples); stats->nr_unprocessable_samples);
} }
if (stats->nr_unordered_events != 0) if (oe->nr_unordered_events != 0)
ui__warning("%u out of order events recorded.\n", stats->nr_unordered_events); ui__warning("%u out of order events recorded.\n", oe->nr_unordered_events);
} }
volatile int session_done; volatile int session_done;
...@@ -1164,7 +1175,7 @@ volatile int session_done; ...@@ -1164,7 +1175,7 @@ volatile int session_done;
static int __perf_session__process_pipe_events(struct perf_session *session) static int __perf_session__process_pipe_events(struct perf_session *session)
{ {
struct ordered_events *oe = &session->ordered_events; struct ordered_events *oe = &session->ordered_events;
struct perf_tool *tool = oe->tool; struct perf_tool *tool = session->tool;
int fd = perf_data_file__fd(session->file); int fd = perf_data_file__fd(session->file);
union perf_event *event; union perf_event *event;
uint32_t size, cur_size = 0; uint32_t size, cur_size = 0;
...@@ -1247,7 +1258,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session) ...@@ -1247,7 +1258,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session)
err = ordered_events__flush(oe, OE_FLUSH__FINAL); err = ordered_events__flush(oe, OE_FLUSH__FINAL);
out_err: out_err:
free(buf); free(buf);
perf_tool__warn_about_errors(tool, &session->evlist->stats); perf_session__warn_about_errors(session);
ordered_events__free(&session->ordered_events); ordered_events__free(&session->ordered_events);
return err; return err;
} }
...@@ -1297,7 +1308,7 @@ static int __perf_session__process_events(struct perf_session *session, ...@@ -1297,7 +1308,7 @@ static int __perf_session__process_events(struct perf_session *session,
u64 file_size) u64 file_size)
{ {
struct ordered_events *oe = &session->ordered_events; struct ordered_events *oe = &session->ordered_events;
struct perf_tool *tool = oe->tool; struct perf_tool *tool = session->tool;
int fd = perf_data_file__fd(session->file); int fd = perf_data_file__fd(session->file);
u64 head, page_offset, file_offset, file_pos, size; u64 head, page_offset, file_offset, file_pos, size;
int err, mmap_prot, mmap_flags, map_idx = 0; int err, mmap_prot, mmap_flags, map_idx = 0;
...@@ -1393,7 +1404,7 @@ static int __perf_session__process_events(struct perf_session *session, ...@@ -1393,7 +1404,7 @@ static int __perf_session__process_events(struct perf_session *session,
err = ordered_events__flush(oe, OE_FLUSH__FINAL); err = ordered_events__flush(oe, OE_FLUSH__FINAL);
out_err: out_err:
ui_progress__finish(); ui_progress__finish();
perf_tool__warn_about_errors(tool, &session->evlist->stats); perf_session__warn_about_errors(session);
ordered_events__free(&session->ordered_events); ordered_events__free(&session->ordered_events);
session->one_mmap = false; session->one_mmap = false;
return err; return err;
......
...@@ -26,6 +26,7 @@ struct perf_session { ...@@ -26,6 +26,7 @@ struct perf_session {
u64 one_mmap_offset; u64 one_mmap_offset;
struct ordered_events ordered_events; struct ordered_events ordered_events;
struct perf_data_file *file; struct perf_data_file *file;
struct perf_tool *tool;
}; };
#define PRINT_IP_OPT_IP (1<<0) #define PRINT_IP_OPT_IP (1<<0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment