public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: Have trace_marker writes be just half of TRACE_SEQ_SIZE
@ 2024-03-05  0:27 Steven Rostedt
  2024-03-05  0:43 ` Randy Dunlap
  2024-03-05  1:15 ` Mathieu Desnoyers
  0 siblings, 2 replies; 15+ messages in thread
From: Steven Rostedt @ 2024-03-05  0:27 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Mathieu Desnoyers, Linus Torvalds, Sachin Sant

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Since the size of trace_seq's buffer is the max an event can output, have
the trace_marker be half of the entire TRACE_SEQ_SIZE, which is 4K. That
will keep writes that has meta data written from being dropped (but
reported), because the total output of the print event is greater than
what the trace_seq can hold.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8198bfc54b58..d68544aef65f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7320,6 +7320,17 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
 	if ((ssize_t)cnt < 0)
 		return -EINVAL;
 
+	/*
+	 * TRACE_SEQ_SIZE is the total size of trace_seq buffer used
+	 * for output. As the print event outputs more than just
+	 * the string written, keep it smaller than the trace_seq
+	 * as it could drop the event if the extra data makes it bigger
+	 * than what the trace_seq can hold. Half he TRACE_SEQ_SIZE
+	 * is more than enough.
+	 */
+	if (cnt > TRACE_SEQ_SIZE / 2)
+		cnt = TRACE_SEQ_SIZE / 2;
+
 	meta_size = sizeof(*entry) + 2;  /* add '\0' and possible '\n' */
  again:
 	size = cnt + meta_size;
@@ -7328,11 +7339,6 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
 	if (cnt < FAULTED_SIZE)
 		size += FAULTED_SIZE - cnt;
 
-	if (size > TRACE_SEQ_BUFFER_SIZE) {
-		cnt -= size - TRACE_SEQ_BUFFER_SIZE;
-		goto again;
-	}
-
 	buffer = tr->array_buffer.buffer;
 	event = __trace_buffer_lock_reserve(buffer, TRACE_PRINT, size,
 					    tracing_gen_ctx());
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-03-05  3:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05  0:27 [PATCH] tracing: Have trace_marker writes be just half of TRACE_SEQ_SIZE Steven Rostedt
2024-03-05  0:43 ` Randy Dunlap
2024-03-05  0:49   ` Steven Rostedt
2024-03-05  1:15 ` Mathieu Desnoyers
2024-03-05  1:35   ` Steven Rostedt
2024-03-05  1:36     ` Mathieu Desnoyers
2024-03-05  1:57       ` Steven Rostedt
2024-03-05  1:41     ` Steven Rostedt
2024-03-05  1:42       ` Mathieu Desnoyers
2024-03-05  1:59         ` Steven Rostedt
2024-03-05  2:18           ` Mathieu Desnoyers
2024-03-05  2:35             ` Steven Rostedt
2024-03-05  2:37               ` Steven Rostedt
2024-03-05  2:48                 ` Mathieu Desnoyers
2024-03-05  3:07                   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox