perf, tools, bench: Fix memcpy benchmark for large sizes
A message that is not in the archive (sent off-list or not yet received): [email protected]
Kirill A. Shutemov
Acked-byQuoted 6 lines · Andi Kleen
From: Andi Kleen <[email protected]>
glibc
calloc()has an optimization to not explicitelymemset()very large calloc allocations that just came frommmap(), because they are known to be zero.
Quoted 8 lines
This could result in the perf memcpy benchmark reading only from the zero page, which gives unrealistic results.
Always call memset explicitly on the source area to avoid this problem.
Quoted 19 lines
--- tools/perf/bench/mem-memcpy.c | 2 ++ 1 file changed, 2 insertions(+)tools/perf/bench/mem-memcpy.c +2
-0@@ -117,6 +117,8 @@ static void alloc_mem(void **dst, void **src, size_t length) *src =zalloc (length);if (!src)die ("memory allocation failed - maybe length is too large?\n" ); +/* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */ +memset (src,0 , length); }static u64 do_memcpy_cycle (memcpy_t fn,size_t len,bool prefault)Signature · 1 line
1.8.1.4
Signature · 1 line
Kirill A. Shutemov
Hitoshi Mitake
Acked-byAt Mon, 15 Jul 2013 11:15:32 +0300 (EEST),
Quoted 11 lines · Kirill A. Shutemov
Quoted 9 lines · Andi Kleen
From: Andi Kleen <[email protected]>
glibc
calloc()has an optimization to not explicitelymemset()very large calloc allocations that just came frommmap(), because they are known to be zero.This could result in the perf memcpy benchmark reading only from the zero page, which gives unrealistic results.
Quoted 7 lines
Quoted 5 lines
Always call memset explicitly on the source area to avoid this problem.
Thanks for this fix, Andi.
Quoted 28 lines
Quoted 20 lines
--- tools/perf/bench/mem-memcpy.c | 2 ++ 1 file changed, 2 insertions(+)tools/perf/bench/mem-memcpy.c +2
-0@@ -117,6 +117,8 @@ static void alloc_mem(void **dst, void **src, size_t length) *src =zalloc (length);if (!src)die ("memory allocation failed - maybe length is too large?\n" ); +/* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */ +memset (src,0 , length); }static u64 do_memcpy_cycle (memcpy_t fn,size_t len,bool prefault)Signature · 1 line
1.8.1.4Signature · 6 lines
Kirill A. Shutemov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Quoted 23 lines · Andi Kleen
From: Andi Kleen <[email protected]>
glibc
calloc()has an optimization to not explicitelymemset()very large calloc allocations that just came frommmap(), because they are known to be zero.This could result in the perf memcpy benchmark reading only from the zero page, which gives unrealistic results.
Always call memset explicitly on the source area to avoid this problem.
--- tools/perf/bench/mem-memcpy.c | 2 ++ 1 file changed, 2 insertions(+)tools/perf/bench/mem-memcpy.c +0
-0
tools/perf/bench/mem-memcpy.c static void alloc_mem(void **dst, void **src, size_t length) · line 121
Quoted 5 lines
tools/perf/bench/mem-memcpy.c +2
-0@@ -117,6 +117,8 @@ static void alloc_mem(void **dst, void **src, size_t length) *src =zalloc (length);if (!src)die ("memory allocation failed - maybe length is too large?\n" ); +/* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */ +memset (src,0 , length);
It should be memset(*src, 0, length) instead.
There's fix for wrong memory allocation fail check in v3.11-rc1.
Signature · 1 line
Kirill A. Shutemov
At Tue, 16 Jul 2013 13:11:00 +0300 (EEST),
Quoted 33 lines · Kirill A. Shutemov
Quoted 23 lines · Andi Kleen
From: Andi Kleen <[email protected]>
glibc
calloc()has an optimization to not explicitelymemset()very large calloc allocations that just came frommmap(), because they are known to be zero.This could result in the perf memcpy benchmark reading only from the zero page, which gives unrealistic results.
Always call memset explicitly on the source area to avoid this problem.
--- tools/perf/bench/mem-memcpy.c | 2 ++ 1 file changed, 2 insertions(+)tools/perf/bench/mem-memcpy.c +0
-0tools/perf/bench/mem-memcpy.c static void alloc_mem(void **dst, void **src, size_t length) · line 121
Quoted 5 lines
tools/perf/bench/mem-memcpy.c +2
-0@@ -117,6 +117,8 @@ static void alloc_mem(void **dst, void **src, size_t length) *src =zalloc (length);if (!src)die ("memory allocation failed - maybe length is too large?\n" ); +/* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */ +memset (src,0 , length);It should be
memset(*src, 0, length)instead.
Quoted 1 line
There's fix for wrong memory allocation fail check in v3.11-rc1.
I couldn't catch it, thanks. The memset() should be fixed.
Thanks,
Hitoshi
Quoted 8 lines
Review static void alloc_mem(void **dst, void **src, size_t length) · line 121
Quoted 6 lines
(quoted diff) +2
-0@@ -117,6 +117,8 @@ static void alloc_mem(void **dst, void **src, size_t length) *src = zalloc(length); if (!src) die("memory allocation failed - maybe length is too large?\n"); + /* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */ + memset(src, 0, length);It should be
memset(*src, 0, length)instead.
Thanks for catching. I wonder why it fixed the problem for me.
Quoted 1 line
There's fix for wrong memory allocation fail check in v3.11-rc1.
Doubt it matters.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only