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 2/5] scripts: restore support for 64-bit pointers in host hash functions
Date: Fri, 27 Nov 2026 00:00:12 +0000 [thread overview]
Message-ID: <20261127000015.3662267-3-julianbraha@gmail.com> (raw)
In-Reply-To: <20261127000015.3662267-1-julianbraha@gmail.com>
This partially reverts commit f93d6bfbd2f7 ("kconfig: use hash table to
reuse expressions").
When the kernel's hash headers were copied over for host usage, hash_ptr()
was also simplified to remove the bit count parameter, with only the "fast
32bit" path in use.
With the bit count parameter restored, let's restore support for passing a
64-bit pointer to hash_ptr(), rather than truncating to 32 bits.
Like other headers in tools/, use __SIZEOF_LONG__ to check the host word
size, as opposed to the in-kernel BITS_PER_LONG.
Signed-off-by: Julian Braha <julianbraha@gmail.com>
---
scripts/include/hash.h | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/scripts/include/hash.h b/scripts/include/hash.h
index ae0d3fc8d470..08e901b8a43d 100644
--- a/scripts/include/hash.h
+++ b/scripts/include/hash.h
@@ -12,17 +12,29 @@ static inline unsigned int hash_str(const char *s)
return hash;
}
+#if __SIZEOF_LONG__ == 4
+#define hash_long(val, bits) hash_32(val, bits)
+#else
+#define hash_long(val, bits) hash_64(val, bits)
+#endif
+
/* simplified version of functions from include/linux/hash.h */
#define GOLDEN_RATIO_32 0x61C88647
+#define GOLDEN_RATIO_64 0x61C8864680B583EBull
static inline unsigned int hash_32(unsigned int val, unsigned int bits)
{
return bits ? (val * GOLDEN_RATIO_32) >> (32 - bits) : 0;
}
+static inline unsigned int hash_64(unsigned long long val, unsigned int bits)
+{
+ return bits ? (val * GOLDEN_RATIO_64) >> (64 - bits) : 0;
+}
+
static inline unsigned int hash_ptr(const void *ptr, unsigned int bits)
{
- return hash_32((unsigned int)(unsigned long)ptr, bits);
+ return hash_long((unsigned long)ptr, bits);
}
#endif /* HASH_H */
--
2.56.0
next prev 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 ` Julian Braha [this message]
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 ` [PATCH 5/5] kconfig: replace XOR with addition for expr_lookup() key generation Julian Braha
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-3-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