Skip to content

kconfig: fix slow 'make oldconfig' by reverting host header simplifications

Julian Braha linux-kbuild linux-modules lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5scripts: add bit count parameter back to host hash functionsscripts/gendwarfksyms/cache.c scripts/gendwarfksyms/die.c scripts/gendwarfksyms/gendwarfksyms.h +4 more+11 -112 replies
2/5scripts: restore support for 64-bit pointers in host hash functionsscripts/include/hash.h+13 -10 replies
3/5scripts: restore host hash table macro namesscripts/gendwarfksyms/die.c scripts/gendwarfksyms/gendwarfksyms.h scripts/gendwarfksyms/kabi.c +9 more+16 -160 replies
4/5scripts: add bit count parameter back to the host hash table functionsscripts/gendwarfksyms/die.c scripts/gendwarfksyms/gendwarfksyms.h scripts/gendwarfksyms/kabi.c +9 more+34 -220 replies
5/5kconfig: replace XOR with addition for expr_lookup() key generationscripts/kconfig/expr.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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

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().

---
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(-)
Signature · 1 line
2.56.0