From: Timofey Titovets <[email protected]>

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/[email protected]
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: leesioh <[email protected]>
Reviewed-by: Pavel Tatashin <[email protected]>
Reviewed-by: Mike Rapoport <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Kirill Tkhai <[email protected]>
---
 mm/Kconfig |    1 +
 mm/ksm.c   |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index d22a5c8d75e2..f5c611b8a342 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -340,6 +340,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 53316ae8057c..1fb8051b22e4 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -23,7 +23,7 @@
 #include <linux/pagemap.h>
 #include <linux/rmap.h>
 #include <linux/spinlock.h>
-#include <linux/jhash.h>
+#include <linux/xxhash.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
 #include <linux/wait.h>
@@ -998,7 +998,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;
 }

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to