From patchwork Sat Dec 30 23:26:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10138031 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 8AF5960233 for ; Sat, 30 Dec 2017 23:27:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E3E9287A2 for ; Sat, 30 Dec 2017 23:27:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7318E287A6; Sat, 30 Dec 2017 23:27:27 +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=unavailable 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 29DC6287A2 for ; Sat, 30 Dec 2017 23:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750949AbdL3X05 (ORCPT ); Sat, 30 Dec 2017 18:26:57 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45246 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917AbdL3X04 (ORCPT ); Sat, 30 Dec 2017 18:26:56 -0500 Received: by mail-wr0-f193.google.com with SMTP id o15so12061825wrf.12; Sat, 30 Dec 2017 15:26:55 -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; bh=yHjMW737ipMcqbipb67WyAvoyb4RxEGD0Hcw/theHgM=; b=H6xv63YfZfJ7cvFRHOe2n+FjfT3LN4Y//7SRRt92keoSrnqUUtinRIN/g3MgzpayXL CfcSRQrHFmFjT03wro8ZWRgPTjZMRo+VenIiuEkGkysnxAswFb45NLOyjUJbGx7utrQr wRiZS0v0CuJRxKzPIb944YpSz5RIevLyJDDab7G2Z1yrm+TqzDRJYfCeovja2KDaYMJa li3+woa24rujT++i8aPL/XR2MJlvEZjISzScLY3NL01xrSP9ODqRZ7pvCkCr0WtGLCbV m+EoCM8h/q4FimJ9Y9xFH/LI+HPw1nSPAe0OxX4Q37mnURsPu7AVMsBY2RRimxMT9svO R3OA== 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; bh=yHjMW737ipMcqbipb67WyAvoyb4RxEGD0Hcw/theHgM=; b=a+WAPtWOiTM9pDYU0DusCOog/jleFMQBONAYp6GskpNT4TMbRy8s6q3m0cK6BWENLq HbjvYrsDJ1ksot1/hg8dYJpI0Cn6kxFvluWL9vj7E793vqBKF+39xK0V9qcMFUiPn4LB ea7HS8OwKGyr6BKpBPjeypGSiNnSWH38REXOZGZyF0o6YpIXWrBWbIbrTeLh0ySUPw1L tbhyE2CGJAS46o/saG77W4mHjW+8xAfNsYAlwbFTmXjfQDW3zYFLgF7iefhVT/EAKmpz V7WSkA47yDYN7X92Cad6umIIo7zJmWPuRHElcZ329jOHWGPIk3iO3PVaEOFb2pl0M7tz AZeQ== X-Gm-Message-State: AKGB3mLax6AJeJ+LM3usZXBLlzdoVZ4WoWNdSSqdbpMVoMbcGRNtYno1 1nfG2Bola1snmmOUIFzgVEw= X-Google-Smtp-Source: ACJfBosDbsmVbp4wTeJ4ZK3UL2FBeJ7BTSP8x6kZcmskUfdb2HS4GQ7HCb83HNEnnu4q6wXC9EGayw== X-Received: by 10.223.136.184 with SMTP id f53mr37050280wrf.143.1514676414689; Sat, 30 Dec 2017 15:26:54 -0800 (PST) Received: from titovetst-beplan.lan (nat6-minsk-pool-46-53-208-190.telecom.by. [46.53.208.190]) by smtp.gmail.com with ESMTPSA id w75sm33883433wrb.86.2017.12.30.15.26.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Dec 2017 15:26:54 -0800 (PST) From: Timofey Titovets To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Timofey Titovets Subject: [PATCH V5 1/2] xxHash: create arch dependent 32/64-bit xxhash() Date: Sun, 31 Dec 2017 02:26:42 +0300 Message-Id: <20171230232643.12315-1-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.15.1 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 -> v5: - Nothing, whole patchset version bump Signed-off-by: Timofey Titovets --- 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 *****************************/