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 *****************************/ From patchwork Thu Sep 13 21:19: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: 10600093 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 1C06C14BD for ; Thu, 13 Sep 2018 21:19:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B23C2A600 for ; Thu, 13 Sep 2018 21:19:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EDEC2A778; Thu, 13 Sep 2018 21:19:51 +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=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 375AD2A600 for ; Thu, 13 Sep 2018 21:19:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D391B8E0004; Thu, 13 Sep 2018 17:19:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CC0618E0001; Thu, 13 Sep 2018 17:19:44 -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 AC5518E0004; Thu, 13 Sep 2018 17:19:44 -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 494428E0001 for ; Thu, 13 Sep 2018 17:19:44 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id i11-v6so6890351wrr.10 for ; Thu, 13 Sep 2018 14:19:44 -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=VrErO3KzNLAe8v4bQPJrWAB0rS+FdfcdIfYPE+8bASo=; b=TvtYsL94GyW8k+rluJs0qQXglfJ43xua3RFi6LBylNr2v2paU3X90h9JOID07WbkQZ zWwm+e/J8gNoWQXQg6FPvjKjg+gbDUPlD9BbOYnLWtzBJUcDH4Ldq22s+TcR4B+qW6Y0 4oYm6VfZrdjBBC1yr3dP+xurJcxoPig9Ez8LOe8Bn24tSyE7EOl129aZlao14zRK8WDk R97CUKPYlYeRxWE3H6W9/4YIPxPO5236DlhPDl84KzU539Ui1vFm7TXSkfzCzj5/kJ5h BQv2/V6MZ+TZiJFMCTHqwnsVv9Wg2ClL2AFNU/dV9+EfqGjNR55wPm5se1ppOgETCLfb z7Rw== 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: APzg51DwzHtfFLQvNNlYR3lwhBiT71iMccYdyMLkgyC2PM5U9IKGsGm3 zrtWsbaViAxK/5zGb/46GrzNX3A61QCRiVHnyWoS3aGBNxl2g0iSxBx4bfFZAG6/h30nibM2bS2 I4PU4uDCfoTWompuVC0kc7xSF9LuiTr2CXDoc3TbeD0uf7/dxFwxn9ilc8N5jnLzCT2dSbOf26K 3b4EQrnsjVqffl00S3AqlwaPSzXNdgNFhwj/IWZepprHBQYgKMQbEj4620Usbwyy3Dvd/4GAte6 B2XcKSHYjjudcdijVgCAD2e5yG0DERwzzjivRxG7YUkXCTHhepelLSwfzuene1iWyEEx8IqpJpO zfik0yuGiboI3xKryCpjN/RNQR+ig9XN3U5S5Wqab79NbDJuyyPll7tbmnn6fXITsX8toduPaA= = X-Received: by 2002:a1c:9215:: with SMTP id u21-v6mr6873245wmd.106.1536873583794; Thu, 13 Sep 2018 14:19:43 -0700 (PDT) X-Received: by 2002:a1c:9215:: with SMTP id u21-v6mr6873219wmd.106.1536873582836; Thu, 13 Sep 2018 14:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536873582; cv=none; d=google.com; s=arc-20160816; b=HKbKLagMkiGle1Ys8uPXfCnnJ7jKzVWGKmmx7sh5Ae8FGd+1hUy//I+jD66Ki16eN4 BrJVAqFDogQE2+iOAj8ILEDXHonKoQdIoCzbrDjGTzOGDh57EpfDa7BkesJA7Axu3r/a b3HYMTo2g83O9h3tYAM7q3ExCPJym0J7jn/YKLoQXyerymjx0XzxfCEZocSKYPXsFuZP sy+UFnZdINiqb2TDwQKAXHebNUyrAhbHsax8Oq5vxnfCixn85ZHKquw/7tQ0qJtUUbZj Hw0H9P01Ci6WHi2jqqubLmGch7aZP4UDlJu6FqEKkI1+fhpgLo+4HS9rV7bp1smKbMrq N/Pw== 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=VrErO3KzNLAe8v4bQPJrWAB0rS+FdfcdIfYPE+8bASo=; b=uvjVkbmfgj+tpqkW/RGj7Gva3SfqdplGrAoJltSbG3uNyXFHUIcBqmpOm6A+mjY+it 4awdSazK6zuG3QMpkAi3fj3RpYZD3r9Io6e74Qmn2kyGY5nfsrvH9YvPgXejZM7hOkBo sheHCpgK1I1u0vp5pj5FUbbZGcLkuKcbxb+1mpev+8LvN+UB8Dq5+ZaCsRCkK4r7JvIl Mwu7GqUhlGJ1Ct3hWJU3DbhzwKDVSiGt0W3Kf8pkVCfKfg164AC1W9ur02cE5vGKk/y2 h4im4vJNrTJtTvOQhhkEviKAB5DlKMzG3cmbZD5lA9CmOv8Xvfpm/ASxWyNDet0c5w6P NOyw== 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 w35-v6sor4344321wrc.46.2018.09.13.14.19.42 for (Google Transport Security); Thu, 13 Sep 2018 14:19:42 -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: ANB0VdYkkn/kwuck2Z1XfYJLZJ7L7HkCA97Wo4n6X5ILKwAc371uOE4h2GNA4vYjod0g+dKL7plJ/g== X-Received: by 2002:adf:d20a:: with SMTP id g10-v6mr7506082wri.66.1536873582299; Thu, 13 Sep 2018 14:19:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 14:19:41 -0700 (PDT) From: Timofey Titovets To: linux-mm@kvack.org Cc: Pavel.Tatashin@microsoft.com, rppt@linux.vnet.ibm.com, Timofey Titovets , leesioh , Andrea Arcangeli , kvm@vger.kernel.org Subject: [PATCH V7 2/2] ksm: replace jhash2 with xxhash Date: Fri, 14 Sep 2018 00:19:23 +0300 Message-Id: <20180913211923.7696-3-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 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 By sioh Lee tests (copy from other mail): Test platform: openstack cloud platform (NEWTON version) Experiment node: openstack based cloud compute node (CPU: xeon E5-2620 v3, memory 64gb) VM: (2 VCPU, RAM 4GB, DISK 20GB) * 4 Linux kernel: 4.14 (latest version) KSM setup - sleep_millisecs: 200ms, pages_to_scan: 200 Experiment process Firstly, we turn off KSM and launch 4 VMs. Then we turn on the KSM and measure the checksum computation time until full_scans become two. The experimental results (the experimental value is the average of the measured values) 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. Signed-off-by: Timofey Titovets Signed-off-by: leesioh CC: Andrea Arcangeli CC: linux-mm@kvack.org CC: kvm@vger.kernel.org Reviewed-by: Pavel Tatashin --- mm/Kconfig | 1 + mm/ksm.c | 6 ++++-- 2 files changed, 5 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..30c595dd5d87 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,6 +41,7 @@ #include #include + #include "internal.h" #ifdef CONFIG_NUMA @@ -303,6 +304,7 @@ static DEFINE_SPINLOCK(ksm_mmlist_lock); sizeof(struct __struct), __alignof__(struct __struct),\ (__flags), NULL) + static int __init ksm_slab_init(void) { rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0); @@ -1009,7 +1011,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; }