Commit 68ca5d07 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6d99a79c
...@@ -219,8 +219,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event, ...@@ -219,8 +219,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
return 0; return 0;
} }
static int __ordered_events__flush(struct ordered_events *oe, static int do_flush(struct ordered_events *oe, bool show_progress)
bool show_progress)
{ {
struct list_head *head = &oe->events; struct list_head *head = &oe->events;
struct ordered_event *tmp, *iter; struct ordered_event *tmp, *iter;
...@@ -263,7 +262,8 @@ static int __ordered_events__flush(struct ordered_events *oe, ...@@ -263,7 +262,8 @@ static int __ordered_events__flush(struct ordered_events *oe,
return 0; return 0;
} }
int ordered_events__flush(struct ordered_events *oe, enum oe_flush how) static int __ordered_events__flush(struct ordered_events *oe, enum oe_flush how,
u64 timestamp)
{ {
static const char * const str[] = { static const char * const str[] = {
"NONE", "NONE",
...@@ -302,6 +302,11 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how) ...@@ -302,6 +302,11 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
break; break;
} }
case OE_FLUSH__TIME:
oe->next_flush = timestamp;
show_progress = false;
break;
case OE_FLUSH__ROUND: case OE_FLUSH__ROUND:
case OE_FLUSH__NONE: case OE_FLUSH__NONE:
default: default:
...@@ -312,7 +317,7 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how) ...@@ -312,7 +317,7 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
str[how], oe->nr_events); str[how], oe->nr_events);
pr_oe_time(oe->max_timestamp, "max_timestamp\n"); pr_oe_time(oe->max_timestamp, "max_timestamp\n");
err = __ordered_events__flush(oe, show_progress); err = do_flush(oe, show_progress);
if (!err) { if (!err) {
if (how == OE_FLUSH__ROUND) if (how == OE_FLUSH__ROUND)
...@@ -328,6 +333,16 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how) ...@@ -328,6 +333,16 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
return err; return err;
} }
int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
{
return __ordered_events__flush(oe, how, 0);
}
int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp)
{
return __ordered_events__flush(oe, OE_FLUSH__TIME, timestamp);
}
void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver, void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver,
void *data) void *data)
{ {
......
...@@ -19,6 +19,7 @@ enum oe_flush { ...@@ -19,6 +19,7 @@ enum oe_flush {
OE_FLUSH__ROUND, OE_FLUSH__ROUND,
OE_FLUSH__HALF, OE_FLUSH__HALF,
OE_FLUSH__TOP, OE_FLUSH__TOP,
OE_FLUSH__TIME,
}; };
struct ordered_events; struct ordered_events;
...@@ -55,6 +56,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event, ...@@ -55,6 +56,7 @@ int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
u64 timestamp, u64 file_offset); u64 timestamp, 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);
int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp);
void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver, void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver,
void *data); void *data);
void ordered_events__free(struct ordered_events *oe); void ordered_events__free(struct ordered_events *oe);
......
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