Currently the return value of the callback function can be used to stop pulling data from the trace buffer, however this return value is lost and the user has no idea if tracefs_iterate_raw_events() terminated because there was no more data or because this was requested from the callback function. If we propagate the return value of the callback, this can be used in cases like the one below: int callback(struct tep_event *event, struct tep_record *record, int cpu, void *py_func) { .... return (something) ? 0 : 1 } int main() { int ret; .... while(ret == 0) ret = tracefs_iterate_raw_events(tep, instance, NULL, 0, callback, NULL); .... Here the user can effectively terminate the pulling the data from inside the callback. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> --- src/tracefs-events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 0fef64f..0a87d28 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -131,7 +131,8 @@ static int read_cpu_pages(struct tep_handle *tep, struct cpu_iterate *cpus, int } if (j < count) { if (callback(cpus[j].event, &cpus[j].record, cpus[j].cpu, callback_context)) - break; + return -1; + cpus[j].event = NULL; read_next_record(tep, cpus + j); } else { -- 2.27.0