* [PATCH] kconfig: add kconfig-sym-check static checker
@ 2026-05-13 21:03 Andrew Jones
2026-05-13 21:44 ` Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Andrew Jones @ 2026-05-13 21:03 UTC (permalink / raw)
To: linux-kbuild, linux-kernel; +Cc: nathan, nsc, andriy.shevchenko
Add 'make kconfig-sym-check', a static checker that finds Kconfig
symbols referenced in expressions (select, depends on, default, etc.)
but never defined via config/menuconfig anywhere in the tree. New
dangling symbols are reported as errors (exit 1) unless they are
listed in an exclusion file, e.g.
KCONFIG_SYM_CHECK_EXCLUDES=sym-check-excludes make kconfig-sym-check
The checker also warns about uppercase N/Y/M used as tristate literal
values following the same logic as checkpatch.
This new static checker is the script used for [1] with a few
improvements to avoid some false positives.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
Makefile | 7 ++-
scripts/kconfig/kconfig-sym-check.pl | 93 ++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 1 deletion(-)
create mode 100755 scripts/kconfig/kconfig-sym-check.pl
diff --git a/Makefile b/Makefile
index fc2d94aafb45..5a0a9f9d6169 100644
--- a/Makefile
+++ b/Makefile
@@ -293,6 +293,7 @@ version_h := include/generated/uapi/linux/version.h
clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \
+ kconfig-sym-check \
$(version_h) headers headers_% archheaders archscripts \
%asm-generic kernelversion %src-pkg dt_binding_check \
outputmakefile rustavailable rustfmt rustfmtcheck \
@@ -1806,6 +1807,7 @@ help:
@echo ' includecheck - Check for duplicate included header files'
@echo ' headerdep - Detect inclusion cycles in headers'
@echo ' coccicheck - Check with Coccinelle'
+ @echo ' kconfig-sym-check - Check for dangling Kconfig symbol references'
@echo ' clang-analyzer - Check with clang static analyzer'
@echo ' clang-tidy - Check with clang-tidy'
@echo ''
@@ -2227,7 +2229,7 @@ endif
# Scripts to check various things for consistency
# ---------------------------------------------------------------------------
-PHONY += includecheck versioncheck coccicheck
+PHONY += includecheck versioncheck coccicheck kconfig-sym-check
includecheck:
find $(srctree)/* $(RCS_FIND_IGNORE) \
@@ -2242,6 +2244,9 @@ versioncheck:
coccicheck:
$(Q)$(BASH) $(srctree)/scripts/$@
+kconfig-sym-check:
+ $(Q)cd $(srctree) && $(PERL) scripts/kconfig/kconfig-sym-check.pl $(KCONFIG_SYM_CHECK_EXCLUDES)
+
PHONY += checkstack kernelrelease kernelversion image_name
# UML needs a little special treatment here. It wants to use the host
diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
new file mode 100755
index 000000000000..a6907e585962
--- /dev/null
+++ b/scripts/kconfig/kconfig-sym-check.pl
@@ -0,0 +1,93 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+
+use warnings;
+use strict;
+
+my $kconfig_sym_check_excludes = undef;
+$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
+
+my @files = `git ls-files '*Kconfig*'`;
+my %configs = ();
+my %refs = ();
+
+foreach my $file (<@files>) {
+ open F, $file or die "Cannot open $file: $!";
+
+ my $help = 0;
+ my $help_level;
+ my $level;
+
+ while (<F>) {
+ chomp;
+
+ next if /^\s*$/;
+ next if /^\s*#/;
+
+ /^(\s*)/;
+ $level = length $1;
+
+ if ($help && $level < $help_level) {
+ $help = 0;
+ }
+
+ next if ($help);
+
+ if (/^\s*(help|\-\-\-help\-\-\-)$/) {
+ $help = 1;
+ $_ = <F>;
+ /^(\s*)/;
+ $help_level = length $1;
+ next;
+ }
+
+ if (/^\s*(config|menuconfig)\s+([a-zA-Z0-9_]+)\s*(#.*)?$/) {
+ $configs{$2}++;
+ next;
+ }
+
+ my $comment_idx = index $_, "#";
+ if ($comment_idx != -1) {
+ $_ = substr $_, 0, $comment_idx;
+ }
+
+ if (/^\s*(default|def_bool|def_tristate|select|depends\s+on|imply|visible\s+if|range|if)\s+(.+)\s*$/) {
+ my $s = $2;
+ $s =~ s/\$\(.*\)//g;
+ $s =~ s/'[^']*'//g;
+ $s =~ s/"[^"]*"//g;
+ $s =~ s/%%[^%]*%%//g;
+ my @syms = split /[^a-zA-Z0-9_]+/, $s;
+ map {
+ $refs{$_}++ if (/[a-zA-Z]/ && $_ ne "if" && $_ ne "y" && $_ ne "n" && $_ ne "m" && !(/^0[xX]/ && !/[g-wy-zG-WY-Z]/));
+ } @syms
+ }
+ }
+
+ close F;
+}
+
+my %known_syms = ();
+if (defined $kconfig_sym_check_excludes) {
+ my $file = $kconfig_sym_check_excludes;
+ open F, $file or die "Cannot open $file: $!";
+ while (<F>) {
+ chomp;
+ next if /^\s*$/;
+ next if /^\s*#/;
+ $known_syms{$1}++ if (/^\s*([a-zA-Z0-9_]+)\s*(#.*)?$/);
+ }
+}
+
+my $ret = 0;
+foreach my $k (sort keys %refs) {
+ next if (exists $configs{$k} || exists $known_syms{$k});
+
+ print "$k";
+ print " - warning: '$k' is probably not what you want; Kconfig tristate literals are always lowercase ('n', 'y', 'm')" if ($k eq "N" || $k eq "Y" || $k eq "M");
+ print "\n";
+
+ $ret = 1;
+}
+
+exit $ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-13 21:03 [PATCH] kconfig: add kconfig-sym-check static checker Andrew Jones
@ 2026-05-13 21:44 ` Andy Shevchenko
2026-05-13 23:31 ` Randy Dunlap
2026-05-14 13:32 ` Nathan Chancellor
2 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2026-05-13 21:44 UTC (permalink / raw)
To: Andrew Jones, Randy Dunlap; +Cc: linux-kbuild, linux-kernel, nathan, nsc
+Cc: Randy: FYI.
On Wed, May 13, 2026 at 04:03:29PM -0500, Andrew Jones wrote:
> Add 'make kconfig-sym-check', a static checker that finds Kconfig
> symbols referenced in expressions (select, depends on, default, etc.)
> but never defined via config/menuconfig anywhere in the tree. New
> dangling symbols are reported as errors (exit 1) unless they are
> listed in an exclusion file, e.g.
>
> KCONFIG_SYM_CHECK_EXCLUDES=sym-check-excludes make kconfig-sym-check
>
> The checker also warns about uppercase N/Y/M used as tristate literal
> values following the same logic as checkpatch.
>
> This new static checker is the script used for [1] with a few
> improvements to avoid some false positives.
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-13 21:03 [PATCH] kconfig: add kconfig-sym-check static checker Andrew Jones
2026-05-13 21:44 ` Andy Shevchenko
@ 2026-05-13 23:31 ` Randy Dunlap
2026-05-14 13:32 ` Nathan Chancellor
2 siblings, 0 replies; 13+ messages in thread
From: Randy Dunlap @ 2026-05-13 23:31 UTC (permalink / raw)
To: Andrew Jones, linux-kbuild, linux-kernel; +Cc: nathan, nsc, andriy.shevchenko
On 5/13/26 2:03 PM, Andrew Jones wrote:
> Add 'make kconfig-sym-check', a static checker that finds Kconfig
> symbols referenced in expressions (select, depends on, default, etc.)
> but never defined via config/menuconfig anywhere in the tree. New
> dangling symbols are reported as errors (exit 1) unless they are
> listed in an exclusion file, e.g.
>
> KCONFIG_SYM_CHECK_EXCLUDES=sym-check-excludes make kconfig-sym-check
>
> The checker also warns about uppercase N/Y/M used as tristate literal
> values following the same logic as checkpatch.
>
> This new static checker is the script used for [1] with a few
> improvements to avoid some false positives.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
> ---
> Makefile | 7 ++-
> scripts/kconfig/kconfig-sym-check.pl | 93 ++++++++++++++++++++++++++++
> 2 files changed, 99 insertions(+), 1 deletion(-)
> create mode 100755 scripts/kconfig/kconfig-sym-check.pl
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.
--
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-13 21:03 [PATCH] kconfig: add kconfig-sym-check static checker Andrew Jones
2026-05-13 21:44 ` Andy Shevchenko
2026-05-13 23:31 ` Randy Dunlap
@ 2026-05-14 13:32 ` Nathan Chancellor
2026-05-14 13:51 ` Andrew Jones
` (2 more replies)
2 siblings, 3 replies; 13+ messages in thread
From: Nathan Chancellor @ 2026-05-14 13:32 UTC (permalink / raw)
To: Andrew Jones; +Cc: linux-kbuild, linux-kernel, nathan, nsc, andriy.shevchenko
On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
Hi Andrew,
> [...]
>
> This new static checker is the script used for [1] with a few
> improvements to avoid some false positives.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
I think something like this is reasonable, as least until kconfirm
is potentially ready for integration into the tree.
https://lore.kernel.org/20260509203808.1142311-1-julianbraha@gmail.com/
That said, I don't know perl, so some superficial comments to follow.
>
>
> diff --git a/Makefile b/Makefile
> index e27c91ea56fc..75487383805b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2240,6 +2242,9 @@ versioncheck:
> coccicheck:
> $(Q)$(BASH) $(srctree)/scripts/$@
>
> +kconfig-sym-check:
> + $(Q)cd $(srctree) && $(PERL) scripts/kconfig/kconfig-sym-check.pl $(KCONFIG_SYM_CHECK_EXCLUDES)
I would prefer to avoid the 'cd $(srctree)' here.
>
> diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
> new file mode 100755
> index 000000000000..a6907e585962
> --- /dev/null
> +++ b/scripts/kconfig/kconfig-sym-check.pl
> @@ -0,0 +1,93 @@
> +#!/usr/bin/env perl
> +# SPDX-License-Identifier: GPL-2.0
> +
> +use warnings;
> +use strict;
> +
> +my $kconfig_sym_check_excludes = undef;
> +$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
> +
> +my @files = `git ls-files '*Kconfig*'`;
What happens if you run this command on a release tarball? We should
probably use something like
find $(srctree) -name '*Kconfig*'
here, which would avoid needing the 'cd $(srctree)' above (although
kconfig-sym-check.pl would need to be prefixed with $(srctree)/ to
ensure the path is valid).
Sashiko has some additional comments that may be relevant, if you have
not already seen them.
https://sashiko.dev/#/patchset/19870
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-14 13:32 ` Nathan Chancellor
@ 2026-05-14 13:51 ` Andrew Jones
2026-05-14 15:26 ` Julian Braha
2026-05-15 19:08 ` Nicolas Schier
2 siblings, 0 replies; 13+ messages in thread
From: Andrew Jones @ 2026-05-14 13:51 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: linux-kbuild, linux-kernel, nsc, andriy.shevchenko
On Thu, May 14, 2026 at 10:32:12PM +0900, Nathan Chancellor wrote:
> On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
>
> Hi Andrew,
>
> > [...]
> >
> > This new static checker is the script used for [1] with a few
> > improvements to avoid some false positives.
> >
> > Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
> > Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
>
> I think something like this is reasonable, as least until kconfirm
> is potentially ready for integration into the tree.
>
> https://lore.kernel.org/20260509203808.1142311-1-julianbraha@gmail.com/
>
> That said, I don't know perl, so some superficial comments to follow.
>
> >
> >
> > diff --git a/Makefile b/Makefile
> > index e27c91ea56fc..75487383805b 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -2240,6 +2242,9 @@ versioncheck:
> > coccicheck:
> > $(Q)$(BASH) $(srctree)/scripts/$@
> >
> > +kconfig-sym-check:
> > + $(Q)cd $(srctree) && $(PERL) scripts/kconfig/kconfig-sym-check.pl $(KCONFIG_SYM_CHECK_EXCLUDES)
>
> I would prefer to avoid the 'cd $(srctree)' here.
>
> >
> > diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
> > new file mode 100755
> > index 000000000000..a6907e585962
> > --- /dev/null
> > +++ b/scripts/kconfig/kconfig-sym-check.pl
> > @@ -0,0 +1,93 @@
> > +#!/usr/bin/env perl
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +use warnings;
> > +use strict;
> > +
> > +my $kconfig_sym_check_excludes = undef;
> > +$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
> > +
> > +my @files = `git ls-files '*Kconfig*'`;
>
> What happens if you run this command on a release tarball? We should
> probably use something like
>
> find $(srctree) -name '*Kconfig*'
>
> here, which would avoid needing the 'cd $(srctree)' above (although
> kconfig-sym-check.pl would need to be prefixed with $(srctree)/ to
> ensure the path is valid).
>
> Sashiko has some additional comments that may be relevant, if you have
> not already seen them.
>
> https://sashiko.dev/#/patchset/19870
Thanks, Nathan. I'll make some improvements based on your and Sashiko's
comments and send a v2.
drew
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-14 13:32 ` Nathan Chancellor
2026-05-14 13:51 ` Andrew Jones
@ 2026-05-14 15:26 ` Julian Braha
2026-05-14 16:01 ` Nathan Chancellor
2026-05-15 19:08 ` Nicolas Schier
2 siblings, 1 reply; 13+ messages in thread
From: Julian Braha @ 2026-05-14 15:26 UTC (permalink / raw)
To: Nathan Chancellor, Andrew Jones
Cc: linux-kbuild, linux-kernel, nsc, andriy.shevchenko
On 5/14/26 14:32, Nathan Chancellor wrote:
> On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
>
> Hi Andrew,
>
>> [...]
>>
>> This new static checker is the script used for [1] with a few
>> improvements to avoid some false positives.
>>
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
>> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
>
> I think something like this is reasonable, as least until kconfirm
> is potentially ready for integration into the tree.
>
> https://lore.kernel.org/20260509203808.1142311-1-julianbraha@gmail.com/
>
Agreed, don't let kconfirm block this. While I do have future plans to
support these same alarms in that tool, there's currently no overlap
between these two, and no ETA on that support either ;)
Side note, this script was actually part of my inspiration to go
searching for more misusage of kconfig and build kconfirm. I also
previously cleaned up some dead code, thanks to this script:
https://lore.kernel.org/all/20260309122321.1528622-1-julianbraha@gmail.com/
- Julian Braha
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-14 15:26 ` Julian Braha
@ 2026-05-14 16:01 ` Nathan Chancellor
0 siblings, 0 replies; 13+ messages in thread
From: Nathan Chancellor @ 2026-05-14 16:01 UTC (permalink / raw)
To: Julian Braha
Cc: Andrew Jones, linux-kbuild, linux-kernel, nsc, andriy.shevchenko
On Thu, May 14, 2026 at 04:26:42PM +0100, Julian Braha wrote:
> On 5/14/26 14:32, Nathan Chancellor wrote:
> > On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
> >
> > Hi Andrew,
> >
> >> [...]
> >>
> >> This new static checker is the script used for [1] with a few
> >> improvements to avoid some false positives.
> >>
> >> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
> >> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
> >
> > I think something like this is reasonable, as least until kconfirm
> > is potentially ready for integration into the tree.
> >
> > https://lore.kernel.org/20260509203808.1142311-1-julianbraha@gmail.com/
> >
> Agreed, don't let kconfirm block this. While I do have future plans to
> support these same alarms in that tool, there's currently no overlap
> between these two, and no ETA on that support either ;)
>
> Side note, this script was actually part of my inspiration to go
> searching for more misusage of kconfig and build kconfirm. I also
> previously cleaned up some dead code, thanks to this script:
> https://lore.kernel.org/all/20260309122321.1528622-1-julianbraha@gmail.com/
Thanks a lot for that additional context, especially around the lack of
overlap between the two tools. This seems worth pursuing then.
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-14 13:32 ` Nathan Chancellor
2026-05-14 13:51 ` Andrew Jones
2026-05-14 15:26 ` Julian Braha
@ 2026-05-15 19:08 ` Nicolas Schier
2026-05-17 4:26 ` Nathan Chancellor
2 siblings, 1 reply; 13+ messages in thread
From: Nicolas Schier @ 2026-05-15 19:08 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Andrew Jones, linux-kbuild, linux-kernel, andriy.shevchenko
On Thu, May 14, 2026 at 10:32:12PM +0900, Nathan Chancellor wrote:
> On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
[...]
> >
> > diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
> > new file mode 100755
> > index 000000000000..a6907e585962
> > --- /dev/null
> > +++ b/scripts/kconfig/kconfig-sym-check.pl
> > @@ -0,0 +1,93 @@
> > +#!/usr/bin/env perl
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +use warnings;
> > +use strict;
> > +
> > +my $kconfig_sym_check_excludes = undef;
> > +$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
> > +
> > +my @files = `git ls-files '*Kconfig*'`;
>
> What happens if you run this command on a release tarball? We should
> probably use something like
>
> find $(srctree) -name '*Kconfig*'
not fully related, but that reminds me to this thread:
https://lore.kernel.org/linux-kbuild/CAK7LNATJ-3JQ0QQGQ5R+R8aBJEq-tmBL8iBZrbM_4t0zeoYTaw@mail.gmail.com/#r
--
Nicolas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-15 19:08 ` Nicolas Schier
@ 2026-05-17 4:26 ` Nathan Chancellor
2026-05-17 6:14 ` Andy Shevchenko
0 siblings, 1 reply; 13+ messages in thread
From: Nathan Chancellor @ 2026-05-17 4:26 UTC (permalink / raw)
To: Nicolas Schier
Cc: Andrew Jones, linux-kbuild, linux-kernel, andriy.shevchenko
On Fri, May 15, 2026 at 09:08:07PM +0200, Nicolas Schier wrote:
> On Thu, May 14, 2026 at 10:32:12PM +0900, Nathan Chancellor wrote:
> > On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
> [...]
> > >
> > > diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
> > > new file mode 100755
> > > index 000000000000..a6907e585962
> > > --- /dev/null
> > > +++ b/scripts/kconfig/kconfig-sym-check.pl
> > > @@ -0,0 +1,93 @@
> > > +#!/usr/bin/env perl
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +
> > > +use warnings;
> > > +use strict;
> > > +
> > > +my $kconfig_sym_check_excludes = undef;
> > > +$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
> > > +
> > > +my @files = `git ls-files '*Kconfig*'`;
> >
> > What happens if you run this command on a release tarball? We should
> > probably use something like
> >
> > find $(srctree) -name '*Kconfig*'
>
> not fully related, but that reminds me to this thread:
> https://lore.kernel.org/linux-kbuild/CAK7LNATJ-3JQ0QQGQ5R+R8aBJEq-tmBL8iBZrbM_4t0zeoYTaw@mail.gmail.com/#r
Ah yeah, that is definitely worth keeping in mind for the future. I feel
like 'find' is not "more complicated" than 'git ls-files' in this case,
so I will assume that such an objection would not really hold here
(especially since it would help people with development of fresh Kconfig
files that have not been committed yet). If we did want to rely on 'git
ls-files', we should at least error gracefully if we are not in a git
checkout.
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-17 4:26 ` Nathan Chancellor
@ 2026-05-17 6:14 ` Andy Shevchenko
2026-05-17 9:11 ` Nathan Chancellor
0 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2026-05-17 6:14 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Andrew Jones, linux-kbuild, linux-kernel
On Sun, May 17, 2026 at 01:26:07PM +0900, Nathan Chancellor wrote:
> On Fri, May 15, 2026 at 09:08:07PM +0200, Nicolas Schier wrote:
> > On Thu, May 14, 2026 at 10:32:12PM +0900, Nathan Chancellor wrote:
> > > On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
[...]
> > > > diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
> > > > new file mode 100755
> > > > index 000000000000..a6907e585962
> > > > --- /dev/null
> > > > +++ b/scripts/kconfig/kconfig-sym-check.pl
> > > > @@ -0,0 +1,93 @@
> > > > +#!/usr/bin/env perl
> > > > +# SPDX-License-Identifier: GPL-2.0
> > > > +
> > > > +use warnings;
> > > > +use strict;
> > > > +
> > > > +my $kconfig_sym_check_excludes = undef;
> > > > +$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
> > > > +
> > > > +my @files = `git ls-files '*Kconfig*'`;
> > >
> > > What happens if you run this command on a release tarball? We should
> > > probably use something like
> > >
> > > find $(srctree) -name '*Kconfig*'
> >
> > not fully related, but that reminds me to this thread:
> > https://lore.kernel.org/linux-kbuild/CAK7LNATJ-3JQ0QQGQ5R+R8aBJEq-tmBL8iBZrbM_4t0zeoYTaw@mail.gmail.com/#r
>
> Ah yeah, that is definitely worth keeping in mind for the future. I feel
> like 'find' is not "more complicated" than 'git ls-files' in this case,
> so I will assume that such an objection would not really hold here
> (especially since it would help people with development of fresh Kconfig
> files that have not been committed yet). If we did want to rely on 'git
> ls-files', we should at least error gracefully if we are not in a git
> checkout.
Can we do both depending on the environment (if we are in Git, do that,
otherwise fallback to `find`)? `find` uses FS, while Git uses index, which
is much faster.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-17 6:14 ` Andy Shevchenko
@ 2026-05-17 9:11 ` Nathan Chancellor
2026-05-17 9:58 ` Andy Shevchenko
0 siblings, 1 reply; 13+ messages in thread
From: Nathan Chancellor @ 2026-05-17 9:11 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Nicolas Schier, Andrew Jones, linux-kbuild, linux-kernel
On Sun, May 17, 2026 at 09:14:47AM +0300, Andy Shevchenko wrote:
> On Sun, May 17, 2026 at 01:26:07PM +0900, Nathan Chancellor wrote:
> > On Fri, May 15, 2026 at 09:08:07PM +0200, Nicolas Schier wrote:
> > > On Thu, May 14, 2026 at 10:32:12PM +0900, Nathan Chancellor wrote:
> > > > On Wed, 13 May 2026 16:03:29 -0500, Andrew Jones <andrew.jones@linux.dev> wrote:
>
> [...]
>
> > > > > diff --git a/scripts/kconfig/kconfig-sym-check.pl b/scripts/kconfig/kconfig-sym-check.pl
> > > > > new file mode 100755
> > > > > index 000000000000..a6907e585962
> > > > > --- /dev/null
> > > > > +++ b/scripts/kconfig/kconfig-sym-check.pl
> > > > > @@ -0,0 +1,93 @@
> > > > > +#!/usr/bin/env perl
> > > > > +# SPDX-License-Identifier: GPL-2.0
> > > > > +
> > > > > +use warnings;
> > > > > +use strict;
> > > > > +
> > > > > +my $kconfig_sym_check_excludes = undef;
> > > > > +$kconfig_sym_check_excludes = $ARGV[0] if (defined $ARGV[0]);
> > > > > +
> > > > > +my @files = `git ls-files '*Kconfig*'`;
> > > >
> > > > What happens if you run this command on a release tarball? We should
> > > > probably use something like
> > > >
> > > > find $(srctree) -name '*Kconfig*'
> > >
> > > not fully related, but that reminds me to this thread:
> > > https://lore.kernel.org/linux-kbuild/CAK7LNATJ-3JQ0QQGQ5R+R8aBJEq-tmBL8iBZrbM_4t0zeoYTaw@mail.gmail.com/#r
> >
> > Ah yeah, that is definitely worth keeping in mind for the future. I feel
> > like 'find' is not "more complicated" than 'git ls-files' in this case,
> > so I will assume that such an objection would not really hold here
> > (especially since it would help people with development of fresh Kconfig
> > files that have not been committed yet). If we did want to rely on 'git
> > ls-files', we should at least error gracefully if we are not in a git
> > checkout.
>
> Can we do both depending on the environment (if we are in Git, do that,
> otherwise fallback to `find`)? `find` uses FS, while Git uses index, which
> is much faster.
It feels like that starts to get into the complicated territory for
little gain, considering there is indeed a performance difference but I
am not sure that it is an obvious one in the grand scheme of things.
$ hyperfine 'git ls-files "*Kconfig*"' 'find . -name "*Kconfig*"'
Benchmark 1: git ls-files "*Kconfig*"
Time (mean ± σ): 24.6 ms ± 1.0 ms [User: 18.0 ms, System: 6.1 ms]
Range (min … max): 20.5 ms … 28.7 ms 120 runs
Benchmark 2: find . -name "*Kconfig*"
Time (mean ± σ): 222.9 ms ± 4.5 ms [User: 80.6 ms, System: 140.1 ms]
Range (min … max): 216.0 ms … 227.6 ms 13 runs
Summary
git ls-files "*Kconfig*" ran
9.06 ± 0.43 times faster than find . -name "*Kconfig*"
But I don't know how complicated such checking is in Perl, so I would be
willing to see what it looks like.
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-17 9:11 ` Nathan Chancellor
@ 2026-05-17 9:58 ` Andy Shevchenko
2026-05-17 21:50 ` Nathan Chancellor
0 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2026-05-17 9:58 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Andrew Jones, linux-kbuild, linux-kernel
On Sun, May 17, 2026 at 06:11:28PM +0900, Nathan Chancellor wrote:
> On Sun, May 17, 2026 at 09:14:47AM +0300, Andy Shevchenko wrote:
> > On Sun, May 17, 2026 at 01:26:07PM +0900, Nathan Chancellor wrote:
> > > On Fri, May 15, 2026 at 09:08:07PM +0200, Nicolas Schier wrote:
[...]
> > > Ah yeah, that is definitely worth keeping in mind for the future. I feel
> > > like 'find' is not "more complicated" than 'git ls-files' in this case,
> > > so I will assume that such an objection would not really hold here
> > > (especially since it would help people with development of fresh Kconfig
> > > files that have not been committed yet). If we did want to rely on 'git
> > > ls-files', we should at least error gracefully if we are not in a git
> > > checkout.
> >
> > Can we do both depending on the environment (if we are in Git, do that,
> > otherwise fallback to `find`)? `find` uses FS, while Git uses index, which
> > is much faster.
>
> It feels like that starts to get into the complicated territory for
> little gain, considering there is indeed a performance difference
I tend to agree, but it depends on how complicated the things really are if
implementing both.
> but I
> am not sure that it is an obvious one in the grand scheme of things.
>
> $ hyperfine 'git ls-files "*Kconfig*"' 'find . -name "*Kconfig*"'
Does this makes caches cold before *each* attempt?
> Benchmark 1: git ls-files "*Kconfig*"
> Time (mean ± σ): 24.6 ms ± 1.0 ms [User: 18.0 ms, System: 6.1 ms]
> Range (min … max): 20.5 ms … 28.7 ms 120 runs
>
> Benchmark 2: find . -name "*Kconfig*"
> Time (mean ± σ): 222.9 ms ± 4.5 ms [User: 80.6 ms, System: 140.1 ms]
> Range (min … max): 216.0 ms … 227.6 ms 13 runs
>
> Summary
> git ls-files "*Kconfig*" ran
> 9.06 ± 0.43 times faster than find . -name "*Kconfig*"
>
> But I don't know how complicated such checking is in Perl, so I would be
> willing to see what it looks like.
1. Call `git ls-files`,
2. if the above fails, call `find`.
3. `find` never fails (okay... :-)
In any language it shouldn't be much code.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kconfig: add kconfig-sym-check static checker
2026-05-17 9:58 ` Andy Shevchenko
@ 2026-05-17 21:50 ` Nathan Chancellor
0 siblings, 0 replies; 13+ messages in thread
From: Nathan Chancellor @ 2026-05-17 21:50 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Nicolas Schier, Andrew Jones, linux-kbuild, linux-kernel
On Sun, May 17, 2026 at 12:58:32PM +0300, Andy Shevchenko wrote:
> On Sun, May 17, 2026 at 06:11:28PM +0900, Nathan Chancellor wrote:
> > but I
> > am not sure that it is an obvious one in the grand scheme of things.
> >
> > $ hyperfine 'git ls-files "*Kconfig*"' 'find . -name "*Kconfig*"'
>
> Does this makes caches cold before *each* attempt?
No but if I do so via the '--prepare' option, I see a similar
difference.
> > Benchmark 1: git ls-files "*Kconfig*"
> > Time (mean ± σ): 24.6 ms ± 1.0 ms [User: 18.0 ms, System: 6.1 ms]
> > Range (min … max): 20.5 ms … 28.7 ms 120 runs
> >
> > Benchmark 2: find . -name "*Kconfig*"
> > Time (mean ± σ): 222.9 ms ± 4.5 ms [User: 80.6 ms, System: 140.1 ms]
> > Range (min … max): 216.0 ms … 227.6 ms 13 runs
> >
> > Summary
> > git ls-files "*Kconfig*" ran
> > 9.06 ± 0.43 times faster than find . -name "*Kconfig*"
> >
> > But I don't know how complicated such checking is in Perl, so I would be
> > willing to see what it looks like.
>
> 1. Call `git ls-files`,
> 2. if the above fails, call `find`.
> 3. `find` never fails (okay... :-)
>
> In any language it shouldn't be much code.
Yeah, I guess I would look for '.git' before calling 'git ls-files' but
that should work as well. It's up to Andrew.
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-05-17 21:50 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 21:03 [PATCH] kconfig: add kconfig-sym-check static checker Andrew Jones
2026-05-13 21:44 ` Andy Shevchenko
2026-05-13 23:31 ` Randy Dunlap
2026-05-14 13:32 ` Nathan Chancellor
2026-05-14 13:51 ` Andrew Jones
2026-05-14 15:26 ` Julian Braha
2026-05-14 16:01 ` Nathan Chancellor
2026-05-15 19:08 ` Nicolas Schier
2026-05-17 4:26 ` Nathan Chancellor
2026-05-17 6:14 ` Andy Shevchenko
2026-05-17 9:11 ` Nathan Chancellor
2026-05-17 9:58 ` Andy Shevchenko
2026-05-17 21:50 ` Nathan Chancellor
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.