Fix massif --pages-as-heap=yes does not report peak caused by mmap+munmap

ms_unrecord_page_mem was wrongly taking the (possible) peak snapshot
when unrecording the last block.
But the peak snapshot will be detected when unrecording the first block
of an munmap, not when unrecording the last block.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15745
This commit is contained in:
Philippe Waroquiers 2015-12-10 22:37:59 +00:00
parent 95bd519438
commit 58ba63b7df
7 changed files with 31 additions and 2 deletions

3
NEWS
View File

@ -52,11 +52,12 @@ where XXXXXX is the bug number as listed below.
354797 Added vbit tester support for PPC 64 isa 2.07 iops
354933 Fix documentation of --kernel-variant=android-no-hw-tls option
355188 valgrind should intercept all malloc related global functions
355455 expected stderr of test cases wrapmalloc and wrapmallocstatic overconstrained
355455 stderr.exp of test cases wrapmalloc and wrapmallocstatic overconstrained
355454 do not intercept malloc related symbols from the runtime linker
356044 Dwarf line info reader misinterprets is_stmt register
n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 32 bits
n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap
Release 3.11.0 (22 September 2015)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1816,10 +1816,13 @@ void ms_unrecord_page_mem( Addr a, SizeT len )
Addr end;
tl_assert(VG_IS_PAGE_ALIGNED(len));
tl_assert(len >= VKI_PAGE_SIZE);
// Unrecord the first page. This might be the peak, so do a snapshot.
unrecord_block((void*)a, /*maybe_snapshot*/True);
a += VKI_PAGE_SIZE;
// Then unrecord the remaining pages, but without snapshots.
for (end = a + len - VKI_PAGE_SIZE; a < end; a += VKI_PAGE_SIZE) {
unrecord_block((void*)a, /*maybe_snapshot*/False);
}
unrecord_block((void*)a, /*maybe_snapshot*/True);
}
//------------------------------------------------------------//

View File

@ -24,6 +24,7 @@ EXTRA_DIST = \
long-names.post.exp long-names.stderr.exp long-names.vgtest \
long-time.post.exp long-time.stderr.exp long-time.vgtest \
malloc_usable.stderr.exp malloc_usable.vgtest \
mmapunmap.post.exp mmapunmap.stderr.exp mmapunmap.vgtest \
new-cpp.post.exp new-cpp.stderr.exp new-cpp.vgtest \
no-stack-no-heap.post.exp no-stack-no-heap.stderr.exp no-stack-no-heap.vgtest \
null.post.exp null.stderr.exp null.vgtest \
@ -61,6 +62,7 @@ check_PROGRAMS = \
insig \
long-names \
long-time \
mmapunmap \
malloc_usable \
new-cpp \
null \

16
massif/tests/mmapunmap.c Normal file
View File

@ -0,0 +1,16 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "tests/sys_mman.h"
int main()
{
void *m;
m = mmap(NULL, 80 * 1000 * 1024,
PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0);
munmap(m, 80 * 1000 * 1024);
return 0;
}

View File

@ -0,0 +1 @@
n0: 81920000 0x........: main (mmapunmap.c:11)

View File

View File

@ -0,0 +1,6 @@
prog: mmapunmap
vgopts: --pages-as-heap=yes --threshold=30.0 -q
vgopts: --stacks=no --time-unit=B --depth=8 --massif-out-file=massif.out
vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element
post: grep -A3 -e =peak massif.out | grep -e 'main (mmapunmap.c:11)' | ../../tests/filter_addresses
# cleanup: rm massif.out