diff mbox series

[09/23] libtracefs: Increase splice to use pipe max size

Message ID 20231228203714.53294-10-rostedt@goodmis.org (mailing list archive)
State Superseded
Headers show
Series libtracefs: Several updates | expand

Commit Message

Steven Rostedt Dec. 28, 2023, 8:35 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

When a pipe is created for splicing to read the tracing ring buffer, instead
of using the default size, which is usually around 65K, read
/proc/sys/fs/pipe_max_size and try to set the pipe to use that size instead.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-record.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/src/tracefs-record.c b/src/tracefs-record.c
index b078c8615194..8750fe7e0e29 100644
--- a/src/tracefs-record.c
+++ b/src/tracefs-record.c
@@ -319,6 +319,7 @@  int tracefs_cpu_read(struct tracefs_cpu *tcpu, void *buffer, bool nonblock)
 
 static int init_splice(struct tracefs_cpu *tcpu)
 {
+	char *buf;
 	int ret;
 
 	if (tcpu->splice_pipe[0] >= 0)
@@ -328,6 +329,12 @@  static int init_splice(struct tracefs_cpu *tcpu)
 	if (ret < 0)
 		return ret;
 
+	if (str_read_file("/proc/sys/fs/pipe-max-size", &buf, false)) {
+		int size = atoi(buf);
+		fcntl(tcpu->splice_pipe[0], F_SETPIPE_SZ, &size);
+		free(buf);
+	}
+
 	ret = fcntl(tcpu->splice_pipe[0], F_GETPIPE_SZ, &tcpu->pipe_size);
 	/*
 	 * F_GETPIPE_SZ was introduced in 2.6.35, ftrace was introduced