From: Joe Perches <joe@perches.com>
To: Nicolas Boichat <drinkcat@chromium.org>,
Andy Whitcroft <apw@canonical.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: Warn if trace_printk and friends are called
Date: Tue, 25 Aug 2020 00:23:26 -0700 [thread overview]
Message-ID: <6972ee8f4bd9d19c137e2526fae53cf4379f4499.camel@perches.com> (raw)
In-Reply-To: <20200825150942.1.I723c43c155f02f726c97501be77984f1e6bb740a@changeid>
On Tue, 2020-08-25 at 15:09 +0800, Nicolas Boichat wrote:
> trace_printk is meant as a debugging tool, and should not be
> compiled into production code without specific debug Kconfig
> options enabled, or source code changes, as indicated by the
> warning that shows up on boot if any trace_printk is called:
> ** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **
> ** **
> ** trace_printk() being used. Allocating extra memory. **
> ** **
> ** This means that this is a DEBUG kernel and it is **
> ** unsafe for production use. **
>
> Let's warn developers when they try to submit such a change.
>
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> ---
>
> See also extensive discussion under this thread:
> https://lkml.org/lkml/2020/8/20/244
>
> This seems to be the simplest way to try to reduce the number
> of trace_printk that make it into the kernel.
I don't have a real objection, just some nits.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -4272,6 +4272,14 @@ sub process {
> "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
> }
>
> +# trace_printk should not be used in production code.
> + if ($line =~ /\b(trace_printk|trace_puts|ftrace_vprintk)\s*\(/) {
> + my $func = $1;
> +
> + WARN("TRACE_PRINTK",
> + "Do not use $func() in production code (this can be ignored if built only behind a debug config option).\n" . $herecurr);
You don't need to do an assign, you could use $1 directly.
I think 'built only behind' could be "building only with'.
No periods before the newline either.
> + }
> +
> # ENOSYS means "bad syscall nr" and nothing else. This will have a small
> # number of false positives, but assembly files are not checked, so at
> # least the arch entry code will not trigger this warning.
prev parent reply other threads:[~2020-08-25 7:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 7:09 Nicolas Boichat
2020-08-25 7:23 ` Joe Perches [this message]
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=6972ee8f4bd9d19c137e2526fae53cf4379f4499.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=drinkcat@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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
all inboxes | Powered by JetHome®