[PATCH 0/5] kconfig: fix slow 'make oldconfig' by reverting host header simplifications

From: Julian Braha

Date: Thu Nov 26 2026 - 19:00:33 EST


As Linus noted when reporting the 'make oldconfig' performance issue [1],
when the kernel's internal hash table implementation was copied over for
Kconfig to use, it also improperly simplified these headers.

By passing '(key) % HASH_SIZE(table)' to hash_head(), this caused a poor
hash table distribution due to using the clear lower bits with power-2
hash table size, leading to a slowdown in Kconfig's expr_lookup() which
makes heavy use of this.

To resolve the performance issue, let's revert the simplifications such
that the signatures of the host functions match the original and takes
the number of bits. Also, replace XOR in Kconfig's expr_lookup() as
suggested by Linus.

Patches 1-3 are pure refactors, restoring code from the original
hash.h and hashtable.h; 4 and 5 resolve the performance issue directly:

Patch 1/5 reverts the removal of the bit count parameter from hash_32()
and hash_ptr() in scripts/include/hash.h (needed by hashtable.h in 3/5).

Patch 2/5 reverts the removal of the 64-bit path from hash_ptr(), so that
potential future callers can safely pass higher bit counts.

Patch 3/5 restores the original names of DEFINE_HASHTABLE() and
DECLARE_HASHTABLE() from the in-kernel implementation.

Patch 4/5 reverts the removal of the bit count parameter from
DECLARE_HASHTABLE and DEFINE_HASHTABLE in scripts/include/hashtable.h.

Patch 5/5 replaces XOR with addition in expr_lookup().

Link: https://lore.kernel.org/all/CAHk-=wi_GuySe0L-uCAM2+nScCLYGBp5BLi6UUPR1gALmNM_3w@xxxxxxxxxxxxxx/ [1]
---
Julian Braha (5):
scripts: add bit count parameter back to host hash functions
scripts: restore full 64-bit support in the host hash functions
scripts: restore host hash table macro names
scripts: add bit count parameter back to the host hash table functions
kconfig: replace XOR with addition for expr_lookup() key generation

scripts/gendwarfksyms/cache.c | 4 ++--
scripts/gendwarfksyms/die.c | 4 ++--
scripts/gendwarfksyms/gendwarfksyms.h | 4 ++--
scripts/gendwarfksyms/kabi.c | 4 ++--
scripts/gendwarfksyms/symbols.c | 6 +++---
scripts/gendwarfksyms/types.c | 2 +-
scripts/genksyms/genksyms.c | 4 ++--
scripts/include/hash.h | 20 ++++++++++++++++----
scripts/include/hashtable.h | 24 ++++++++++++++++++------
scripts/kconfig/expr.c | 4 ++--
scripts/kconfig/internal.h | 8 ++++----
scripts/kconfig/symbol.c | 2 +-
scripts/kconfig/util.c | 2 +-
scripts/mod/modpost.c | 2 +-
14 files changed, 57 insertions(+), 33 deletions(-)

--
2.56.0