aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2018-12-05 11:05:07 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-12-17 13:02:12 -0500
commit68ca5d07de207e56f57e887de23b03fbc1ebc2a6 (patch)
tree5bf6181a2d4f15fb81c615ea29d0ab72e73737e8
parent6d99a79cb40da3eddafef844b7a679fe5162f224 (diff)
perf ordered_events: Add ordered_events__flush_time interface
Add OE_FLUSH__TIME flush type, to be able to flush only certain amount of the queue based on the provided timestamp. It will be used in the following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Dmitry Levin <ldv@altlinux.org> Cc: Eugene Syromiatnikov <esyr@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Luis Cláudio Gonçalves <lclaudio@uudg.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20181205160509.1168-7-jolsa@kernel.org [ Fix the build on older systems such as centos 5 and 6 where 'time' shadows a global declaration ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/ordered-events.c23
-rw-r--r--tools/perf/util/ordered-events.h2
2 files changed, 21 insertions, 4 deletions
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index c5412db05683..46965643020b 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -219,8 +219,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
219 return 0; 219 return 0;
220} 220}
221 221
222static int __ordered_events__flush(struct ordered_events *oe, 222static int do_flush(struct ordered_events *oe, bool show_progress)
223 bool show_progress)
224{ 223{
225 struct list_head *head = &oe->events; 224 struct list_head *head = &oe->events;
226 struct ordered_event *tmp, *iter; 225 struct ordered_event *tmp, *iter;
@@ -263,7 +262,8 @@ static int __ordered_events__flush(struct ordered_events *oe,
263 return 0; 262 return 0;
264} 263}
265 264
266int ordered_events__flush(struct ordered_events *oe, enum oe_flush how) 265static int __ordered_events__flush(struct ordered_events *oe, enum oe_flush how,
266 u64 timestamp)
267{ 267{
268 static const char * const str[] = { 268 static const char * const str[] = {
269 "NONE", 269 "NONE",
@@ -302,6 +302,11 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
302 break; 302 break;
303 } 303 }
304 304
305 case OE_FLUSH__TIME:
306 oe->next_flush = timestamp;
307 show_progress = false;
308 break;
309
305 case OE_FLUSH__ROUND: 310 case OE_FLUSH__ROUND:
306 case OE_FLUSH__NONE: 311 case OE_FLUSH__NONE:
307 default: 312 default:
@@ -312,7 +317,7 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
312 str[how], oe->nr_events); 317 str[how], oe->nr_events);
313 pr_oe_time(oe->max_timestamp, "max_timestamp\n"); 318 pr_oe_time(oe->max_timestamp, "max_timestamp\n");
314 319
315 err = __ordered_events__flush(oe, show_progress); 320 err = do_flush(oe, show_progress);
316 321
317 if (!err) { 322 if (!err) {
318 if (how == OE_FLUSH__ROUND) 323 if (how == OE_FLUSH__ROUND)
@@ -328,6 +333,16 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
328 return err; 333 return err;
329} 334}
330 335
336int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
337{
338 return __ordered_events__flush(oe, how, 0);
339}
340
341int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp)
342{
343 return __ordered_events__flush(oe, OE_FLUSH__TIME, timestamp);
344}
345
331void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver, 346void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver,
332 void *data) 347 void *data)
333{ 348{
diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h
index 0c6e26aec0e3..f352af20e167 100644
--- a/tools/perf/util/ordered-events.h
+++ b/tools/perf/util/ordered-events.h
@@ -19,6 +19,7 @@ enum oe_flush {
19 OE_FLUSH__ROUND, 19 OE_FLUSH__ROUND,
20 OE_FLUSH__HALF, 20 OE_FLUSH__HALF,
21 OE_FLUSH__TOP, 21 OE_FLUSH__TOP,
22 OE_FLUSH__TIME,
22}; 23};
23 24
24struct ordered_events; 25struct ordered_events;
@@ -55,6 +56,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
55 u64 timestamp, u64 file_offset); 56 u64 timestamp, u64 file_offset);
56void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); 57void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
57int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); 58int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
59int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp);
58void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver, 60void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver,
59 void *data); 61 void *data);
60void ordered_events__free(struct ordered_events *oe); 62void ordered_events__free(struct ordered_events *oe);