perf ordered_events: Adopt queue() method
From perf_session, will be used in 'trace'. 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: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-mfihndzaumx44h6y37ng2irb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
01fbc1fee9
commit
4a6b362f36
3 changed files with 35 additions and 31 deletions
|
@ -131,8 +131,8 @@ static struct ordered_event *alloc_event(struct ordered_events *oe,
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ordered_event *
|
static struct ordered_event *
|
||||||
ordered_events__new(struct ordered_events *oe, u64 timestamp,
|
ordered_events__new_event(struct ordered_events *oe, u64 timestamp,
|
||||||
union perf_event *event)
|
union perf_event *event)
|
||||||
{
|
{
|
||||||
struct ordered_event *new;
|
struct ordered_event *new;
|
||||||
|
@ -153,6 +153,36 @@ void ordered_events__delete(struct ordered_events *oe, struct ordered_event *eve
|
||||||
free_dup_event(oe, event->event);
|
free_dup_event(oe, event->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
|
||||||
|
struct perf_sample *sample, u64 file_offset)
|
||||||
|
{
|
||||||
|
u64 timestamp = sample->time;
|
||||||
|
struct ordered_event *oevent;
|
||||||
|
|
||||||
|
if (!timestamp || timestamp == ~0ULL)
|
||||||
|
return -ETIME;
|
||||||
|
|
||||||
|
if (timestamp < oe->last_flush) {
|
||||||
|
pr_oe_time(timestamp, "out of order event\n");
|
||||||
|
pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
|
||||||
|
oe->last_flush_type);
|
||||||
|
|
||||||
|
oe->evlist->stats.nr_unordered_events++;
|
||||||
|
}
|
||||||
|
|
||||||
|
oevent = ordered_events__new_event(oe, timestamp, event);
|
||||||
|
if (!oevent) {
|
||||||
|
ordered_events__flush(oe, OE_FLUSH__HALF);
|
||||||
|
oevent = ordered_events__new_event(oe, timestamp, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!oevent)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
oevent->file_offset = file_offset;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int __ordered_events__flush(struct ordered_events *oe)
|
static int __ordered_events__flush(struct ordered_events *oe)
|
||||||
{
|
{
|
||||||
struct list_head *head = &oe->events;
|
struct list_head *head = &oe->events;
|
||||||
|
|
|
@ -49,8 +49,8 @@ struct ordered_events {
|
||||||
bool copy_on_queue;
|
bool copy_on_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
|
int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
|
||||||
union perf_event *event);
|
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, struct machines *machines,
|
||||||
|
|
|
@ -541,33 +541,7 @@ static int process_finished_round(struct perf_tool *tool __maybe_unused,
|
||||||
int perf_session__queue_event(struct perf_session *s, union perf_event *event,
|
int perf_session__queue_event(struct perf_session *s, union perf_event *event,
|
||||||
struct perf_sample *sample, u64 file_offset)
|
struct perf_sample *sample, u64 file_offset)
|
||||||
{
|
{
|
||||||
struct ordered_events *oe = &s->ordered_events;
|
return ordered_events__queue(&s->ordered_events, event, sample, file_offset);
|
||||||
|
|
||||||
u64 timestamp = sample->time;
|
|
||||||
struct ordered_event *new;
|
|
||||||
|
|
||||||
if (!timestamp || timestamp == ~0ULL)
|
|
||||||
return -ETIME;
|
|
||||||
|
|
||||||
if (timestamp < oe->last_flush) {
|
|
||||||
pr_oe_time(timestamp, "out of order event\n");
|
|
||||||
pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
|
|
||||||
oe->last_flush_type);
|
|
||||||
|
|
||||||
s->evlist->stats.nr_unordered_events++;
|
|
||||||
}
|
|
||||||
|
|
||||||
new = ordered_events__new(oe, timestamp, event);
|
|
||||||
if (!new) {
|
|
||||||
ordered_events__flush(oe, OE_FLUSH__HALF);
|
|
||||||
new = ordered_events__new(oe, timestamp, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!new)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
new->file_offset = file_offset;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void callchain__lbr_callstack_printf(struct perf_sample *sample)
|
static void callchain__lbr_callstack_printf(struct perf_sample *sample)
|
||||||
|
|
Loading…
Add table
Reference in a new issue