From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> If mmapping the ring buffer is available, use that for iterating raw events as it's less copying than using splice buffering. Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- src/tracefs-events.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 2571c4b43341..9f620abebdda 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -32,6 +32,7 @@ struct cpu_iterate { struct tep_event *event; struct kbuffer *kbuf; int cpu; + bool mapped; }; static int read_kbuf_record(struct cpu_iterate *cpu) @@ -66,7 +67,11 @@ int read_next_page(struct tep_handle *tep, struct cpu_iterate *cpu) if (!cpu->tcpu) return -1; - kbuf = tracefs_cpu_buffered_read_buf(cpu->tcpu, true); + /* Do not do buffered reads if it is mapped */ + if (cpu->mapped) + kbuf = tracefs_cpu_read_buf(cpu->tcpu, true); + else + kbuf = tracefs_cpu_buffered_read_buf(cpu->tcpu, true); /* * tracefs_cpu_buffered_read_buf() only reads in full subbuffer size, * but this wants partial buffers as well. If the function returns @@ -274,7 +279,7 @@ static int open_cpu_files(struct tracefs_instance *instance, cpu_set_t *cpus, if (snapshot) tcpu = tracefs_cpu_snapshot_open(instance, cpu, true); else - tcpu = tracefs_cpu_open(instance, cpu, true); + tcpu = tracefs_cpu_open_mapped(instance, cpu, true); tmp = realloc(*all_cpus, (i + 1) * sizeof(*tmp)); if (!tmp) { i--; @@ -290,6 +295,7 @@ static int open_cpu_files(struct tracefs_instance *instance, cpu_set_t *cpus, tmp[i].tcpu = tcpu; tmp[i].cpu = cpu; + tmp[i].mapped = tracefs_cpu_is_mapped(tcpu); i++; } *count = i; -- 2.43.0