Re: [PATCH 2/2] kconfig: do not write .config if the content is the same

From: Geert Uytterhoeven
Date: Fri May 10 2019 - 02:48:06 EST

Hi Yamada-san,

On Fri, May 10, 2019 at 8:14 AM Masahiro Yamada
<yamada.masahiro@xxxxxxxxxxxxx> wrote:
> Kconfig updates the .config when it exits even if its content is
> exactly the same as before. Since its timestamp becomes newer than
> that of other build artifacts, additional processing is invoked,
> which is annoying.
> - syncconfig is invoked to update include/config/auto.conf, etc.
> - kernel/config.o is recompiled if CONFIG_IKCONFIG is enabled,
> then vmlinux is relinked as well.
> If the .config is not changed at all, we do not have to even
> touch it. Just bail out showing "No change to .config".
> $ make allmodconfig
> scripts/kconfig/conf --allmodconfig Kconfig
> #
> # configuration written to .config
> #
> $ make allmodconfig
> scripts/kconfig/conf --allmodconfig Kconfig
> #
> # No change to .config
> #
> Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>

Thanks for your patch!

> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c

> @@ -888,6 +935,13 @@ int conf_write(const char *name)
> fclose(out);
> if (*tmpname) {
> + if (is_same(name, tmpname)) {
> + conf_message("No change to %s", name);
> + unlink(tmpname);
> + sym_set_change_count(0);
> + return 0;
> + }
> +
> snprintf(oldname, sizeof(oldname), "%s.old", name);
> rename(name, oldname);
> if (rename(tmpname, name))

This causes a semantic change for the meaning of ".config.old", which is
no longer updated if .config has not changed.
Hence its contents may no longer correspond to the previous config, but to
an arbitrary older version.

My workflow involves always running my own script "linux-oldconfig",
instead of "make oldconfig", so I immediately see what has changed:

$ cat $(type -p linux-oldconfig)
make ${0#*/linux-} && colordiff -u .config{.old,}

However, after your patch, "linux-oldconfig" keeps on showing the old
changes, while .config itself has not changed. I guess other people
tracking .config changes are using a similar scheme.

One way to fix this is to rename tmpname to oldname if is_same() returns
true. However, this may have side effects for other people, as the
timestamp of .config.old will be changed.

Do you have a better solution?



Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds