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: 10653475 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 B5BC913B5 for ; Tue, 23 Oct 2018 18:26:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A48002A30D for ; Tue, 23 Oct 2018 18:26:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97D442A2FB; Tue, 23 Oct 2018 18:26:28 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 2DBD52A311 for ; Tue, 23 Oct 2018 18:26:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB9E36B000D; Tue, 23 Oct 2018 14:26:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D67CC6B000E; Tue, 23 Oct 2018 14:26:26 -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 C30CB6B0010; Tue, 23 Oct 2018 14:26:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 8F2FD6B000D for ; Tue, 23 Oct 2018 14:26:26 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id v30-v6so1725091wra.19 for ; Tue, 23 Oct 2018 11:26:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=juSqou92Oj6KHn9X1w5Z5XFkfnLalVstDj0XAX5DRwM=; b=f/Emp5HZEQ7bGuC2D8FrKI4BGvtzvfnYzo570cAGxbc1ZjlElqjOjrIwmDUKbzmcQx B6hpg2d7uVVSfZy69OQNkSgBqZKX5a2YWoYgc6jB7KeNHekE9NpWYp9mgE3fgWdtxCnp CfyvcgsXNH/jy2EB3Yi9ymyPm6vvBwOU6AZHPJg87vG7sYh3nk+RX/Iiev5t2485/nJB 4XVDT/LWedu+xFjiOwJp4+MqGjF2xvs9BqfeLQotSCA033+NwSopMHVgMvfoEAwSMGZe DUfri7dT08j+jT9Xd3nHKkM7LwXvrYiz3IuM6MfBI0G6dQa1nK71hEOUingi6By0ELEI 3kuA== X-Gm-Message-State: ABuFfoiVeozLTmrwUIpPud60lxsjlqEnA2+eZvBtvzFgHnC7BdJuYgHN ZK5VzNge3A97eAhnbR/FxbTReyzHYgAHEUw/Ggyk/Z7O4GLU8Nx4dL/WhxnsXmH7KmRcJntI+/O KBDAIrd/aW8QFFjBgb3q1wNjnBGhmMZMe31jMcmgQPzSZX+gRVzJPKOZd7GTNbW7kuw8gwByxrz 1S89ELZMUijR7lBnl2xkcbX3Y8cGpEcQr3V/ztAAzQ2gshouJ3G/Fn9g1ItKmOS6zVkZCI9sg6X /u6kvmL0EliOWBJnvHeJWwrTNoqswLBPmctpOvTPS/QPU0WNhGYFW3ZEUd+5K50zMlCP7MBoNoI RUbszijv4t/IU0EXY4xCaDRc+F8oejQJRxH1qS2AV9Wrb6MJlJG/l334e5VK86RIDebSmB3XnzA s X-Received: by 2002:adf:f18c:: with SMTP id h12-v6mr26941303wro.86.1540319186013; Tue, 23 Oct 2018 11:26:26 -0700 (PDT) X-Received: by 2002:adf:f18c:: with SMTP id h12-v6mr26941241wro.86.1540319185043; Tue, 23 Oct 2018 11:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540319185; cv=none; d=google.com; s=arc-20160816; b=esuqtjS+MYRwMqYbs4ac0/PRseAt3FKdy+ndhdoCf3nujmKAj1i7qVAYp3tWipaAq3 9jmY7Yf55P/qxSIDlT00pDiFxec1k/erAOO37uvRbwN70jngC5uUUoE9OrMR79b1UfWa NjNzxB+nsqyG8dr1OkwpgXoM7GjNpoOvX88oG+eOuSfG07a24R3CU26S0EZmvUZioGdJ elr9jdxc03nNm6hhFlZc961I6YY1SFHcU0jdcngUHIW8r7eEFlZLb33Z3SmT21choBID WriscErCww8+gkuz3sa5HXA1eeVhzDURXvZZrZY93RIPUeKMGYdQcO0LQ7r/keuiecQN kXMQ== 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:dkim-signature; bh=juSqou92Oj6KHn9X1w5Z5XFkfnLalVstDj0XAX5DRwM=; b=MOW5Z0FObdTIHeAVJzNxl0tCxLHT1vacQG/GM1lzDCTtFYKu/nmWU7BYr7XhAXXK9L akp1iT3XG+Nv0nNnR4pU4HQqI25sR1M+uemKyEZR4mxJfkht6N8xzg0YU/u+z8gu77kN tKtEGoTQSKsy4CGT2+kbiOV11CUrUlD/NMhU6Sih7Rrq3kwY9okqjjsujTkXS4j276bT epSyobaRWVcbRRR7360h0eDIQeArbU+eFDq4wXRG+PBixIkshHWqH2Zgjru5qdKDY4TA PyPLGQbVnjjhy1IHKKsUQ7NBXyeQcwocqeKIEEGTwaZfwRMm8fadtJj2RVT2h1CzsevE pESA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KOb7K6Lh; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=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 v3-v6sor1635402wrw.43.2018.10.23.11.26.24 for (Google Transport Security); Tue, 23 Oct 2018 11:26:25 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KOb7K6Lh; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-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 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 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 *****************************/ From patchwork Tue Oct 23 18:25:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10653479 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 94CD313A9 for ; Tue, 23 Oct 2018 18:26:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85F8C2A31F for ; Tue, 23 Oct 2018 18:26:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 840252A322; Tue, 23 Oct 2018 18:26:31 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable 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 0C14A2A30C for ; Tue, 23 Oct 2018 18:26:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F7016B000E; Tue, 23 Oct 2018 14:26:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 37DE76B0266; Tue, 23 Oct 2018 14:26:28 -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 26CE26B0269; Tue, 23 Oct 2018 14:26:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id BEE296B000E for ; Tue, 23 Oct 2018 14:26:27 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id 66-v6so1886352wmt.8 for ; Tue, 23 Oct 2018 11:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XMhwUaYFX1Xwieq8R43xwhmhoXuGl8283OLe3DBZQS0=; b=sj+/gKvb/GO2y4EliehaVcKWjEjxYa0hal40Gdfamq2pTBtC9TsOxznSsZL62HS2F8 lr/cqkezzqC7XYvfCBL2wCsLsyLXpJn8M29YK8qX12pxqnvloBumhpKynwDgU5BdM+5L jeQJTlprVEs2/jFwq0IulSXLPc0sc77FNd7LL8POMlwGQm7fFMo351XpSBii6prdX7+j 8qbAtSbPN9u1FQW2GAItz8SC7EHujl0mFHbe7n/JGd80gekZrk/+b8O28PVBv4zx2ZB8 htfWIXOiuDLmuFLev9+vVLq8whDJT+oStmdiNI/6yfRzJ403P5A2LOsVqusfTBK8nmeW iZBw== X-Gm-Message-State: AGRZ1gIr/5fZNNnCsbfV96y9m5UplBGd9cIzbXe4mpXDyJREou/vBF6e Wnl4Y7T/hUN5I8/QBWxPXBrhm1Onn3M9eMi0JSYClKTN/YUiItMHdK8VqT66E1XIfOHwQYcAgy7 9Ne7R0VPHqhEiF4BbWlcBWe4n/P7pRnQulESc2OFYuZXwv9ZgPon/x/53X8nGzoBEB70WOc9GuF doqmjfvyukcOis2C0D6J0iscQhFj8Oapi97XSZdwrBg6NCyjBIpawAKAeioZ36M0CNekkm5FyK6 5jIha+5YS+STE0Vra6p66af2i34f0i+E+aWxQmgICu12pmSDAPCYhbtRjfs2JpU3DX2+CXZ2uUh GsRQnSkkER7eQRpRWgzgdsVczyzWybbB8GIjSBl4gW6lJF8QNCGNbzPVBOweY5SmJxBjRxBotPV u X-Received: by 2002:adf:e68c:: with SMTP id r12-v6mr152562wrm.239.1540319187119; Tue, 23 Oct 2018 11:26:27 -0700 (PDT) X-Received: by 2002:adf:e68c:: with SMTP id r12-v6mr152501wrm.239.1540319186069; Tue, 23 Oct 2018 11:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540319186; cv=none; d=google.com; s=arc-20160816; b=qAyc0pd3RRMLW1yQUulCch0Th+uh4knKqUdUADwXS1urnk6QVzjhZ1+vur0HTZmNdO qw9nbgljqzuy563eatqNUYn/7mueEodoD7Wm7aZ3VvH35MzTwGxfj3TXUFfUc6JmHGmj vLoKdyhi4/IQkfNI+ei27knLVfAp+t1FZ+RMbGznMcHf4H+rw/zF8cx9Jf9AevrcnGcx nuLE5IPqqdb/ER4e51ycfrycjUsQ7e5cvHf7fUx7l3q/FexOw3rR4ZgCPRR17lD8KH06 gzROIupsPlDFpNg2+a+s7VU4ebeYkhyf/wvoKlMTBw0YeWnRJain66a77i/pXFei3AEE 00rg== 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:dkim-signature; bh=XMhwUaYFX1Xwieq8R43xwhmhoXuGl8283OLe3DBZQS0=; b=vRqkknyVcNbRAWVNeSbHPlQ2NuYt2nLZsa6hUBzd90pdwvy3KnstKzE/dBPkh9wYTF /5C3Rg0Mer6ywgsjrsrPJhoIM0/Q/6kA6Vs0lGEacMDevAp60cd4y79vbt8FnbnwwC0F sf+z8wmIcwTcLR3InyxZyKxgb3OByMiA1bvJoM+4Laxz0pa4hBI+y+BqLeWpdMnLNeib an9lvZW6zfh1pBjcXG7GSpXSK6J80/tXtN6ih+lYirn95hUW9mRLfNiwdvLL4FVfiuwO 02Lc11Xxc1YWNVwWk/ocW9EdpmFK+ntV2U4RN6e0O6iaLkCzxqSduead4RGaofaN7Ujj JamA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hbAbuY6K; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=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 r15-v6sor1636550wrs.9.2018.10.23.11.26.25 for (Google Transport Security); Tue, 23 Oct 2018 11:26:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hbAbuY6K; spf=pass (google.com: domain of nefelim4ag@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nefelim4ag@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=XMhwUaYFX1Xwieq8R43xwhmhoXuGl8283OLe3DBZQS0=; b=hbAbuY6Kk89Gq3WyfTfPAvHD20SAJHHsyQ3qhy1xt8rNhN8jXScQApDRl7Y29xccGi On+m/FPEfXUkXpFqzBVUdlohdWDIiDJJxg+NrW2GKQUeH95uVufpXtcwBJyQMwIs/KJz aUXl/ZV6I4HMoOzqApZqTzscZdZWzow7+wgoHIop5+qR02cIqJ/7G6guzeSBhijeZORV 7Sae7MV3y6j9xy28OTClHAynP7gBbybETmXhIVCtNShDkRG+cs+yWq84mLq0m1F8zH4o 3lh8/Zz4lBQv5bN6UVZ8cgwU0Ffh6HCBMAeox8mjb3v3NkRaS8pDCH9ym5UN/4wE1opc 1IEQ== X-Google-Smtp-Source: ACcGV62VGw65izw26x41K2uzrWXeln7LOI0N5KoZPJq7+vF85lbd9RCTdpnoMiST73jIukT8EGYFuA== X-Received: by 2002:a5d:49c4:: with SMTP id t4-v6mr50957119wrs.116.1540319185318; Tue, 23 Oct 2018 11:26:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 11:26:24 -0700 (PDT) From: Timofey Titovets To: linux-mm@kvack.org Cc: Timofey Titovets , leesioh , Andrea Arcangeli , kvm@vger.kernel.org Subject: [PATCH RESEND V8 2/2] ksm: replace jhash2 with xxhash Date: Tue, 23 Oct 2018 21:25:54 +0300 Message-Id: <20181023182554.23464-3-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 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 Replace jhash2 with xxhash. Perf numbers: Intel(R) Xeon(R) CPU E5-2420 v2 @ 2.20GHz ksm: crc32c hash() 12081 MB/s ksm: xxh64 hash() 8770 MB/s ksm: xxh32 hash() 4529 MB/s ksm: jhash2 hash() 1569 MB/s From Sioh Lee: crc32c_intel: 1084.10ns crc32c (no hardware acceleration): 7012.51ns xxhash32: 2227.75ns xxhash64: 1413.16ns jhash2: 5128.30ns As jhash2 always will be slower (for data size like PAGE_SIZE). Don't use it in ksm at all. Use only xxhash for now, because for using crc32c, cryptoapi must be initialized first - that require some tricky solution to work good in all situations. Thanks. Changes: v1 -> v2: - Move xxhash() to xxhash.h/c and separate patches v2 -> v3: - Move xxhash() xxhash.c -> xxhash.h - replace xxhash_t with 'unsigned long' - update kerneldoc above xxhash() v3 -> v4: - Merge xxhash/crc32 patches - Replace crc32 with crc32c (crc32 have same as jhash2 speed) - Add auto speed test and auto choice of fastest hash function v4 -> v5: - Pickup missed xxhash patch - Update code with compile time choicen xxhash - Add more macros to make code more readable - As now that only possible use xxhash or crc32c, on crc32c allocation error, skip speed test and fallback to xxhash - For workaround too early init problem (crc32c not avaliable), move zero_checksum init to first call of fastcall() - Don't alloc page for hash testing, use arch zero pages for that v5 -> v6: - Use libcrc32c instead of CRYPTO API, mainly for code/Kconfig deps Simplification - Add crc32c_available(): libcrc32c will BUG_ON on crc32c problems, so test crc32c avaliable by crc32c_available() - Simplify choice_fastest_hash() - Simplify fasthash() - struct rmap_item && stable_node have sizeof == 64 on x86_64, that makes them cache friendly. As we don't suffer from hash collisions, change hash type from unsigned long back to u32. - Fix kbuild robot warning, make all local functions static v6 -> v7: - Drop crc32c for now and use only xxhash in ksm. v7 -> v8: - Remove empty line changes Signed-off-by: Timofey Titovets Signed-off-by: leesioh Reviewed-by: Pavel Tatashin Reviewed-by: Mike Rapoport CC: Andrea Arcangeli CC: linux-mm@kvack.org CC: kvm@vger.kernel.org --- mm/Kconfig | 1 + mm/ksm.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index a550635ea5c3..b5f923081bce 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -297,6 +297,7 @@ config MMU_NOTIFIER config KSM bool "Enable KSM for page merging" depends on MMU + select XXHASH help Enable Kernel Samepage Merging: KSM periodically scans those areas of an application's address space that an app has advised may be diff --git a/mm/ksm.c b/mm/ksm.c index 5b0894b45ee5..1a088306ef81 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -1009,7 +1009,7 @@ static u32 calc_checksum(struct page *page) { u32 checksum; void *addr = kmap_atomic(page); - checksum = jhash2(addr, PAGE_SIZE / 4, 17); + checksum = xxhash(addr, PAGE_SIZE, 0); kunmap_atomic(addr); return checksum; }