Skip to contentSkip to conversation

diffconfig: add verification mode

PATCH In review Thomas Weißschuh 3 participants 9 messages Jan 8, 2025 – Feb 10, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

cover diffconfig: add verification mode

Also add MAINTAINERS for some kconfig utility scripts.

---
Thomas Weißschuh (2):
MAINTAINERS: Add kconfig utility scripts
diffconfig: add verification mode

 MAINTAINERS        |  3 +++
 scripts/diffconfig | 23 ++++++++++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

---
base-commit: fbfd64d25c7af3b8695201ebc85efe90be28c5a3
change-id: 20250108-diffconfig-validate-23b57b985e14

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#1 lore raw

PATCH 1/2 MAINTAINERS: Add kconfig utility scripts

There are various utilities in scripts/ which work with kconfig files. These have currently no maintainer.
As most patches for them are applied through kconfig/kbuild anyways, add an explicit maintainership entry.

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
index 30cbc3d44cd53e6b1a81d56161004d7ab825d7a9..2bd414fb3e6d6515b57a57a5f3d4d735137edcce 100644
@@ -12385,6 +12385,9 @@ Q:	https://patchwork.kernel.org/project/linux-kbuild/list/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
 F:	Documentation/kbuild/kconfig*
 F:	scripts/Kconfig.include
+F:	scripts/checkkconfigsymbols.py
+F:	scripts/config
+F:	scripts/diffconfig
 F:	scripts/kconfig/
 
 KCOV
Signature · 1 line
2.47.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] MAINTAINERS: Add kconfig utility scripts

Quoted 16 lines · Thomas Weißschuh

There are various utilities in scripts/ which work with kconfig files.
These have currently no maintainer.
As most patches for them are applied through kconfig/kbuild anyways, add an explicit maintainership entry.

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +0 -0
index 30cbc3d44cd53e6b1a81d56161004d7ab825d7a9..2bd414fb3e6d6515b57a57a5f3d4d735137edcce 100644

MAINTAINERS Q: https://patchwork.kernel.org/project/linux-kbuild/list/ · line 12390

Quoted 6 lines
MAINTAINERS +3 -0
@@ -12385,6 +12385,9 @@ Q:	https://patchwork.kernel.org/project/linux-kbuild/list/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
 F:	Documentation/kbuild/kconfig*
 F:	scripts/Kconfig.include
+F:	scripts/checkkconfigsymbols.py
+F:	scripts/config
+F:	scripts/diffconfig

Thanks!

Does it make sense to add scripts/extract-ikconfig also? It does not handle kconfig language at all, but linux-kbuild would probably still a good place for review.

Nevertheless,

Kind regards,
Nicolas

#3 lore raw

Re: [PATCH 1/2] MAINTAINERS: Add kconfig utility scripts

Quoted 26 lines · Nicolas Schier
Quoted 16 lines · Thomas Weißschuh

There are various utilities in scripts/ which work with kconfig files.
These have currently no maintainer.
As most patches for them are applied through kconfig/kbuild anyways, add an explicit maintainership entry.

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +0 -0
index 30cbc3d44cd53e6b1a81d56161004d7ab825d7a9..2bd414fb3e6d6515b57a57a5f3d4d735137edcce 100644

MAINTAINERS Q: https://patchwork.kernel.org/project/linux-kbuild/list/ · line 12390

Quoted 6 lines
MAINTAINERS +3 -0
@@ -12385,6 +12385,9 @@ Q:	https://patchwork.kernel.org/project/linux-kbuild/list/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
 F:	Documentation/kbuild/kconfig*
 F:	scripts/Kconfig.include
+F:	scripts/checkkconfigsymbols.py
+F:	scripts/config
+F:	scripts/diffconfig

Thanks!

Quoted 3 lines

Does it make sense to add scripts/extract-ikconfig also? It does not handle kconfig language at all, but linux-kbuild would probably still a good place for review.

scripts/extract-ikconfig should be maintained together with kernel/configs.c. Today both are formally unmaintained. linux-kbuild picking up both looks reasonable to me.

Quoted 3 lines

Nevertheless,

Thanks!

#4 lore raw

Re: [PATCH 1/2] MAINTAINERS: Add kconfig utility scripts

In reply to Thomas Weißschuh
Quoted 16 lines · Thomas Weißschuh

There are various utilities in scripts/ which work with kconfig files. These have currently no maintainer.
As most patches for them are applied through kconfig/kbuild anyways, add an explicit maintainership entry.

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +0 -0
index 30cbc3d44cd53e6b1a81d56161004d7ab825d7a9..2bd414fb3e6d6515b57a57a5f3d4d735137edcce 100644

MAINTAINERS Q: https://patchwork.kernel.org/project/linux-kbuild/list/ · line 12391

Quoted 7 lines
MAINTAINERS +3 -0
@@ -12385,6 +12385,9 @@ Q:      https://patchwork.kernel.org/project/linux-kbuild/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
 F:     Documentation/kbuild/kconfig*
 F:     scripts/Kconfig.include
+F:     scripts/checkkconfigsymbols.py
+F:     scripts/config
+F:     scripts/diffconfig
 F:     scripts/kconfig/

There are a number of random scripts I am unfamiliar with.

I have never used checkkconfigsymbols.py

I may happen to check patches for such tools very reluctantly and very lazily, but it is daunting to endlessly extend my obligations, especially to the point where I lost interest.

--
Best Regards
Masahiro Yamada

#5 lore raw

Re: [PATCH 1/2] MAINTAINERS: Add kconfig utility scripts

Quoted 29 lines · Masahiro Yamada
Quoted 16 lines · Thomas Weißschuh

There are various utilities in scripts/ which work with kconfig files. These have currently no maintainer.
As most patches for them are applied through kconfig/kbuild anyways, add an explicit maintainership entry.

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +0 -0
index 30cbc3d44cd53e6b1a81d56161004d7ab825d7a9..2bd414fb3e6d6515b57a57a5f3d4d735137edcce 100644

MAINTAINERS Q: https://patchwork.kernel.org/project/linux-kbuild/list/ · line 12391

Quoted 7 lines
MAINTAINERS +3 -0
@@ -12385,6 +12385,9 @@ Q:      https://patchwork.kernel.org/project/linux-kbuild/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
 F:     Documentation/kbuild/kconfig*
 F:     scripts/Kconfig.include
+F:     scripts/checkkconfigsymbols.py
+F:     scripts/config
+F:     scripts/diffconfig
 F:     scripts/kconfig/

There are a number of random scripts I am unfamiliar with.

Quoted 5 lines

I have never used checkkconfigsymbols.py

I may happen to check patches for such tools very reluctantly and very lazily, but it is daunting to endlessly extend my obligations, especially to the point where I lost interest.

Understood.
My intention is not to extend your obligations beyond your interest.

However I am not entirely sure from your message if this holds for all three of the added scripts or only checkkconfigsymbols.py. Until further notice I'll assume it affects all of them and the whole patch should be dropped.

Thomas

#6 lore raw

PATCH 2/2 diffconfig: add verification mode

In reply to Thomas Weißschuh

When creating kconfig files from defconfig files or snippets some items from the reference config may be silently omitted when dependency constraints are not met.
Manual validation is necessary to make sure that the expected items are present in the new configuration. As the constraints can change over time, this validation has to be repeated.
Extend the diffconfig script with a validation mode that can be used to perform those validation easily and in an automated manner.

---
 scripts/diffconfig | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
scripts/diffconfig +18 -5
index 43f0f3d273ae7178086f03038780ba103fd9970b..95cb0282f6db2873ef32804d361ef6db8a7bc8ce 100755
@@ -24,6 +24,10 @@ Changed items show the old and new values on a single line.
 If -m is specified, then output will be in "merge" style, which has the
 changed and new values in kernel config option format.
 
+If -v is specified, then diffconfig will validate that config2 is a superset of
+of config1. Only items from config1 not in config2 are printed.
+If items are missing from config2 diffconfig will exit with code 2.
+
 If no config files are specified, .config and .config.old are used.
 
 Example usage:
@@ -77,6 +81,11 @@ def show_diff():
         merge_style = 1
         sys.argv.remove("-m")
 
+    validate = 0
+    if "-v" in sys.argv:
+        validate = 1
+        sys.argv.remove("-v")
+
     argc = len(sys.argv)
     if not (argc==1 or argc == 3):
         print("Error: incorrect number of arguments or unrecognized option")
@@ -123,11 +132,15 @@ def show_diff():
         print_config("->", config, a[config], b[config])
         del b[config]
 
-    # now print items in b but not in a
-    # (items from b that were in a were removed above)
-    new = sorted(b.keys())
-    for config in new:
-        print_config("+", config, None, b[config])
+    if not validate:
+        # now print items in b but not in a
+        # (items from b that were in a were removed above)
+        new = sorted(b.keys())
+        for config in new:
+            print_config("+", config, None, b[config])
+
+    if validate and (old or changed):
+        sys.exit(2)
 
 def main():
     try:
Signature · 1 line
2.47.1
Reviewed-by on v1 2/2
#7 lore raw
Quoted 42 lines · Thomas Weißschuh

When creating kconfig files from defconfig files or snippets some items from the reference config may be silently omitted when dependency constraints are not met.
Manual validation is necessary to make sure that the expected items are present in the new configuration. As the constraints can change over time, this validation has to be repeated.
Extend the diffconfig script with a validation mode that can be used to perform those validation easily and in an automated manner.

---
 scripts/diffconfig | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
scripts/diffconfig +9 -0
index 43f0f3d273ae7178086f03038780ba103fd9970b..95cb0282f6db2873ef32804d361ef6db8a7bc8ce 100755
@@ -24,6 +24,10 @@ Changed items show the old and new values on a single line.
 If -m is specified, then output will be in "merge" style, which has the
 changed and new values in kernel config option format.
 
+If -v is specified, then diffconfig will validate that config2 is a superset of
+of config1. Only items from config1 not in config2 are printed.
+If items are missing from config2 diffconfig will exit with code 2.
+
 If no config files are specified, .config and .config.old are used.
 
 Example usage:
@@ -77,6 +81,11 @@ def show_diff():
         merge_style = 1
         sys.argv.remove("-m")
 
+    validate = 0
+    if "-v" in sys.argv:
+        validate = 1
+        sys.argv.remove("-v")
+
     argc = len(sys.argv)
     if not (argc==1 or argc == 3):
         print("Error: incorrect number of arguments or unrecognized option")

scripts/diffconfig def show_diff(): · line 133

Quoted 2 lines
scripts/diffconfig +0 -0
@@ -123,11 +132,15 @@ def show_diff():
         print_config("->", config, a[config], b[config])
         del b[config]

I think I'd move the early-exit for validate=1 here, and would leave the rest as is. But this is only personal preference.

Thanks for the nice idea!

Kind regards,
Nicolas

Quoted 24 lines
scripts/diffconfig +9 -5
-    # now print items in b but not in a
-    # (items from b that were in a were removed above)
-    new = sorted(b.keys())
-    for config in new:
-        print_config("+", config, None, b[config])
+    if not validate:
+        # now print items in b but not in a
+        # (items from b that were in a were removed above)
+        new = sorted(b.keys())
+        for config in new:
+            print_config("+", config, None, b[config])
+
+    if validate and (old or changed):
+        sys.exit(2)
 
 
 def main():
     try:
Signature · 2 lines
-- 
2.47.1
Signature · 5 lines
Nicolas Schier
 
epost|xmpp: [email protected]          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --
#8 lore raw
In reply to Thomas Weißschuh
Quoted 9 lines · Thomas Weißschuh

When creating kconfig files from defconfig files or snippets some items from the reference config may be silently omitted when dependency constraints are not met.
Manual validation is necessary to make sure that the expected items are present in the new configuration. As the constraints can change over time, this validation has to be repeated.
Extend the diffconfig script with a validation mode that can be used to perform those validation easily and in an automated manner.

This is a niche solution and is not worthwhile for upstream inclusion.

--
Best Regards

Masahiro Yamada