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: samitolvanen@google.com, torvalds@linux-foundation.org,
	ljs@kernel.org, david.laight.linux@gmail.com, sashal@kernel.org,
	lzsx618@gmail.com, zuoan.penguin@gmail.com, petr.pavlu@suse.com,
	jani.nikula@intel.com, xur@google.com, sidnayyar@google.com,
	robertusdchris@gmail.com, acourbot@nvidia.com,
	linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Julian Braha <julianbraha@gmail.com>
Subject: [PATCH 5/5] kconfig: replace XOR with addition for expr_lookup() key generation
Date: Fri, 27 Nov 2026 00:00:15 +0000	[thread overview]
Message-ID: <20261127000015.3662267-6-julianbraha@gmail.com> (raw)
In-Reply-To: <20261127000015.3662267-1-julianbraha@gmail.com>

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@mail.gmail.com/ [1]
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Julian Braha <julianbraha@gmail.com>
---
 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


      parent reply	other threads:[~2026-11-27  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  0:00 [PATCH 0/5] kconfig: fix slow 'make oldconfig' by reverting host header simplifications Julian Braha
2026-11-27  0:00 ` [PATCH 1/5] scripts: add bit count parameter back to host hash functions Julian Braha
2026-11-27  1:16   ` Linus Torvalds
2026-11-27  1:34     ` Linus Torvalds
2026-11-27  0:00 ` [PATCH 2/5] scripts: restore support for 64-bit pointers in " Julian Braha
2026-11-27  0:00 ` [PATCH 3/5] scripts: restore host hash table macro names Julian Braha
2026-11-27  0:00 ` [PATCH 4/5] scripts: add bit count parameter back to the host hash table functions Julian Braha
2026-11-27  0:00 ` Julian Braha [this message]

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=20261127000015.3662267-6-julianbraha@gmail.com \
    --to=julianbraha@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=david.laight.linux@gmail.com \
    --cc=jani.nikula@intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=lzsx618@gmail.com \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=robertusdchris@gmail.com \
    --cc=samitolvanen@google.com \
    --cc=sashal@kernel.org \
    --cc=sidnayyar@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=xur@google.com \
    --cc=zuoan.penguin@gmail.com \
    /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®