Re: [PATCH v5] kernel/trace: Add DISALLOW_TRACE_PRINTK make option

From: Nicolas Boichat
Date: Mon Aug 24 2020 - 20:38:42 EST


On Mon, Aug 24, 2020 at 9:30 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Mon, 24 Aug 2020 10:59:13 +0800
> Nicolas Boichat <drinkcat@xxxxxxxxxxxx> wrote:
>
> > ---
> >

> > +ifeq ($(KBUILD_DISALLOW_TRACE_PRINTK),1)
> > +KBUILD_CFLAGS += -DDISALLOW_TRACE_PRINTK
> > +endif
> > +
> > KBUILD_CFLAGS += $(DEBUG_CFLAGS)
> > export DEBUG_CFLAGS
> >
>
>
> There's one more thing we need to do, is if you build without this option
> then build with it, you should trigger a full kernel rebuild.
> Otherwise, if you build without the option, then build with it, and it
> doesn't rebuild the tree, it wont catch anything.

This already works. I'll be honest, I'm not 100% sure why (and if
fully intentional)...

The CFLAGS end up in 3 generated assembly files:
# grep -R DISALLOW_TRACE_PRINTK * | grep -v ".cmd:"
arch/x86/kernel/asm-offsets.s:# -imultiarch x86_64-linux-gnu -D
__KERNEL__ -D DISALLOW_TRACE_PRINTK
kernel/bounds.s:# -imultiarch x86_64-linux-gnu -D __KERNEL__ -D
DISALLOW_TRACE_PRINTK
scripts/mod/devicetable-offsets.s:# -D DISALLOW_TRACE_PRINTK
(along with all *.cmd files)

and I suspect some/all of those force a complete kernel rebuild.

> -- Steve