|
From: Jeremy F. <je...@go...> - 2005-02-04 22:53:34
|
CVS commit by fitzhardinge:
Defer allocating shadow memory for mappings PROT_NONE protections.
They're effectively unaddressable, so there's no need to set up shadow
memory.
Also optimises the addrcheck and memcheck mode-setting so that if
we're setting pages to be unaddressable, don't bother allocating
shadow memory for them (since absent shadow already means
unaddressable).
These help a lot with memory usage when running Valgrind under itself,
since it creates large PROT_NONE mappings, but never touches their
pages.
M +3 -4 addrcheck/ac_main.c 1.73
M +8 -6 coregrind/vg_syscalls.c 1.241
M +2 -0 memcheck/mac_shared.h 1.29
M +3 -4 memcheck/mc_main.c 1.59
--- valgrind/coregrind/vg_syscalls.c #1.240:1.241
@@ -173,5 +173,4 @@ static
void mmap_segment ( Addr a, SizeT len, UInt prot, UInt mm_flags, Int fd, ULong offset )
{
- Bool rr, ww, xx;
UInt flags;
@@ -189,4 +188,6 @@ void mmap_segment ( Addr a, SizeT len, U
VG_(map_fd_segment)(a, len, prot, flags, fd, offset, NULL);
+ if (prot != VKI_PROT_NONE) {
+ Bool rr, ww, xx;
rr = prot & VKI_PROT_READ;
ww = prot & VKI_PROT_WRITE;
@@ -194,4 +195,5 @@ void mmap_segment ( Addr a, SizeT len, U
VG_TRACK( new_mem_mmap, a, len, rr, ww, xx );
+ }
}
--- valgrind/memcheck/mc_main.c #1.58:1.59
@@ -351,7 +351,8 @@ static void set_address_range_perms ( Ad
/* Once aligned, go fast. */
- while (True) {
+ for (; len >= 8; a += 8, len -= 8) {
PROF_EVENT(32);
- if (len < 8) break;
+ if (abyte8 == VGM_BYTE_INVALID && !IS_MAPPABLE(a))
+ continue;
ENSURE_MAPPABLE(a, "set_address_range_perms(fast)");
sm = primary_map[a >> 16];
@@ -360,6 +361,4 @@ static void set_address_range_perms ( Ad
((UInt*)(sm->vbyte))[(sm_off >> 2) + 0] = vword4;
((UInt*)(sm->vbyte))[(sm_off >> 2) + 1] = vword4;
- a += 8;
- len -= 8;
}
--- valgrind/memcheck/mac_shared.h #1.28:1.29
@@ -196,4 +196,6 @@ extern UInt MAC_(event_ctr)[N_PROF_EVENT
((smap) == &distinguished_secondary_map)
+#define IS_MAPPABLE(addr) (!(IS_DISTINGUISHED_SM(primary_map[(addr) >> 16])))
+
#define ENSURE_MAPPABLE(addr,caller) \
do { \
--- valgrind/addrcheck/ac_main.c #1.72:1.73
@@ -321,13 +321,12 @@ void set_address_range_perms ( Addr a, S
/* Once aligned, go fast. */
- while (True) {
+ for (; len >= 8; a += 8, len -= 8) {
PROF_EVENT(32);
- if (len < 8) break;
+ if (abyte8 == VGM_BYTE_INVALID && !IS_MAPPABLE(a))
+ continue;
ENSURE_MAPPABLE(a, "set_address_range_perms(fast)");
sm = primary_map[a >> 16];
sm_off = a & 0xFFFF;
sm->abits[sm_off >> 3] = abyte8;
- a += 8;
- len -= 8;
}
|