Re: [PATCH 1/3] printk: use CONFIG_CONSOLE_LOGLEVEL_* directly

Greg Kroah-Hartman
2021-02-02T10:13:58Z

On Tue, Feb 02, 2021 at 04:02:16PM +0900, Masahiro Yamada wrote:
> CONSOLE_LOGLEVEL_DEFAULT is nothing more than a shorthand of
> CONFIG_CONSOLE_LOGLEVEL_DEFAULT.
>
> When you change CONFIG_CONSOLE_LOGLEVEL_DEFAULT from Kconfig, almost
> all objects are rebuilt because CONFIG_CONSOLE_LOGLEVEL_DEFAULT is
> used in <linux/printk.h>, which is included from most of source files.
>
> In fact, there are only 4 users of CONSOLE_LOGLEVEL_DEFAULT:
>
> arch/x86/platform/uv/uv_nmi.c
> drivers/firmware/efi/libstub/efi-stub-helper.c
> drivers/tty/sysrq.c
> kernel/printk/printk.c
>
> So, when you change CONFIG_CONSOLE_LOGLEVEL_DEFAULT and rebuild the
> kernel, it is enough to recompile those 4 files.
>
> Remove the CONSOLE_LOGLEVEL_DEFAULT definition from <linux/printk.h>,
> and use CONFIG_CONSOLE_LOGLEVEL_DEFAULT directly.
>
> With this, the build system will rebuild the minimal number of objects.
>
> Steps to confirm it:
>
> [1] Do the full build
> [2] Change CONFIG_CONSOLE_LOGLEVEL_DEFAULT from 'make menuconfig' etc.
> [3] Rebuild
>
> $ make
> SYNC include/config/auto.conf
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> CHK include/generated/compile.h
> CC kernel/printk/printk.o
> AR kernel/printk/built-in.a
> AR kernel/built-in.a
> CC drivers/tty/sysrq.o
> AR drivers/tty/built-in.a
> CC drivers/firmware/efi/libstub/efi-stub-helper.o
> STUBCPY drivers/firmware/efi/libstub/efi-stub-helper.stub.o
> AR drivers/firmware/efi/libstub/lib.a
> AR drivers/built-in.a
> GEN .version
> CHK include/generated/compile.h
> UPD include/generated/compile.h
> CC init/version.o
> AR init/built-in.a
> LD vmlinux.o
> ...
>
> For the same reason, do likewise for CONSOLE_LOGLEVEL_QUIET and
> MESSAGE_LOGLEVEL_DEFAULT.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> arch/x86/platform/uv/uv_nmi.c | 2 +-
> drivers/firmware/efi/libstub/efi-stub-helper.c | 6 +++---
> drivers/tty/sysrq.c | 4 ++--
> drivers/video/fbdev/core/fbcon.c | 2 +-
> drivers/video/fbdev/efifb.c | 2 +-
> include/linux/printk.h | 10 ----------
> init/main.c | 2 +-
> kernel/printk/printk.c | 6 +++---
> 8 files changed, 12 insertions(+), 22 deletions(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>