From: Julian Seward Date: Fri, 30 Nov 2007 17:19:36 +0000 (+0000) Subject: Make the freed-block-queue volume metrics 64-bit throughout, to avoid X-Git-Tag: svn/VALGRIND_3_3_0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=755bc0ea22bcc26078048d117c487126116b0c1a;p=thirdparty%2Fvalgrind.git Make the freed-block-queue volume metrics 64-bit throughout, to avoid any wierdness on very large machines in the future. Also, double the default size from 5MB to 10MB, on the basis that programs are now on average twice as lardy as they were when it was set to 5MB, whenever that was. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7256 --- diff --git a/memcheck/docs/mc-manual.xml b/memcheck/docs/mc-manual.xml index f8444c76a2..3ddcc2bbd8 100644 --- a/memcheck/docs/mc-manual.xml +++ b/memcheck/docs/mc-manual.xml @@ -122,7 +122,7 @@ the following problems: - + When the client program releases memory using @@ -137,7 +137,7 @@ the following problems: have been freed. This flag specifies the maximum total size, in bytes, of the - blocks in the queue. The default value is five million bytes. + blocks in the queue. The default value is ten million bytes. Increasing this increases the total amount of memory used by memcheck but may detect invalid uses of freed blocks which would otherwise go undetected. diff --git a/memcheck/mc_include.h b/memcheck/mc_include.h index fb4cfb7bb0..c731271f18 100644 --- a/memcheck/mc_include.h +++ b/memcheck/mc_include.h @@ -255,7 +255,7 @@ extern Bool MC_(record_leak_error) ( ThreadId tid, extern Bool MC_(clo_partial_loads_ok); /* Max volume of the freed blocks queue. */ -extern SSizeT MC_(clo_freelist_vol); +extern Long MC_(clo_freelist_vol); /* Do leak check at exit? default: NO */ extern LeakCheckMode MC_(clo_leak_check); diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index bc9f2e7af9..b24039c9b0 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -4367,7 +4367,7 @@ static Bool mc_expensive_sanity_check ( void ) /*------------------------------------------------------------*/ Bool MC_(clo_partial_loads_ok) = False; -SSizeT MC_(clo_freelist_vol) = 5000000; +Long MC_(clo_freelist_vol) = 10*1000*1000LL; LeakCheckMode MC_(clo_leak_check) = LC_Summary; VgRes MC_(clo_leak_resolution) = Vg_LowRes; Bool MC_(clo_show_reachable) = False; @@ -4382,7 +4382,8 @@ static Bool mc_process_cmd_line_options(Char* arg) else VG_BOOL_CLO(arg, "--undef-value-errors", MC_(clo_undef_value_errors)) - else VG_BNUM_CLO(arg, "--freelist-vol", MC_(clo_freelist_vol), 0, 1000000000) + else VG_BNUM_CLO(arg, "--freelist-vol", MC_(clo_freelist_vol), + 0, 10*1000*1000*1000LL) else if (VG_CLO_STREQ(arg, "--leak-check=no")) MC_(clo_leak_check) = LC_Off; @@ -4442,7 +4443,7 @@ static void mc_print_usage(void) " --show-reachable=no|yes show reachable blocks in leak check? [no]\n" " --undef-value-errors=no|yes check for undefined value errors [yes]\n" " --partial-loads-ok=no|yes too hard to explain here; see manual [no]\n" -" --freelist-vol= volume of freed blocks queue [5000000]\n" +" --freelist-vol= volume of freed blocks queue [10000000]\n" " --workaround-gcc296-bugs=no|yes self explanatory [no]\n" " --ignore-ranges=0xPP-0xQQ[,0xRR-0xSS] assume given addresses are OK\n" ); diff --git a/memcheck/mc_malloc_wrappers.c b/memcheck/mc_malloc_wrappers.c index aa9c68815f..4fd9aec93a 100644 --- a/memcheck/mc_malloc_wrappers.c +++ b/memcheck/mc_malloc_wrappers.c @@ -71,22 +71,27 @@ VgHashTable MC_(mempool_list) = NULL; /* Records blocks after freeing. */ static MC_Chunk* freed_list_start = NULL; static MC_Chunk* freed_list_end = NULL; -static SSizeT freed_list_volume = 0; +static Long freed_list_volume = 0; /* Put a shadow chunk on the freed blocks queue, possibly freeing up some of the oldest blocks in the queue at the same time. */ static void add_to_freed_queue ( MC_Chunk* mc ) { + const Bool show = False; + /* Put it at the end of the freed list */ if (freed_list_end == NULL) { tl_assert(freed_list_start == NULL); freed_list_end = freed_list_start = mc; - freed_list_volume = mc->szB; + freed_list_volume = (Long)mc->szB; } else { tl_assert(freed_list_end->next == NULL); freed_list_end->next = mc; freed_list_end = mc; - freed_list_volume += mc->szB; + freed_list_volume += (Long)mc->szB; + if (show) + VG_(printf)("mc_freelist: acquire: volume now %lld\n", + freed_list_volume); } mc->next = NULL; @@ -100,8 +105,10 @@ static void add_to_freed_queue ( MC_Chunk* mc ) tl_assert(freed_list_end != NULL); mc1 = freed_list_start; - freed_list_volume -= mc1->szB; - /* VG_(printf)("volume now %d\n", freed_list_volume); */ + freed_list_volume -= (Long)mc1->szB; + if (show) + VG_(printf)("mc_freelist: discard: volume now %lld\n", + freed_list_volume); tl_assert(freed_list_volume >= 0); if (freed_list_start == freed_list_end) { @@ -174,7 +181,6 @@ static Bool complain_about_silly_args2(SizeT n, SizeT sizeB) } /* Allocate memory and note change in memory available */ -__inline__ void* MC_(new_block) ( ThreadId tid, Addr p, SizeT szB, SizeT alignB, UInt rzB, Bool is_zeroed, MC_AllocKind kind, VgHashTable table) @@ -278,7 +284,6 @@ void die_and_free_mem ( ThreadId tid, MC_Chunk* mc, SizeT rzB ) } } -__inline__ void MC_(handle_free) ( ThreadId tid, Addr p, UInt rzB, MC_AllocKind kind ) { MC_Chunk* mc;