Re: [PATCH] tracing: Have trace_marker writes be just half of TRACE_SEQ_SIZE

From: Randy Dunlap
Date: Mon Mar 04 2024 - 19:44:00 EST



> 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

the

> + * 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;


--
#Randy