lkml.org 
[lkml]   [2020]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] kernel/trace: Add TRACING_ALLOW_PRINTK config option
On Wed, Jun 24, 2020 at 9:57 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Wed, Jun 24, 2020 at 04:45:24PM +0800, Nicolas Boichat wrote:
> > trace_printk is only meant as a debugging tool, and should never be
> > compiled into production code without 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. **
> >
> > If this option is set to n, the kernel will generate a build-time
> > error if trace_printk is used.
> >
> > Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> > include/linux/kernel.h | 17 ++++++++++++++++-
> > kernel/trace/Kconfig | 9 +++++++++
> > 2 files changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > index 196607aaf653082..b6addc6ba669e85 100644
> > +++ b/include/linux/kernel.h
> > @@ -721,10 +721,15 @@ do { \
> > #define trace_printk(fmt, ...) \
> > do { \
> > char _______STR[] = __stringify((__VA_ARGS__)); \
> > + \
> > + __static_assert( \
> > + IS_ENABLED(CONFIG_TRACING_ALLOW_PRINTK),\
> > + "trace_printk called, please enable CONFIG_TRACING_ALLOW_PRINTK."); \
> > + \
>
> Why __static_assert not normal static_assert?

Oh, I misread the macro code (and didn't read the comment above in
include/linux/build_bug.h). static_assert would be just fine.

>
> Jason

\
 
 \ /
  Last update: 2020-06-25 03:14    [W:0.626 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site