From patchwork Thu Sep 13 21:19:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10600091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33C2314BD for ; Thu, 13 Sep 2018 21:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 707F32A600 for ; Thu, 13 Sep 2018 21:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 628D12A778; Thu, 13 Sep 2018 21:19:47 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 022DB2A600 for ; Thu, 13 Sep 2018 21:19:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76E2B8E0003; Thu, 13 Sep 2018 17:19:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 71C498E0001; Thu, 13 Sep 2018 17:19:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 545D78E0003; Thu, 13 Sep 2018 17:19:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id F18578E0001 for ; Thu, 13 Sep 2018 17:19:42 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id d17-v6so7022025wrr.14 for ; Thu, 13 Sep 2018 14:19:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cFIeUsRp+NBJYkgWfXr3IQGOiaZM5wzZBw+4DdYtwDA=; b=cH06JcqimATJtLq/dXR7ktyZsarBbfgso1lhmsIvwRvFdCE7FI1eyOzgMVdiHrdK9G Xd4blGW0NbfAns1DaH693yPio2dTc8UIOwWyPZgKZt3tICFgn0SxpnCb8mj3AbcxTJv9 YZsMjEZXFY+Rdj3Q167rtvVSNFBEu/rvgpEGCJINhzU6kXjaKAgRVdG+TBxdde4t28E3 kuRAYkgPOwF7ixr7f1J1vnZhpZ9E1I2gXiU3BqZ/ry01OEAgnAKAct66f05ZirSWljvD XvTYQT7KpwoOzNOkgB01JjO2nYa02d9FYaFOuAWwy5iTNOg6hK6Olr04qzXBL848+sdN 2/PQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com X-Gm-Message-State: APzg51AuIqOBjDixxVXdrdLCXziNL8Mj3ptmuC3mDfTHDRefFsGF/cmR DF69MaVi8ZtXtkb3xlYti4A8aSUPU6rx66bhmFtzh9r8gUWLL+1IyQXqAMKtb9oFONFXhRe/6rc tYyIibGT7UmD5YxxBZtfZyB7HZeufXiGFI0WZRdX4oOk6lyA4Sk2ZFz6TEJV1QmIVON5W8/wTWU riG11UtCFSKSfRXmaZB+B5EVo6GTeElRz3IFhNE/QV73iJqhQc2DwYC6gS8+mg8sAvZ70+ucVrp wvxItjB8awo+P+3QSD8oIBDuGor0SA0dxOE8slh/dfUl+N0zzILoWS1wi/oeDe8uj90DOoShkZq AAo6YNY23hBHE31dTOFwRD+EwnlsqYIT9Q0+NQQJVXqLHyOt/BbbI3mSSMAKVFO0UNf046XamQ= = X-Received: by 2002:a1c:8406:: with SMTP id g6-v6mr6663796wmd.18.1536873582507; Thu, 13 Sep 2018 14:19:42 -0700 (PDT) X-Received: by 2002:a1c:8406:: with SMTP id g6-v6mr6663772wmd.18.1536873581754; Thu, 13 Sep 2018 14:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536873581; cv=none; d=google.com; s=arc-20160816; b=NHOHU4DrsV6JSp3sbVSrf8Nt8eFOmsEvphDEEujCDmDZhEUvimNpZ7ZO4+hUGQtdpj ei4Zo67s2A94ouXGbAwFqGzirtkGZQ5N/g5i/oTk7TnYJ55eagXYTI4W7KAy0ghJu5Tc uOzZ9p0D29KFLF04nV5ca4986+Vz5z7WehZqliNRHVwdWjPGY8FEfDvxVlgPzvv5qgxo g51bS7Sla7b5Lw3nRAupd+D065DSC6mfsHtfOj+mHgi2jJVnmIOQL+CefW4gQAK9d2Ng fS8U+UJUlcZXphjxsKEdHeKsFMrhsH6RsAbPsVRWpWlXUsCmw7ey/iigWvKECc8IoUk0 7k2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=cFIeUsRp+NBJYkgWfXr3IQGOiaZM5wzZBw+4DdYtwDA=; b=0NrWAgg/GlOW262pQtq+yYlQA9rARUys9kehU/PfbObJH6UGQhsOJQ2J1yPScbC4Jl uFEEs3qKBvCZWRwRVtayUwtmeRz7WvZHq5gwoR2BFkZvSbxVEBU5CtS2RLui0Ca4fxq0 ln/pl7Egn2C6pw1GTfs8nVkENxAKRJ6qtNAx1aPQCXlJf7BVgGimLF8M7t/p8+YrOKkC jBX49Bvr1meTEtDLgXQGOddZmDHfcJQPcmaWpgBzS+PO+30hl7Kdaw2rjad+b2PORsap ztAv/lFxoSnuZio1AR5d0Lf5NFd48K2jZZv6Db+P2xvEztYvXskm7oQ1aEmBooFhFCPw rr2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k13-v6sor5020492wmd.18.2018.09.13.14.19.41 for (Google Transport Security); Thu, 13 Sep 2018 14:19:41 -0700 (PDT) Received-SPF: pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com X-Google-Smtp-Source: ANB0VdaG57Q3qIxxYC5UPFbLnBefIcaaOsK33TWBvBsypFGkiRR4p0kBrxpjWGU+QtPTrc7hQgHL7w== X-Received: by 2002:a1c:28c2:: with SMTP id o185-v6mr7322428wmo.40.1536873581138; Thu, 13 Sep 2018 14:19:41 -0700 (PDT) Received: from TitovetsT.synesis.local ([178.121.227.155]) by smtp.gmail.com with ESMTPSA id 75-v6sm11068673wml.21.2018.09.13.14.19.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 14:19:40 -0700 (PDT) From: Timofey Titovets To: linux-mm@kvack.org Cc: Pavel.Tatashin@microsoft.com, rppt@linux.vnet.ibm.com, Timofey Titovets , Andrea Arcangeli , kvm@vger.kernel.org, leesioh Subject: [PATCH V7 1/2] xxHash: create arch dependent 32/64-bit xxhash() Date: Fri, 14 Sep 2018 00:19:22 +0300 Message-Id: <20180913211923.7696-2-timofey.titovets@synesis.ru> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913211923.7696-1-timofey.titovets@synesis.ru> References: <20180913211923.7696-1-timofey.titovets@synesis.ru> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Timofey Titovets 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 Reviewed-by: Pavel Tatashin --- 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 *****************************/