aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-03-31 11:48:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-31 16:52:32 -0400
commit9870d7809575515e26194f4b3df1750872a6ee60 (patch)
tree43905494fe3c7724b8fe4326a4e820e897e7a7e9 /tools
parentaae59fab978e143f24d22e52f075c4be3ee4e628 (diff)
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 b7b61cbebd789a3dbca522e3fdb727fe5c95593f 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: Jiri Olsa <jolsa@kernel.org> Acked-by: Jiri 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.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/event.h1
-rw-r--r--tools/perf/util/ordered-events.c21
-rw-r--r--tools/perf/util/ordered-events.h14
-rw-r--r--tools/perf/util/session.c47
-rw-r--r--tools/perf/util/session.h1
5 files changed, 37 insertions, 47 deletions
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index c4ffe2bd0738..09b9e8d3fcf7 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -242,7 +242,6 @@ struct events_stats {
242 u32 nr_invalid_chains; 242 u32 nr_invalid_chains;
243 u32 nr_unknown_id; 243 u32 nr_unknown_id;
244 u32 nr_unprocessable_samples; 244 u32 nr_unprocessable_samples;
245 u32 nr_unordered_events;
246}; 245};
247 246
248struct attr_event { 247struct attr_event {
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index 6002fa3fcf77..52be201b9b25 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -2,7 +2,6 @@
2#include <linux/compiler.h> 2#include <linux/compiler.h>
3#include <linux/string.h> 3#include <linux/string.h>
4#include "ordered-events.h" 4#include "ordered-events.h"
5#include "evlist.h"
6#include "session.h" 5#include "session.h"
7#include "asm/bug.h" 6#include "asm/bug.h"
8#include "debug.h" 7#include "debug.h"
@@ -167,7 +166,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
167 pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n", 166 pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
168 oe->last_flush_type); 167 oe->last_flush_type);
169 168
170 oe->evlist->stats.nr_unordered_events++; 169 oe->nr_unordered_events++;
171 } 170 }
172 171
173 oevent = ordered_events__new_event(oe, timestamp, event); 172 oevent = ordered_events__new_event(oe, timestamp, event);
@@ -187,7 +186,6 @@ static int __ordered_events__flush(struct ordered_events *oe)
187{ 186{
188 struct list_head *head = &oe->events; 187 struct list_head *head = &oe->events;
189 struct ordered_event *tmp, *iter; 188 struct ordered_event *tmp, *iter;
190 struct perf_sample sample;
191 u64 limit = oe->next_flush; 189 u64 limit = oe->next_flush;
192 u64 last_ts = oe->last ? oe->last->timestamp : 0ULL; 190 u64 last_ts = oe->last ? oe->last->timestamp : 0ULL;
193 bool show_progress = limit == ULLONG_MAX; 191 bool show_progress = limit == ULLONG_MAX;
@@ -206,15 +204,9 @@ static int __ordered_events__flush(struct ordered_events *oe)
206 204
207 if (iter->timestamp > limit) 205 if (iter->timestamp > limit)
208 break; 206 break;
209 207 ret = oe->deliver(oe, iter);
210 ret = perf_evlist__parse_sample(oe->evlist, iter->event, &sample);
211 if (ret) 208 if (ret)
212 pr_err("Can't parse sample, err = %d\n", ret); 209 return ret;
213 else {
214 ret = oe->deliver(oe, iter, &sample);
215 if (ret)
216 return ret;
217 }
218 210
219 ordered_events__delete(oe, iter); 211 ordered_events__delete(oe, iter);
220 oe->last_flush = iter->timestamp; 212 oe->last_flush = iter->timestamp;
@@ -292,18 +284,13 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
292 return err; 284 return err;
293} 285}
294 286
295void ordered_events__init(struct ordered_events *oe, struct machines *machines, 287void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver)
296 struct perf_evlist *evlist, struct perf_tool *tool,
297 ordered_events__deliver_t deliver)
298{ 288{
299 INIT_LIST_HEAD(&oe->events); 289 INIT_LIST_HEAD(&oe->events);
300 INIT_LIST_HEAD(&oe->cache); 290 INIT_LIST_HEAD(&oe->cache);
301 INIT_LIST_HEAD(&oe->to_free); 291 INIT_LIST_HEAD(&oe->to_free);
302 oe->max_alloc_size = (u64) -1; 292 oe->max_alloc_size = (u64) -1;
303 oe->cur_alloc_size = 0; 293 oe->cur_alloc_size = 0;
304 oe->evlist = evlist;
305 oe->machines = machines;
306 oe->tool = tool;
307 oe->deliver = deliver; 294 oe->deliver = deliver;
308} 295}
309 296
diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h
index 173e13f28c08..f403991e3bfd 100644
--- a/tools/perf/util/ordered-events.h
+++ b/tools/perf/util/ordered-events.h
@@ -3,10 +3,7 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6struct perf_tool;
7struct perf_evlist;
8struct perf_sample; 6struct perf_sample;
9struct machines;
10 7
11struct ordered_event { 8struct ordered_event {
12 u64 timestamp; 9 u64 timestamp;
@@ -25,8 +22,7 @@ enum oe_flush {
25struct ordered_events; 22struct ordered_events;
26 23
27typedef int (*ordered_events__deliver_t)(struct ordered_events *oe, 24typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
28 struct ordered_event *event, 25 struct ordered_event *event);
29 struct perf_sample *sample);
30 26
31struct ordered_events { 27struct ordered_events {
32 u64 last_flush; 28 u64 last_flush;
@@ -39,13 +35,11 @@ struct ordered_events {
39 struct list_head to_free; 35 struct list_head to_free;
40 struct ordered_event *buffer; 36 struct ordered_event *buffer;
41 struct ordered_event *last; 37 struct ordered_event *last;
42 struct machines *machines;
43 struct perf_evlist *evlist;
44 struct perf_tool *tool;
45 ordered_events__deliver_t deliver; 38 ordered_events__deliver_t deliver;
46 int buffer_idx; 39 int buffer_idx;
47 unsigned int nr_events; 40 unsigned int nr_events;
48 enum oe_flush last_flush_type; 41 enum oe_flush last_flush_type;
42 u32 nr_unordered_events;
49 bool copy_on_queue; 43 bool copy_on_queue;
50}; 44};
51 45
@@ -53,9 +47,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
53 struct perf_sample *sample, u64 file_offset); 47 struct perf_sample *sample, u64 file_offset);
54void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); 48void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
55int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); 49int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
56void ordered_events__init(struct ordered_events *oe, struct machines *machines, 50void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver);
57 struct perf_evlist *evlsit, struct perf_tool *tool,
58 ordered_events__deliver_t deliver);
59void ordered_events__free(struct ordered_events *oe); 51void ordered_events__free(struct ordered_events *oe);
60 52
61static inline 53static inline
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 89c66797abe4..dfacf1d50162 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -93,11 +93,20 @@ static void perf_session__set_comm_exec(struct perf_session *session)
93} 93}
94 94
95static int ordered_events__deliver_event(struct ordered_events *oe, 95static int ordered_events__deliver_event(struct ordered_events *oe,
96 struct ordered_event *event, 96 struct ordered_event *event)
97 struct perf_sample *sample)
98{ 97{
99 return machines__deliver_event(oe->machines, oe->evlist, event->event, 98 struct perf_sample sample;
100 sample, oe->tool, event->file_offset); 99 struct perf_session *session = container_of(oe, struct perf_session,
100 ordered_events);
101 int ret = perf_evlist__parse_sample(session->evlist, event->event, &sample);
102
103 if (ret) {
104 pr_err("Can't parse sample, err = %d\n", ret);
105 return ret;
106 }
107
108 return machines__deliver_event(&session->machines, session->evlist, event->event,
109 &sample, session->tool, event->file_offset);
101} 110}
102 111
103struct perf_session *perf_session__new(struct perf_data_file *file, 112struct 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 goto out; 118 goto out;
110 119
111 session->repipe = repipe; 120 session->repipe = repipe;
121 session->tool = tool;
112 machines__init(&session->machines); 122 machines__init(&session->machines);
113 ordered_events__init(&session->ordered_events, &session->machines, 123 ordered_events__init(&session->ordered_events, ordered_events__deliver_event);
114 session->evlist, tool, ordered_events__deliver_event);
115 124
116 if (file) { 125 if (file) {
117 if (perf_data_file__open(file)) 126 if (perf_data_file__open(file))
@@ -940,7 +949,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
940 u64 file_offset) 949 u64 file_offset)
941{ 950{
942 struct ordered_events *oe = &session->ordered_events; 951 struct ordered_events *oe = &session->ordered_events;
943 struct perf_tool *tool = oe->tool; 952 struct perf_tool *tool = session->tool;
944 int fd = perf_data_file__fd(session->file); 953 int fd = perf_data_file__fd(session->file);
945 int err; 954 int err;
946 955
@@ -981,7 +990,7 @@ int perf_session__deliver_synth_event(struct perf_session *session,
981 struct perf_sample *sample) 990 struct perf_sample *sample)
982{ 991{
983 struct perf_evlist *evlist = session->evlist; 992 struct perf_evlist *evlist = session->evlist;
984 struct perf_tool *tool = session->ordered_events.tool; 993 struct perf_tool *tool = session->tool;
985 994
986 events_stats__inc(&evlist->stats, event->header.type); 995 events_stats__inc(&evlist->stats, event->header.type);
987 996
@@ -1059,7 +1068,7 @@ static s64 perf_session__process_event(struct perf_session *session,
1059 union perf_event *event, u64 file_offset) 1068 union perf_event *event, u64 file_offset)
1060{ 1069{
1061 struct perf_evlist *evlist = session->evlist; 1070 struct perf_evlist *evlist = session->evlist;
1062 struct perf_tool *tool = session->ordered_events.tool; 1071 struct perf_tool *tool = session->tool;
1063 struct perf_sample sample; 1072 struct perf_sample sample;
1064 int ret; 1073 int ret;
1065 1074
@@ -1116,10 +1125,12 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
1116 return thread; 1125 return thread;
1117} 1126}
1118 1127
1119static void perf_tool__warn_about_errors(const struct perf_tool *tool, 1128static void perf_session__warn_about_errors(const struct perf_session *session)
1120 const struct events_stats *stats)
1121{ 1129{
1122 if (tool->lost == perf_event__process_lost && 1130 const struct events_stats *stats = &session->evlist->stats;
1131 const struct ordered_events *oe = &session->ordered_events;
1132
1133 if (session->tool->lost == perf_event__process_lost &&
1123 stats->nr_events[PERF_RECORD_LOST] != 0) { 1134 stats->nr_events[PERF_RECORD_LOST] != 0) {
1124 ui__warning("Processed %d events and lost %d chunks!\n\n" 1135 ui__warning("Processed %d events and lost %d chunks!\n\n"
1125 "Check IO/CPU overload!\n\n", 1136 "Check IO/CPU overload!\n\n",
@@ -1155,8 +1166,8 @@ static void perf_tool__warn_about_errors(const struct perf_tool *tool,
1155 stats->nr_unprocessable_samples); 1166 stats->nr_unprocessable_samples);
1156 } 1167 }
1157 1168
1158 if (stats->nr_unordered_events != 0) 1169 if (oe->nr_unordered_events != 0)
1159 ui__warning("%u out of order events recorded.\n", stats->nr_unordered_events); 1170 ui__warning("%u out of order events recorded.\n", oe->nr_unordered_events);
1160} 1171}
1161 1172
1162volatile int session_done; 1173volatile int session_done;
@@ -1164,7 +1175,7 @@ volatile int session_done;
1164static int __perf_session__process_pipe_events(struct perf_session *session) 1175static int __perf_session__process_pipe_events(struct perf_session *session)
1165{ 1176{
1166 struct ordered_events *oe = &session->ordered_events; 1177 struct ordered_events *oe = &session->ordered_events;
1167 struct perf_tool *tool = oe->tool; 1178 struct perf_tool *tool = session->tool;
1168 int fd = perf_data_file__fd(session->file); 1179 int fd = perf_data_file__fd(session->file);
1169 union perf_event *event; 1180 union perf_event *event;
1170 uint32_t size, cur_size = 0; 1181 uint32_t size, cur_size = 0;
@@ -1247,7 +1258,7 @@ done:
1247 err = ordered_events__flush(oe, OE_FLUSH__FINAL); 1258 err = ordered_events__flush(oe, OE_FLUSH__FINAL);
1248out_err: 1259out_err:
1249 free(buf); 1260 free(buf);
1250 perf_tool__warn_about_errors(tool, &session->evlist->stats); 1261 perf_session__warn_about_errors(session);
1251 ordered_events__free(&session->ordered_events); 1262 ordered_events__free(&session->ordered_events);
1252 return err; 1263 return err;
1253} 1264}
@@ -1297,7 +1308,7 @@ static int __perf_session__process_events(struct perf_session *session,
1297 u64 file_size) 1308 u64 file_size)
1298{ 1309{
1299 struct ordered_events *oe = &session->ordered_events; 1310 struct ordered_events *oe = &session->ordered_events;
1300 struct perf_tool *tool = oe->tool; 1311 struct perf_tool *tool = session->tool;
1301 int fd = perf_data_file__fd(session->file); 1312 int fd = perf_data_file__fd(session->file);
1302 u64 head, page_offset, file_offset, file_pos, size; 1313 u64 head, page_offset, file_offset, file_pos, size;
1303 int err, mmap_prot, mmap_flags, map_idx = 0; 1314 int err, mmap_prot, mmap_flags, map_idx = 0;
@@ -1393,7 +1404,7 @@ out:
1393 err = ordered_events__flush(oe, OE_FLUSH__FINAL); 1404 err = ordered_events__flush(oe, OE_FLUSH__FINAL);
1394out_err: 1405out_err:
1395 ui_progress__finish(); 1406 ui_progress__finish();
1396 perf_tool__warn_about_errors(tool, &session->evlist->stats); 1407 perf_session__warn_about_errors(session);
1397 ordered_events__free(&session->ordered_events); 1408 ordered_events__free(&session->ordered_events);
1398 session->one_mmap = false; 1409 session->one_mmap = false;
1399 return err; 1410 return err;
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 1310998f8318..d5fa7b7916ef 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -26,6 +26,7 @@ struct perf_session {
26 u64 one_mmap_offset; 26 u64 one_mmap_offset;
27 struct ordered_events ordered_events; 27 struct ordered_events ordered_events;
28 struct perf_data_file *file; 28 struct perf_data_file *file;
29 struct perf_tool *tool;
29}; 30};
30 31
31#define PRINT_IP_OPT_IP (1<<0) 32#define PRINT_IP_OPT_IP (1<<0)