[PATCH 5/5] kconfig: replace XOR with addition for expr_lookup() key generation
From: Julian Braha
Date: Thu Nov 26 2026 - 19:00:48 EST
As Linus noted when reporting the 'make oldconfig' performance issue [1],
XOR of the hash_ptr() values will clear the shared bits, increasing hash
table collisions when l == r. In Kconfig, this happens when two sides of
an expression are equal, for example 'range 1 1' in fs/erofs/Kconfig.
Let's replace the XOR usage with addition, as Linus suggested.
Link: https://lore.kernel.org/all/CAHk-=wi_GuySe0L-uCAM2+nScCLYGBp5BLi6UUPR1gALmNM_3w@xxxxxxxxxxxxxx/ [1]
Suggested-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Julian Braha <julianbraha@xxxxxxxxx>
---
scripts/kconfig/expr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 8dc73acb08ad..e30554807d12 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -35,7 +35,7 @@ static struct expr *expr_lookup(enum expr_type type, void *l, void *r)
struct expr *e;
int hash;
- hash = hash_32((unsigned int)type ^ hash_ptr(l, 32) ^ hash_ptr(r, 32), 32);
+ hash = hash_32((unsigned int)type + hash_ptr(l, 32) + hash_ptr(r, 32), 32);
hash_for_each_possible(expr_hashtable, e, node, hash) {
if (e->type == type && e->left._initdata == l &&
--
2.56.0