提交 ac7353e5 编写于 作者: T Timofey Titovets 提交者: Xie XiuQi

ksm: replace jhash2 with xxhash

mainline inclusion
from mainline-5.0-rc1
commit 59e1a2f4bf83744e748636415fde7d1e9f557e05
category: performance
bugzilla: 13231
CVE: NA

------------------------------------------------

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

Sioh Lee did some testing:

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 requires some tricky solution to work well in all
situations.

Link: http://lkml.kernel.org/r/20181023182554.23464-3-nefelim4ag@gmail.comSigned-off-by: NTimofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Nleesioh <solee@os.korea.ac.kr>
Reviewed-by: NPavel Tatashin <pavel.tatashin@microsoft.com>
Reviewed-by: NMike Rapoport <rppt@linux.vnet.ibm.com>
Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Nzhong jiang <zhongjiang@huawei.com>
Signed-off-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 b41feb0c
...@@ -307,6 +307,7 @@ config MMU_NOTIFIER ...@@ -307,6 +307,7 @@ config MMU_NOTIFIER
config KSM config KSM
bool "Enable KSM for page merging" bool "Enable KSM for page merging"
depends on MMU depends on MMU
select XXHASH
help help
Enable Kernel Samepage Merging: KSM periodically scans those areas Enable Kernel Samepage Merging: KSM periodically scans those areas
of an application's address space that an app has advised may be of an application's address space that an app has advised may be
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/rmap.h> #include <linux/rmap.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/jhash.h> #include <linux/xxhash.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/wait.h> #include <linux/wait.h>
...@@ -1024,7 +1024,7 @@ static u32 calc_checksum(struct page *page) ...@@ -1024,7 +1024,7 @@ static u32 calc_checksum(struct page *page)
{ {
u32 checksum; u32 checksum;
void *addr = kmap_atomic(page); void *addr = kmap_atomic(page);
checksum = jhash2(addr, PAGE_SIZE / 4, 17); checksum = xxhash(addr, PAGE_SIZE, 0);
kunmap_atomic(addr); kunmap_atomic(addr);
return checksum; return checksum;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册