From patchwork Wed Feb 7 10:22:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10204871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A08360327 for ; Wed, 7 Feb 2018 10:22:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29D6B2882F for ; Wed, 7 Feb 2018 10:22:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DF7F28AA2; Wed, 7 Feb 2018 10:22:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5E92882F for ; Wed, 7 Feb 2018 10:22:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753692AbeBGKWk (ORCPT ); Wed, 7 Feb 2018 05:22:40 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38286 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753564AbeBGKWh (ORCPT ); Wed, 7 Feb 2018 05:22:37 -0500 Received: by mail-lf0-f67.google.com with SMTP id g72so572987lfg.5 for ; Wed, 07 Feb 2018 02:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZX++hfzzMK6IE9yc9NO9WMK67Pbh5RHrPdiOO/73QF8=; b=l3eyN5ikWzpkJkX1OjJi0SR1pbeBjCp1GVyxJtLqHj/wUcb1yRj+Z78uUDE1CBzWJ4 nmIktCCM++iz6yFcNm0tE1/uOTeDiMMNul2DzVOryy2fl4ACzudDgVQWktwpSWzmq/lk czA4tM4Wga0QwSQK/x5E2kzYtA6HEF6YoCysXlQBAvCrYZy6G53h3eskFhPfUCUPsfx4 niJhzVNQ+YtkzNxNw2lmkEv7PVK+x3y7ynISVJsVgot9cSdUexFvGqlHQm8TCx0MEubh ASaTbnTDudgp3GYanpV5JYhkjynOLC+Qoht4OAPuFLlDUXKmHJzRWcqB4CYHdBXZaVpV dZQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZX++hfzzMK6IE9yc9NO9WMK67Pbh5RHrPdiOO/73QF8=; b=VdrjmpBxthhvigJzIs85qaoMXOKx8nN+gIxbfuhGYnOr35G6Xn+UOGESR1M8WngD8k BjJ+DVmQLVpdLykI2tzGnqQwxyu412R7W+QRLD7E+nmcHX1hwbz2o+SY3DbDtA82MMqL ZdVWsMV4LKwqQ+ZzuDRcSxD8DsYrgR61MkeJUqHpHtueXwu5a7pL0V76C9/oz6y2wfB0 RNfc5J4FdCZVzBMum8CdrwFyv5UY+a1qWBp4wu4C/Al0n1rviixX8pX4PrXedFbHg5yn mgHdblumu0/QJVtCUkgzLBnTIDb/+mLjk5Uqjc0Xfm5vO1AntX0IBsm3HvTcuO7NQ3MU ZdyA== X-Gm-Message-State: APf1xPCkTitP92mzUZPmVn0cxE1zj1C0l2JfX0c6P+7L1lrKAq6cgXrm P8Nc3VerWAC9JVMPr62vjlSZpg== X-Google-Smtp-Source: AH8x227zeNN9LqnoVTq0+b7Z5PkroBEBdBRAg9zmjLij0nH3TB2Sf/nYbfsYe0PnKg2Vy6cTbYLwAg== X-Received: by 10.25.225.84 with SMTP id y81mr4027467lfg.96.1517998956569; Wed, 07 Feb 2018 02:22:36 -0800 (PST) Received: from TitovetsT.synesis.local ([86.57.155.118]) by smtp.gmail.com with ESMTPSA id v197sm253238lfa.25.2018.02.07.02.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 02:22:35 -0800 (PST) From: Timofey Titovets To: linux-mm@kvack.org Cc: Timofey Titovets , Andrea Arcangeli , kvm@vger.kernel.org, leesioh Subject: [PATCH V6 1/2 RESEND] xxHash: create arch dependent 32/64-bit xxhash() Date: Wed, 7 Feb 2018 13:22:23 +0300 Message-Id: <20180207102224.28016-2-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180207102224.28016-1-nefelim4ag@gmail.com> References: <20180207102224.28016-1-nefelim4ag@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 CC: Andrea Arcangeli CC: linux-mm@kvack.org CC: kvm@vger.kernel.org CC: leesioh --- 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 *****************************/