mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julian Braha <julianbraha@gmail.com>
To: nathan@kernel.org, nsc@kernel.org
Cc: ojeda@kernel.org, akpm@linux-foundation.org,
	jani.nikula@linux.intel.com, gary@garyguo.net,
	gregkh@linuxfoundation.org, arnd@arndb.de, ljs@kernel.org,
	andrew.jones@linux.dev, masahiroy@kernel.org, corbet@lwn.net,
	qingfang.deng@linux.dev, demiobenour@gmail.com, ej@inai.de,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: Re: [PATCH v4 0/5] add kconfirm
Date: Fri, 4 Sep 2026 13:29:16 +0100	[thread overview]
Message-ID: <51ade68e-7a0c-454e-a48a-4c72f7a730ac@gmail.com> (raw)
In-Reply-To: <20260727001623.2794156-1-julianbraha@gmail.com>

On 7/27/26 01:16, Julian Braha wrote:
> kconfirm now uses the in-tree parser. Making this migration required a
> modification to the parser that allows us to observe the parse tree before
> its final simplification step, thus allowing us to detect dead code.
> 
> Since no external crates are now necessary, I’ve removed the Cargo requirement,
> too.
> 
> I believe these changes should resolve the major questions, so I’ve
> removed the RFC tag.
> 
> Now, onto the existing patch-set description since the RFCs:
> 
> ===
> 
> kconfirm is a tool to detect misusage of Kconfig. It detects dead code,
> constant conditions, and invalid (reverse) ranges. There are also optional
> checks to detect config options that select visible config options, and to
> check for dead links in the help texts.
> 
> See also kconfirm's original introduction to the mailing list:
> https://lore.kernel.org/all/6ec4df6d-1445-48ca-8f54-1d1a83c4716d@gmail.com/
> 
> False Alarms:
> kconfirm aims for zero false-positives, though this is not completely
> feasible due to macro evaluation from the host environment, primarily
> affecting host compiler-related options. There will also be some false
> positives for dead link checks, as this depends on an internet connection,
> and we do not attempt to bypass bot blocks. For this reason, dead link
> checking is disabled by default, but I've provided an example below of how
> to enable it. Additionally, you can view my previous message to the
> mailing list with hand-verified dead links here:
> https://lore.kernel.org/all/6732bf08-41ee-40c4-83b2-4ae8bc0da7cf@gmail.com/
> 
> Additionally, there is an optional check to detect config options that
> select visible config options, as requested by Jani during the review of
> the first RFC:
> https://lore.kernel.org/all/dcb7439832f0bb35598fba653d922b5f6a4d0058@intel.com/
> 
> Even after deduplicating across architectures, there are well over 1,000
> instances of these select-visible cases, and I suspect that, despite the
> Kconfig documentation saying select-visible should be avoided, some
> exceptions will be made. So, I have left this check disabled by default,
> keeping in line with the goal of having a low-noise checker. If interested
> in using it, I have included an example below of how to enable this check.
> 
> Current State of Alarms:
> With x86-64 on Linux v7.2-rc4 (which this RFC is based), there are 1282
> alarms coming from the default set of checks, and an additional 976 alarms
> if enabling the optional select-visible check. The last time I checked
> linux-next (next-20260427), there were 81 unique dead links.
> 
> The most critical check is the dead default statements, which has surfaced
> a few misconfiguration bugs (fortunately, just for kunit tests), see
> examples:
> https://lore.kernel.org/all/20260323124118.1414913-1-julianbraha@gmail.com/
> and:
> https://lore.kernel.org/all/20260323123536.1413732-1-julianbraha@gmail.com/
> 
> But hopefully kconfirm can ease maintenance and we can prevent more of
> these from making it into the tree in the future.
> 
> Use it:
> You can test out kconfirm with this patch series by compiling and running
> kconfirm like this:
> 
> `make kconfirm`
> 
> To enable the select-visible check:
> `KCONFIRM_ARGS="--enable-check select_visible" make kconfirm`
> 
> And to enable dead link checks in the help texts:
> `KCONFIRM_ARGS="--enable-check dead_link" make kconfirm`
> 
> kconfirm by default runs on the same architecture as the kernel build
> would. To run kconfirm on another architecture (for example, ARM with an
> X86 host):
> `ARCH=arm make kconfirm`
> 
> Thanks,
> Julian Braha
> ---
> Changes since RFC v3:
> - Modify kconfig parser to make raw parse tree viewable to enable analysis
> - Switch from external parser to in-tree kconfig parser (Demi)
> - Add Rust bindings for kconfig
> - Remove Cargo and external crates
> - Make curl an optional dependency for optional dead link check (Arnd)
> - Switch from libcurl to curl CLI for dead link checks (Miguel)
> - Adhere to Rust-for-Linux style (Miguel)
> - Add tests (Miguel)
> - Move kconfirm under scripts/kconfig/ to resolve broken tab autocompletion (Nathan)
> - Remove ungrouped attributes style check
> - Add support for checking liveness of ftp and git URIs in help texts
> - Dropped RFC tag
> 
> Link to RFC v3:
> https://lore.kernel.org/all/20260516215354.449807-1-julianbraha@gmail.com/
> 
> Changes since RFC v2:
> - Reduce Rust dependencies significantly (follows Demi's suggestions):
>   - from 6 direct dependencies to 1
>   - from 107 indirect dependencies to 4
>   - Replace ureq crate with usage of system libcurl (thanks Demi)
>   - Replace clap crate with FFI bindings to libc's getopt_long (also Demi)
>   - Remove crates env_logger, regex
> - Switch from vendoring dependencies to requiring users to first download
>   outside of Make (as suggested by Miguel)
> - Various makefile improvements (as pointed out by Nicolas):
>   - Fix out-of-tree builds
>   - Only delete kconfirm artifacts with 'distclean' and 'mrproper'
> - Add myself as maintainer of kconfirm (as discussed with Nicolas)
> - Remove dedicated code license file (pointed out by Jani)
> - Update documentation to explain tool setup
> - Add hint to users to check documentation and download tool dependencies
> - Address sashiko's many code-level and documentation suggestions:
>   - Follow the kernel's rust import style
>   - Fix a dead_range/duplicate_range alarm mixup
>   - Fix potential duplicates in default value style check
>   - Avoid panicking on errors
>   - Clarify parse failure check usage in documentation 
>   - Fix typo in documentation
> - Can now enable architectures and disable the default (host) architecture in the CLI
> 
> Link to RFC v2:
> https://lore.kernel.org/all/20260509203808.1142311-1-julianbraha@gmail.com/
> 
> Changes since RFC v1:
> - vendored dependencies instead of requiring an internet connection
> - removed Cargo.lock
> - replaced reqwest dependency with smaller ureq
> - removed rustls, expect user to have openssl instead
> - added select-visible check based on Jani's feature request
> - added invalid (reverse) range check
> - deduplicating alarms that appear for multiple architectures
> - `make clean` no longer deletes kconfirm's build artifacts
> - typo fixes in documentation
> - added patch description for the main "add kconfirm" patch (patch 1/2)
> 
> Link to RFC v1:
> https://lore.kernel.org/all/20260427174429.779474-1-julianbraha@gmail.com/
> ---
> 
> Julian Braha (5):
>   kconfig: add add another callback to the parser to view raw parse tree
>   kconfig: add kconfirm
>   kconfirm: add tests
>   Documentation: add kconfirm
>   MAINTAINERS: add entry for kconfirm
> 
>  Documentation/dev-tools/index.rst             |   1 +
>  Documentation/dev-tools/kconfirm.rst          | 229 ++++++
>  MAINTAINERS                                   |   7 +
>  Makefile                                      |  17 +-
>  scripts/kconfig/.gitignore                    |   1 +
>  scripts/kconfig/Makefile                      |  54 ++
>  scripts/kconfig/kconfig.rs                    | 445 +++++++++++
>  scripts/kconfig/kconfirm/.gitignore           |   2 +
>  scripts/kconfig/kconfirm/analyze.rs           | 340 ++++++++
>  scripts/kconfig/kconfirm/arch.rs              |  53 ++
>  scripts/kconfig/kconfirm/checks.rs            | 748 ++++++++++++++++++
>  scripts/kconfig/kconfirm/dead_links.rs        | 230 ++++++
>  scripts/kconfig/kconfirm/kconfirm-cfg.sh      |  57 ++
>  scripts/kconfig/kconfirm/kconfirm.rs          | 278 +++++++
>  scripts/kconfig/kconfirm/output.rs            |  87 ++
>  scripts/kconfig/kconfirm/symbol_table.rs      | 105 +++
>  .../kconfig/kconfirm/tests/arch/arm/Kconfig   |   9 +
>  .../kconfirm/tests/arch/powerpc/Kconfig       |   4 +
>  .../kconfig/kconfirm/tests/arch/riscv/Kconfig |   9 +
>  .../kconfig/kconfirm/tests/arch/sh/Kconfig    |   4 +
>  .../kconfirm/tests/arch/testarch/Kconfig      |   4 +
>  .../kconfig/kconfirm/tests/arch/um/Kconfig    |   4 +
>  .../kconfig/kconfirm/tests/arch/x86/Kconfig   |   4 +
>  .../kconfirm/tests/architecture.Kconfig       |   4 +
>  .../tests/architecture_common.Kconfig         |  19 +
>  .../kconfirm/tests/conditional_prompt.Kconfig |  17 +
>  scripts/kconfig/kconfirm/tests/conftest.py    |  93 +++
>  ...nt_condition_negative_expression_1.Kconfig |  13 +
>  ...nt_condition_negative_expression_2.Kconfig |  13 +
>  ...nstant_condition_negative_symbol_1.Kconfig |  13 +
>  ...nstant_condition_negative_symbol_2.Kconfig |  13 +
>  .../kconfig/kconfirm/tests/dead_link.Kconfig  |  12 +
>  .../tests/default_categorization.Kconfig      |  20 +
>  scripts/kconfig/kconfirm/tests/pytest.ini     |   2 +
>  scripts/kconfig/kconfirm/tests/ranges.Kconfig |  39 +
>  .../kconfirm/tests/select_imply.Kconfig       |  28 +
>  .../kconfig/kconfirm/tests/test_kconfirm.py   | 358 +++++++++
>  scripts/kconfig/lkc_proto.h                   |   2 +
>  scripts/kconfig/parser.y                      |  21 +
>  39 files changed, 3357 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/dev-tools/kconfirm.rst
>  create mode 100644 scripts/kconfig/kconfig.rs
>  create mode 100644 scripts/kconfig/kconfirm/.gitignore
>  create mode 100644 scripts/kconfig/kconfirm/analyze.rs
>  create mode 100644 scripts/kconfig/kconfirm/arch.rs
>  create mode 100644 scripts/kconfig/kconfirm/checks.rs
>  create mode 100644 scripts/kconfig/kconfirm/dead_links.rs
>  create mode 100755 scripts/kconfig/kconfirm/kconfirm-cfg.sh
>  create mode 100644 scripts/kconfig/kconfirm/kconfirm.rs
>  create mode 100644 scripts/kconfig/kconfirm/output.rs
>  create mode 100644 scripts/kconfig/kconfirm/symbol_table.rs
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/arm/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/powerpc/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/riscv/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/sh/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/testarch/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/um/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/arch/x86/Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/architecture.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/architecture_common.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/conditional_prompt.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/conftest.py
>  create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_expression_1.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_expression_2.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_symbol_1.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_symbol_2.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/dead_link.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/default_categorization.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/pytest.ini
>  create mode 100644 scripts/kconfig/kconfirm/tests/ranges.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/select_imply.Kconfig
>  create mode 100644 scripts/kconfig/kconfirm/tests/test_kconfirm.py
> 

As I've been getting more comfortable with the in-tree Kconfig
interpreter, I've been wondering if the community might prefer the
gradual integration of lints directly into Kconfig, instead of as a
standalone tool. Similar to a comment by Jani on another patch [1].

Otherwise, I can do a round of self-review and send a v5 for this
series. I already noticed some dumb typos in the subject lines, but any
other feedback on v4 would be welcome if kconfirm is the preferred
route :)

Link:
https://lore.kernel.org/all/f362ddf2e0f3ecf41ed81f03f77577473c3e21bc@intel.com/
[1]

- Julian Braha


  parent reply	other threads:[~2026-09-04 12:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27  0:16 Julian Braha
2026-07-27  0:16 ` [PATCH v4 1/5] kconfig: add add another callback to the parser to view raw parse tree Julian Braha
2026-07-27  0:16 ` [PATCH 2/5] kconfig: add kconfirm Julian Braha
2026-07-27  0:16 ` [PATCH v4 3/5] kconfirm: add tests Julian Braha
2026-07-27  0:16 ` [PATCH v4 4/5] Documentation: add kconfirm Julian Braha
2026-07-27  0:16 ` [PATCH v4 5/5] MAINTAINERS: add entry for kconfirm Julian Braha
2026-09-04 12:29 ` Julian Braha [this message]
2026-09-04 18:37   ` [PATCH v4 0/5] add kconfirm Nicolas Schier
2026-09-04 22:05   ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51ade68e-7a0c-454e-a48a-4c72f7a730ac@gmail.com \
    --to=julianbraha@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrew.jones@linux.dev \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=demiobenour@gmail.com \
    --cc=ej@inai.de \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=qingfang.deng@linux.dev \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®