From patchwork Tue Oct 23 18:25:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10653473 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 C27F613A9 for ; Tue, 23 Oct 2018 18:26:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2C122A312 for ; Tue, 23 Oct 2018 18:26:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A63352A2FB; Tue, 23 Oct 2018 18:26: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 4A92D2A311 for ; Tue, 23 Oct 2018 18:26:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728511AbeJXCu4 (ORCPT ); Tue, 23 Oct 2018 22:50:56 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39841 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728454AbeJXCu4 (ORCPT ); Tue, 23 Oct 2018 22:50:56 -0400 Received: by mail-wr1-f67.google.com with SMTP id r10-v6so1882652wrv.6 for ; Tue, 23 Oct 2018 11:26:25 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=juSqou92Oj6KHn9X1w5Z5XFkfnLalVstDj0XAX5DRwM=; b=KOb7K6LhClGd+kqwinPKr1pD/mjTkbw5eNsmQqL807GtKRZhWHnw1UM7Mg9JohoM3D MrVV0GRWUpD8gYdqZpFtA1Gin/P/4HGl0a1FXBY4PRTat+JbDcnhPOVjethwkRO4OL7C 3EYKv10yW3ootBE1SKPJNB2m/CxD7iHLo+OCA2weoNVnlilyITJ2v6wdknnuvT1XqTL9 361fimkDrt5XKXb9zplLe2f6+zbIcbIn6XyUaKmb+k9CrZRdPtcvZX1GojKtRE4BqJzd 25tzJv7yhm7PfwzWunrh8NyAGc7utnKkJGIwEOriuAS/qVbKLsIE85Vwly06q/knBawh IGJw== 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:mime-version:content-transfer-encoding; bh=juSqou92Oj6KHn9X1w5Z5XFkfnLalVstDj0XAX5DRwM=; b=nM4lX2AGFBjDS8LnpRDMkND3agL2K2jSK5XmXFXPtfvF2MtKfLLtsYy+EkW18dEqs1 6GJD8fp0t928BVs+lDkcbH+DC8dexIuztJSs2MAfliGeKW3tAimyeVCjzN8eKxEXeZoT pPDPu0zO/TW54qkDVeUxxfA7lNNWlJ8cxYJfiGeFc1C/GeW9RMvYzXKqoBks3ZycwTZQ b/TOJknT0+T1KGdWsQolyAP+2iapnMmmJLcBv6FdXOW9kOOiJ5yrPNWkyVeZi0dkIDGV pnLvbHv1xbbl72yd8q0195Y8tcBXeT6FXvumkx7BKRuXLyNMyGrewQdBLZmgvow5nxon ZALg== X-Gm-Message-State: ABuFfoi4Ek1jcEvVxeUYcrxNgwqi0uKQ/mSxkIK0myLeSFwoYEZyJcaQ +y98S6LzT5MfaQ5hw1zDkew= X-Google-Smtp-Source: ACcGV63F4p4vHD8I4RnSJptrwed2aLyHVx++q6v99VaYo7GoYFUpb+y+QuteITE++u4L/Nov+iQshw== X-Received: by 2002:adf:b743:: with SMTP id n3-v6mr52407477wre.274.1540319184275; Tue, 23 Oct 2018 11:26:24 -0700 (PDT) Received: from TitovetsT.synesis.local ([86.57.155.118]) by smtp.gmail.com with ESMTPSA id x16-v6sm2442551wro.28.2018.10.23.11.26.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 11:26:23 -0700 (PDT) From: Timofey Titovets To: linux-mm@kvack.org Cc: Timofey Titovets , Andrea Arcangeli , kvm@vger.kernel.org, leesioh Subject: [PATCH RESEND V8 1/2] xxHash: create arch dependent 32/64-bit xxhash() Date: Tue, 23 Oct 2018 21:25:53 +0300 Message-Id: <20181023182554.23464-2-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181023182554.23464-1-nefelim4ag@gmail.com> References: <20181023182554.23464-1-nefelim4ag@gmail.com> MIME-Version: 1.0 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 -> v8: - Nothing, whole patchset version bump Signed-off-by: Timofey Titovets Reviewed-by: Pavel Tatashin Reviewed-by: Mike Rapoport 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 *****************************/