From patchwork Thu Sep 13 21:19:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10600087 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 36E346CB for ; Thu, 13 Sep 2018 21:19:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72FD92A76F for ; Thu, 13 Sep 2018 21:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 656AA2A778; Thu, 13 Sep 2018 21:19:45 +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 0E1B82A600 for ; Thu, 13 Sep 2018 21:19:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98F498E0002; Thu, 13 Sep 2018 17:19:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 93CFA8E0001; Thu, 13 Sep 2018 17:19:42 -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 8051A8E0002; Thu, 13 Sep 2018 17:19:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 23A5C8E0001 for ; Thu, 13 Sep 2018 17:19:42 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id j6-v6so6989399wrr.15 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:mime-version:content-transfer-encoding; bh=emxgfuk55fWq+3NEXmEWPrwx8FWl1mfWjrvDV3mdGqQ=; b=YtigL2zafSdue0U50Q3HpjE6MduKZY9DXXDZQuDwhxR8Fdxz6VytDUbJQGIJnlGOux NNcKav74QKFM2fgDYEJQA6lQgbAntCgEqICV9ftKsRKuFaEA11T8ookHRt4OQyOW0kVL 9OxKKv7aKioUfV0E+f/zgH/cBzS6BkQyRj63wo4m83pf4uuwjZS6j1WVzIQV5TniFtzO 16L6tvicgq2P4rxnA2m36xKNgzYcL+ArKJf3B2y8hbYsI9IVUVPkI3DmccfzTIycPHp+ 64buEqyITy0sWqEUBlm2Nzv9oloWyLjuqMlfixyEYf6IVC2o1L2H3nyKRDMvySHIMttn qSUw== 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: APzg51CnK5SszIe4+ZjbMAEHGT/xMqGpdGeQdLetZF23R22/vQ2wpSpY UTbLwoyibTD8RNEAjL59vJdV6td+cdDvtrckxjMpcI0AwlKW3JZJ34uwIREc1CfIR7CEWU27ezI 3RG2E81oSd4TH6GgQqUCz58o/jCxVQ68yxDXtb6vru8KqgSMHTdtCtMUM52gCNnCexnZ6wVxL89 hlFKUll+rdKaribw5NI4hqtam4fdC3cHqSEQx5yiOJ8OnANL5/otvp2Hbs4CA8BJIihU3S0yjlB /SFLgsMAaune4vDtN31EG6P21oGnfG8mdL6nrBWmrY/DVlqJJINOyW2+fH+PqgNKR72ETQwuN00 Y/8ZN02Hq9zhHwXTE5r+fYd97iFmF8wcCiBHIc5kI3CPpYFbrV5O9i453QaTdwefhV7P9gmwTQ= = X-Received: by 2002:adf:a3d9:: with SMTP id m25-v6mr7026390wrb.1.1536873581646; Thu, 13 Sep 2018 14:19:41 -0700 (PDT) X-Received: by 2002:adf:a3d9:: with SMTP id m25-v6mr7026353wrb.1.1536873580736; Thu, 13 Sep 2018 14:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536873580; cv=none; d=google.com; s=arc-20160816; b=qcSJ+UaonIJ9YodSjYM0te+T+vQytk+XtjYA6hEmbFkM2vM9JCb7vhuWCTCJuP+1bl wXXA79aBOfJm8jufeFG9odABmdt2SICM/6lz3bq8/awXnr4m8tIR7SBOAiQTwve/NChw JuCBzitlBUkFohgEobg04BZKvAXsy+XxTsTIEXHUmES4d4lrStFBC1FTFNi+od5x2zh3 qTQ/TpfdNXgZafbBF5Oqy4q5iHHXL1itMuxXBlPjVBnoxAjXidgXHmS2VCeK40Bcnkzn CXvlkFcBZeNqFvuDRZ4V8WojFX0sUZSD4etn8NFXFwarje9pZVybmNt9L+R5TybEMHKc Vp4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=emxgfuk55fWq+3NEXmEWPrwx8FWl1mfWjrvDV3mdGqQ=; b=w+YvjJGA9/RQVYt20Mh0AY6wkIaPXvL3csAaEIdxdkN6FmBWGSC24b/4tJFtQDnH44 j6lepO3OY63B2lBYG9oC5xk3hQzVzO4BWUTqaEbQieTTj22IuVLd1gKZt0/y3zZqmMRp d8vpEI5DLqXS66jHZkhthkXV8mkYRNH3rukuU2zUe45Eh7U+2l2lhM6+AD6D06hsXbx3 +Vd9gue50NdvuwFQi6qVfZ/3ARcIfdmq01sxTnHx7gX1IDdz5Qnf+iKxtgNIn0yoEZS8 4vL9NXok625CJw4iZMyOaAO6Fv3jNzriDSSA8KTUqTMb4qpRE/K3YBifWUwZRK3YBCsk il/g== 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 y12-v6sor4575493wrq.31.2018.09.13.14.19.40 for (Google Transport Security); Thu, 13 Sep 2018 14:19:40 -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: ANB0VdZ5ClqGf5QUAsKrHmC8lDbyk/qwiAPOwk+UkxoLQqEcaKLLQC2Xn+zT5DamwxL0X0vpebLs4w== X-Received: by 2002:a5d:448d:: with SMTP id j13-v6mr7195623wrq.236.1536873580032; Thu, 13 Sep 2018 14:19:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 14:19:39 -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 0/2] KSM replace hash algo with xxhash Date: Fri, 14 Sep 2018 00:19:21 +0300 Message-Id: <20180913211923.7696-1-timofey.titovets@synesis.ru> X-Mailer: git-send-email 2.19.0 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 Currently used jhash are slow enough and replace it allow as to make KSM less cpu hungry. About speed (in kernel): 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 In summary, the result shows that crc32c_intel has advantages over all of the hash function used in the experiment. (decreased by 84.54% compared to crc32c, 78.86% compared to jhash2, 51.33% xxhash32, 23.28% compared to xxhash64) the results are similar to those of Timofey. But, 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. So: - Fisrt patch implement compile time pickup of fastest implementation of xxhash for target platform. - Second replace jhash2 with xxhash Thanks. CC: Andrea Arcangeli CC: linux-mm@kvack.org CC: kvm@vger.kernel.org CC: leesioh Timofey Titovets (2): xxHash: create arch dependent 32/64-bit xxhash() ksm: replace jhash2 with xxhash include/linux/xxhash.h | 23 +++++++++++++ mm/Kconfig | 2 ++ mm/ksm.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 114 insertions(+), 4 deletions(-)