Commit 37e39aa8 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Rename ordered_samples struct to ordered_events

Following up with ordered_samples rename for ordered_samples and
sample_queue structs to ordered_events and ordered_event structs
respectively.

Also changing flush_sample_queue function name to ordered_events_flush.

No functional change was intended.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-2dkrdvh0bbmzxdse437fcgls@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0a8cb85c
...@@ -785,7 +785,7 @@ static int perf_kvm__mmap_read(struct perf_kvm_stat *kvm) ...@@ -785,7 +785,7 @@ static int perf_kvm__mmap_read(struct perf_kvm_stat *kvm)
/* flush queue after each round in which we processed events */ /* flush queue after each round in which we processed events */
if (ntotal) { if (ntotal) {
kvm->session->ordered_samples.next_flush = flush_time; kvm->session->ordered_events.next_flush = flush_time;
err = kvm->tool.finished_round(&kvm->tool, NULL, kvm->session); err = kvm->tool.finished_round(&kvm->tool, NULL, kvm->session);
if (err) { if (err) {
if (kvm->lost_events) if (kvm->lost_events)
......
...@@ -75,9 +75,9 @@ struct perf_session *perf_session__new(struct perf_data_file *file, ...@@ -75,9 +75,9 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
goto out; goto out;
session->repipe = repipe; session->repipe = repipe;
INIT_LIST_HEAD(&session->ordered_samples.samples); INIT_LIST_HEAD(&session->ordered_events.samples);
INIT_LIST_HEAD(&session->ordered_samples.sample_cache); INIT_LIST_HEAD(&session->ordered_events.sample_cache);
INIT_LIST_HEAD(&session->ordered_samples.to_free); INIT_LIST_HEAD(&session->ordered_events.to_free);
machines__init(&session->machines); machines__init(&session->machines);
if (file) { if (file) {
...@@ -444,7 +444,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { ...@@ -444,7 +444,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
[PERF_RECORD_HEADER_MAX] = NULL, [PERF_RECORD_HEADER_MAX] = NULL,
}; };
struct sample_queue { struct ordered_event {
u64 timestamp; u64 timestamp;
u64 file_offset; u64 file_offset;
union perf_event *event; union perf_event *event;
...@@ -453,14 +453,14 @@ struct sample_queue { ...@@ -453,14 +453,14 @@ struct sample_queue {
static void perf_session_free_sample_buffers(struct perf_session *session) static void perf_session_free_sample_buffers(struct perf_session *session)
{ {
struct ordered_samples *os = &session->ordered_samples; struct ordered_events *oe = &session->ordered_events;
while (!list_empty(&os->to_free)) { while (!list_empty(&oe->to_free)) {
struct sample_queue *sq; struct ordered_event *event;
sq = list_entry(os->to_free.next, struct sample_queue, list); event = list_entry(oe->to_free.next, struct ordered_event, list);
list_del(&sq->list); list_del(&event->list);
free(sq); free(event);
} }
} }
...@@ -470,15 +470,15 @@ static int perf_session_deliver_event(struct perf_session *session, ...@@ -470,15 +470,15 @@ static int perf_session_deliver_event(struct perf_session *session,
struct perf_tool *tool, struct perf_tool *tool,
u64 file_offset); u64 file_offset);
static int flush_sample_queue(struct perf_session *s, static int ordered_events__flush(struct perf_session *s,
struct perf_tool *tool) struct perf_tool *tool)
{ {
struct ordered_samples *os = &s->ordered_samples; struct ordered_events *oe = &s->ordered_events;
struct list_head *head = &os->samples; struct list_head *head = &oe->samples;
struct sample_queue *tmp, *iter; struct ordered_event *tmp, *iter;
struct perf_sample sample; struct perf_sample sample;
u64 limit = os->next_flush; u64 limit = oe->next_flush;
u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL; u64 last_ts = oe->last_sample ? oe->last_sample->timestamp : 0ULL;
bool show_progress = limit == ULLONG_MAX; bool show_progress = limit == ULLONG_MAX;
struct ui_progress prog; struct ui_progress prog;
int ret; int ret;
...@@ -487,7 +487,7 @@ static int flush_sample_queue(struct perf_session *s, ...@@ -487,7 +487,7 @@ static int flush_sample_queue(struct perf_session *s,
return 0; return 0;
if (show_progress) if (show_progress)
ui_progress__init(&prog, os->nr_samples, "Processing time ordered events..."); ui_progress__init(&prog, oe->nr_samples, "Processing time ordered events...");
list_for_each_entry_safe(iter, tmp, head, list) { list_for_each_entry_safe(iter, tmp, head, list) {
if (session_done()) if (session_done())
...@@ -506,20 +506,20 @@ static int flush_sample_queue(struct perf_session *s, ...@@ -506,20 +506,20 @@ static int flush_sample_queue(struct perf_session *s,
return ret; return ret;
} }
os->last_flush = iter->timestamp; oe->last_flush = iter->timestamp;
list_del(&iter->list); list_del(&iter->list);
list_add(&iter->list, &os->sample_cache); list_add(&iter->list, &oe->sample_cache);
os->nr_samples--; oe->nr_samples--;
if (show_progress) if (show_progress)
ui_progress__update(&prog, 1); ui_progress__update(&prog, 1);
} }
if (list_empty(head)) { if (list_empty(head)) {
os->last_sample = NULL; oe->last_sample = NULL;
} else if (last_ts <= limit) { } else if (last_ts <= limit) {
os->last_sample = oe->last_sample =
list_entry(head->prev, struct sample_queue, list); list_entry(head->prev, struct ordered_event, list);
} }
return 0; return 0;
...@@ -568,27 +568,27 @@ static int process_finished_round(struct perf_tool *tool, ...@@ -568,27 +568,27 @@ static int process_finished_round(struct perf_tool *tool,
union perf_event *event __maybe_unused, union perf_event *event __maybe_unused,
struct perf_session *session) struct perf_session *session)
{ {
int ret = flush_sample_queue(session, tool); int ret = ordered_events__flush(session, tool);
if (!ret) if (!ret)
session->ordered_samples.next_flush = session->ordered_samples.max_timestamp; session->ordered_events.next_flush = session->ordered_events.max_timestamp;
return ret; return ret;
} }
/* The queue is ordered by time */ /* The queue is ordered by time */
static void __queue_event(struct sample_queue *new, struct perf_session *s) static void __queue_event(struct ordered_event *new, struct perf_session *s)
{ {
struct ordered_samples *os = &s->ordered_samples; struct ordered_events *oe = &s->ordered_events;
struct sample_queue *sample = os->last_sample; struct ordered_event *sample = oe->last_sample;
u64 timestamp = new->timestamp; u64 timestamp = new->timestamp;
struct list_head *p; struct list_head *p;
++os->nr_samples; ++oe->nr_samples;
os->last_sample = new; oe->last_sample = new;
if (!sample) { if (!sample) {
list_add(&new->list, &os->samples); list_add(&new->list, &oe->samples);
os->max_timestamp = timestamp; oe->max_timestamp = timestamp;
return; return;
} }
...@@ -600,59 +600,59 @@ static void __queue_event(struct sample_queue *new, struct perf_session *s) ...@@ -600,59 +600,59 @@ static void __queue_event(struct sample_queue *new, struct perf_session *s)
if (sample->timestamp <= timestamp) { if (sample->timestamp <= timestamp) {
while (sample->timestamp <= timestamp) { while (sample->timestamp <= timestamp) {
p = sample->list.next; p = sample->list.next;
if (p == &os->samples) { if (p == &oe->samples) {
list_add_tail(&new->list, &os->samples); list_add_tail(&new->list, &oe->samples);
os->max_timestamp = timestamp; oe->max_timestamp = timestamp;
return; return;
} }
sample = list_entry(p, struct sample_queue, list); sample = list_entry(p, struct ordered_event, list);
} }
list_add_tail(&new->list, &sample->list); list_add_tail(&new->list, &sample->list);
} else { } else {
while (sample->timestamp > timestamp) { while (sample->timestamp > timestamp) {
p = sample->list.prev; p = sample->list.prev;
if (p == &os->samples) { if (p == &oe->samples) {
list_add(&new->list, &os->samples); list_add(&new->list, &oe->samples);
return; return;
} }
sample = list_entry(p, struct sample_queue, list); sample = list_entry(p, struct ordered_event, list);
} }
list_add(&new->list, &sample->list); list_add(&new->list, &sample->list);
} }
} }
#define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue)) #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct ordered_event))
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_samples *os = &s->ordered_samples; struct ordered_events *oe = &s->ordered_events;
struct list_head *sc = &os->sample_cache; struct list_head *sc = &oe->sample_cache;
u64 timestamp = sample->time; u64 timestamp = sample->time;
struct sample_queue *new; struct ordered_event *new;
if (!timestamp || timestamp == ~0ULL) if (!timestamp || timestamp == ~0ULL)
return -ETIME; return -ETIME;
if (timestamp < s->ordered_samples.last_flush) { if (timestamp < s->ordered_events.last_flush) {
printf("Warning: Timestamp below last timeslice flush\n"); printf("Warning: Timestamp below last timeslice flush\n");
return -EINVAL; return -EINVAL;
} }
if (!list_empty(sc)) { if (!list_empty(sc)) {
new = list_entry(sc->next, struct sample_queue, list); new = list_entry(sc->next, struct ordered_event, list);
list_del(&new->list); list_del(&new->list);
} else if (os->sample_buffer) { } else if (oe->sample_buffer) {
new = os->sample_buffer + os->sample_buffer_idx; new = oe->sample_buffer + oe->sample_buffer_idx;
if (++os->sample_buffer_idx == MAX_SAMPLE_BUFFER) if (++oe->sample_buffer_idx == MAX_SAMPLE_BUFFER)
os->sample_buffer = NULL; oe->sample_buffer = NULL;
} else { } else {
os->sample_buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new)); oe->sample_buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
if (!os->sample_buffer) if (!oe->sample_buffer)
return -ENOMEM; return -ENOMEM;
list_add(&os->sample_buffer->list, &os->to_free); list_add(&oe->sample_buffer->list, &oe->to_free);
os->sample_buffer_idx = 2; oe->sample_buffer_idx = 2;
new = os->sample_buffer + 1; new = oe->sample_buffer + 1;
} }
new->timestamp = timestamp; new->timestamp = timestamp;
...@@ -1222,8 +1222,8 @@ static int __perf_session__process_pipe_events(struct perf_session *session, ...@@ -1222,8 +1222,8 @@ static int __perf_session__process_pipe_events(struct perf_session *session,
goto more; goto more;
done: done:
/* do the final flush for ordered samples */ /* do the final flush for ordered samples */
session->ordered_samples.next_flush = ULLONG_MAX; session->ordered_events.next_flush = ULLONG_MAX;
err = flush_sample_queue(session, tool); err = ordered_events__flush(session, tool);
out_err: out_err:
free(buf); free(buf);
perf_session__warn_about_errors(session, tool); perf_session__warn_about_errors(session, tool);
...@@ -1368,8 +1368,8 @@ int __perf_session__process_events(struct perf_session *session, ...@@ -1368,8 +1368,8 @@ int __perf_session__process_events(struct perf_session *session,
out: out:
/* do the final flush for ordered samples */ /* do the final flush for ordered samples */
session->ordered_samples.next_flush = ULLONG_MAX; session->ordered_events.next_flush = ULLONG_MAX;
err = flush_sample_queue(session, tool); err = ordered_events__flush(session, tool);
out_err: out_err:
ui_progress__finish(); ui_progress__finish();
perf_session__warn_about_errors(session, tool); perf_session__warn_about_errors(session, tool);
......
...@@ -12,19 +12,19 @@ ...@@ -12,19 +12,19 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
struct sample_queue; struct ordered_event;
struct ip_callchain; struct ip_callchain;
struct thread; struct thread;
struct ordered_samples { struct ordered_events {
u64 last_flush; u64 last_flush;
u64 next_flush; u64 next_flush;
u64 max_timestamp; u64 max_timestamp;
struct list_head samples; struct list_head samples;
struct list_head sample_cache; struct list_head sample_cache;
struct list_head to_free; struct list_head to_free;
struct sample_queue *sample_buffer; struct ordered_event *sample_buffer;
struct sample_queue *last_sample; struct ordered_event *last_sample;
int sample_buffer_idx; int sample_buffer_idx;
unsigned int nr_samples; unsigned int nr_samples;
}; };
...@@ -39,7 +39,7 @@ struct perf_session { ...@@ -39,7 +39,7 @@ struct perf_session {
bool one_mmap; bool one_mmap;
void *one_mmap_addr; void *one_mmap_addr;
u64 one_mmap_offset; u64 one_mmap_offset;
struct ordered_samples ordered_samples; struct ordered_events ordered_events;
struct perf_data_file *file; struct perf_data_file *file;
}; };
......
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