From: John Ogness <john.ogness@linutronix.de>
To: Jim Cromie <jim.cromie@gmail.com>,
rostedt@goodmis.org, linux-kernel@vger.kernel.org
Cc: Jim Cromie <jim.cromie@gmail.com>,
Vincent Whitchurch <vincent.whitchurch@axis.com>,
daniel@ffwll.ch, pmladek@suse.com, sergey.senozhatsky@gmail.com,
Simon Ser <contact@emersion.fr>,
Sean Paul <seanpaul@chromium.org>
Subject: Re: [RFC PATCH 1/1] tracefs: add TP_printk_no_nl - RFC
Date: Mon, 31 Jul 2023 10:31:03 +0206 [thread overview]
Message-ID: <87y1iwlc80.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20230730222134.54547-1-jim.cromie@gmail.com>
On 2023-07-30, Jim Cromie <jim.cromie@gmail.com> wrote:
> This variant of TP_printk() does *not* add the trailing newline.
>
> https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@axis.com/
>
> taught dyndbg to send pr_debug() msgs to tracefs, via -x/T flag.
>
> It "reused" the include/trace/events/printk.h console event,
> which does the following:
>
> TP_fast_assign(
> /*
> * Each trace entry is printed in a new line.
> * If the msg finishes with '\n', cut it off
> * to avoid blank lines in the trace.
> */
> if ((len > 0) && (text[len-1] == '\n'))
> len -= 1;
>
> memcpy(__get_str(msg), text, len);
> __get_str(msg)[len] = 0;
> ),
>
> That trim work could be avoided, *iff* all pr_debug() callers are
> known to have no '\n' to strip. While thats not true for *all*
> callsites, it is 99+% true for DRM.debug callsites, and can be made
> true for some subsets of prdbg/dyndbg callsites.
Note that the trailing '\n' in printk messages has a purpose. It
finalizes commitment of the message to the ringbuffer so that the
message cannot be extended by any LOG_CONT printk's that may come along
(from any context).
If it is not intended that a message is extended, then that message
should include a trailing '\n'.
Grepping through the kernel, I am surprised how many messages are
missing the trailing newline when it is obvious they are not intended to
be extended. I consider these bugs.
John Ogness
next prev parent reply other threads:[~2023-07-31 8:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-30 22:21 [RFC PATCH 1/1] tracefs: add TP_printk_no_nl - RFC Jim Cromie
2023-07-31 8:25 ` John Ogness [this message]
2023-07-31 10:21 ` Petr Mladek
2023-07-31 15:21 ` Steven Rostedt
2023-07-31 21:01 ` jim.cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1iwlc80.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=jim.cromie@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=seanpaul@chromium.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=vincent.whitchurch@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox