From: Timofey Titovets <nefelim4ag@gmail.com> To: linux-mm@kvack.org Cc: Timofey Titovets <nefelim4ag@gmail.com>, Andrea Arcangeli <aarcange@redhat.com>, kvm@vger.kernel.org, leesioh <solee@os.korea.ac.kr> Subject: [PATCH V6 1/2 RESEND] xxHash: create arch dependent 32/64-bit xxhash() Date: Wed, 7 Feb 2018 13:22:23 +0300 [thread overview] Message-ID: <20180207102224.28016-2-nefelim4ag@gmail.com> (raw) In-Reply-To: <20180207102224.28016-1-nefelim4ag@gmail.com> xxh32() - fast on both 32/64-bit platforms xxh64() - fast only on 64-bit platform Create xxhash() which will pickup fastest version on compile time. As result depends on cpu word size, the main proporse of that - in memory hashing. Changes: v2: - Create that patch v3 -> v6: - Nothing, whole patchset version bump Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> CC: Andrea Arcangeli <aarcange@redhat.com> CC: linux-mm@kvack.org CC: kvm@vger.kernel.org CC: leesioh <solee@os.korea.ac.kr> --- include/linux/xxhash.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/xxhash.h b/include/linux/xxhash.h index 9e1f42cb57e9..52b073fea17f 100644 --- a/include/linux/xxhash.h +++ b/include/linux/xxhash.h @@ -107,6 +107,29 @@ uint32_t xxh32(const void *input, size_t length, uint32_t seed); */ uint64_t xxh64(const void *input, size_t length, uint64_t seed); +/** + * xxhash() - calculate wordsize hash of the input with a given seed + * @input: The data to hash. + * @length: The length of the data to hash. + * @seed: The seed can be used to alter the result predictably. + * + * If the hash does not need to be comparable between machines with + * different word sizes, this function will call whichever of xxh32() + * or xxh64() is faster. + * + * Return: wordsize hash of the data. + */ + +static inline unsigned long xxhash(const void *input, size_t length, + uint64_t seed) +{ +#if BITS_PER_LONG == 64 + return xxh64(input, length, seed); +#else + return xxh32(input, length, seed); +#endif +} + /*-**************************** * Streaming Hash Functions *****************************/ -- 2.14.1
WARNING: multiple messages have this Message-ID (diff)
From: Timofey Titovets <nefelim4ag@gmail.com> To: linux-mm@kvack.org Cc: Timofey Titovets <nefelim4ag@gmail.com>, Andrea Arcangeli <aarcange@redhat.com>, kvm@vger.kernel.org, leesioh <solee@os.korea.ac.kr> Subject: [PATCH V6 1/2 RESEND] xxHash: create arch dependent 32/64-bit xxhash() Date: Wed, 7 Feb 2018 13:22:23 +0300 [thread overview] Message-ID: <20180207102224.28016-2-nefelim4ag@gmail.com> (raw) In-Reply-To: <20180207102224.28016-1-nefelim4ag@gmail.com> xxh32() - fast on both 32/64-bit platforms xxh64() - fast only on 64-bit platform Create xxhash() which will pickup fastest version on compile time. As result depends on cpu word size, the main proporse of that - in memory hashing. Changes: v2: - Create that patch v3 -> v6: - Nothing, whole patchset version bump Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> CC: Andrea Arcangeli <aarcange@redhat.com> CC: linux-mm@kvack.org CC: kvm@vger.kernel.org CC: leesioh <solee@os.korea.ac.kr> --- include/linux/xxhash.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/xxhash.h b/include/linux/xxhash.h index 9e1f42cb57e9..52b073fea17f 100644 --- a/include/linux/xxhash.h +++ b/include/linux/xxhash.h @@ -107,6 +107,29 @@ uint32_t xxh32(const void *input, size_t length, uint32_t seed); */ uint64_t xxh64(const void *input, size_t length, uint64_t seed); +/** + * xxhash() - calculate wordsize hash of the input with a given seed + * @input: The data to hash. + * @length: The length of the data to hash. + * @seed: The seed can be used to alter the result predictably. + * + * If the hash does not need to be comparable between machines with + * different word sizes, this function will call whichever of xxh32() + * or xxh64() is faster. + * + * Return: wordsize hash of the data. + */ + +static inline unsigned long xxhash(const void *input, size_t length, + uint64_t seed) +{ +#if BITS_PER_LONG == 64 + return xxh64(input, length, seed); +#else + return xxh32(input, length, seed); +#endif +} + /*-**************************** * Streaming Hash Functions *****************************/ -- 2.14.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-02-07 10:22 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-02-07 10:22 [PATCH V6 0/2 RESEND] KSM replace hash algo with faster hash Timofey Titovets 2018-02-07 10:22 ` Timofey Titovets 2018-02-07 10:22 ` Timofey Titovets [this message] 2018-02-07 10:22 ` [PATCH V6 1/2 RESEND] xxHash: create arch dependent 32/64-bit xxhash() Timofey Titovets 2018-02-07 10:22 ` [PATCH V6 2/2 RESEND] ksm: replace jhash2 with faster hash Timofey Titovets 2018-02-07 10:22 ` Timofey Titovets 2018-04-18 19:32 [PATCH V6 0/2 RESEND] KSM replace hash algo " Timofey Titovets 2018-04-18 19:32 ` [PATCH V6 1/2 RESEND] xxHash: create arch dependent 32/64-bit xxhash() Timofey Titovets
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=20180207102224.28016-2-nefelim4ag@gmail.com \ --to=nefelim4ag@gmail.com \ --cc=aarcange@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=solee@os.korea.ac.kr \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.