From: Martin Quinson Date: Wed, 1 Feb 2012 15:14:36 +0000 (+0100) Subject: we don't need any stats about the amount of free chunks and such X-Git-Tag: exp_20120216~101 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/aacddcb23a4ddc3ac099fb874fc7698b5f01b4cb we don't need any stats about the amount of free chunks and such --- diff --git a/include/xbt/mmalloc.h b/include/xbt/mmalloc.h index b416105599..e03b4f451b 100644 --- a/include/xbt/mmalloc.h +++ b/include/xbt/mmalloc.h @@ -34,10 +34,6 @@ extern void *mmemalign(void *md, size_t alignment, size_t size); extern void *mvalloc(void *md, size_t size); -/* Pick up the current statistics. (see FIXME elsewhere) */ - -extern struct mstats mmstats(void *md); - extern void *mmalloc_attach(int fd, void *baseaddr); extern void mmalloc_pre_detach(void *md); @@ -48,9 +44,6 @@ extern int mmalloc_setkey(void *md, int keynum, void *key); extern void *mmalloc_getkey(void *md, int keynum); -// FIXME: this function is not implemented anymore? -//extern int mmalloc_errno (void* md); - /* return the heap used when NULL is passed as first argument to any mm* function */ extern void *mmalloc_get_default_md(void); diff --git a/src/xbt/mmalloc/mfree.c b/src/xbt/mmalloc/mfree.c index d86b0fefc1..185fe6bdb6 100644 --- a/src/xbt/mmalloc/mfree.c +++ b/src/xbt/mmalloc/mfree.c @@ -33,13 +33,6 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) type = mdp->heapinfo[block].busy.type; switch (type) { case 0: - /* Get as many statistics as early as we can. */ - mdp->heapstats.chunks_used--; - mdp->heapstats.bytes_used -= - mdp->heapinfo[block].busy.info.block.size * BLOCKSIZE; - mdp->heapstats.bytes_free += - mdp->heapinfo[block].busy.info.block.size * BLOCKSIZE; - /* Find the free cluster previous to this one in the free list. Start searching at the last block referenced; this may benefit programs with locality of allocation. */ @@ -68,7 +61,6 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) mdp->heapinfo[block].free.prev = i; mdp->heapinfo[i].free.next = block; mdp->heapinfo[mdp->heapinfo[block].free.next].free.prev = block; - mdp->heapstats.chunks_free++; } /* Now that the block is linked in, see if we can coalesce it @@ -81,7 +73,6 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) mdp->heapinfo[block].free.next = mdp->heapinfo[mdp->heapinfo[block].free.next].free.next; mdp->heapinfo[mdp->heapinfo[block].free.next].free.prev = block; - mdp->heapstats.chunks_free--; } /* Now see if we can return stuff to the system. */ @@ -106,12 +97,6 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) break; default: - /* Do some of the statistics. */ - mdp->heapstats.chunks_used--; - mdp->heapstats.bytes_used -= 1 << type; - mdp->heapstats.chunks_free++; - mdp->heapstats.bytes_free += 1 << type; - /* Get the address of the first free fragment in this block. */ prev = (struct list *) ((char *) ADDRESS(block) + @@ -133,12 +118,6 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) mdp->heapinfo[block].busy.info.block.size = 1; mdp->heapinfo[block].busy.info.block.busy_size = 0; - /* Keep the statistics accurate. */ - mdp->heapstats.chunks_used++; - mdp->heapstats.bytes_used += BLOCKSIZE; - mdp->heapstats.chunks_free -= BLOCKSIZE >> type; - mdp->heapstats.bytes_free -= BLOCKSIZE; - mfree((void *) mdp, (void *) ADDRESS(block)); } else if (mdp->heapinfo[block].busy.info.frag.nfree != 0) { /* If some fragments of this block are free, link this diff --git a/src/xbt/mmalloc/mm.c b/src/xbt/mmalloc/mm.c index ee448555f4..adc31bb646 100644 --- a/src/xbt/mmalloc/mm.c +++ b/src/xbt/mmalloc/mm.c @@ -19,7 +19,6 @@ #include "mfree.c" #include "mmalloc.c" #include "mmemalign.c" -#include "mmstats.c" #include "mrealloc.c" #include "mvalloc.c" #include "mmorecore.c" diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index 74bc4286e1..1415ad6f64 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -184,54 +184,13 @@ int mmalloc_compare_heap(void *h1, void *h2, void *std_heap_addr){ /* Heapstats */ - int errors = 0; - - struct mstats ms1 = mmstats(h1); - struct mstats ms2 = mmstats(h2); - - if(ms1.chunks_used != ms2.chunks_used){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different chunks allocated by the user : %zu - %zu", ms1.chunks_used, ms2.chunks_used); - errors++; - }else{ - return 1; - } - } - - if(ms1.bytes_used != ms2.bytes_used){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different byte total of user-allocated chunks : %zu - %zu", ms1.bytes_used, ms2.bytes_used); - errors++; - }else{ - return 1; - } - } - - if(ms1.bytes_free != ms2.bytes_free){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different byte total of chunks in the free list : %zu - %zu", ms1.bytes_free, ms2.bytes_free); - errors++; - }else{ - return 1; - } - } - - if(ms1.chunks_free != ms2.chunks_free){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different chunks in the free list : %zu - %zu", ms1.chunks_free, ms2.chunks_free); - errors++; - }else{ - return 1; - } - } - struct mdesc *mdp1, *mdp2; mdp1 = MD_TO_MDP(h1); mdp2 = MD_TO_MDP(h2); - int res = mmalloc_compare_mdesc(mdp1, mdp2, std_heap_addr); + int errors = mmalloc_compare_mdesc(mdp1, mdp2, std_heap_addr); - return ((errors + res ) > 0); + return (errors > 0); } diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index e9e8588bf1..a3d29c4d9f 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -156,11 +156,6 @@ void *mmalloc(void *md, size_t size) RESIDUAL(next->next, BLOCKSIZE) >> log; } - /* Update the statistics. */ - mdp->heapstats.chunks_used++; - mdp->heapstats.bytes_used += 1 << log; - mdp->heapstats.chunks_free--; - mdp->heapstats.bytes_free -= 1 << log; } else { /* No free fragments of the desired size, so get a new block and break it into fragments, returning the first. */ @@ -187,10 +182,6 @@ void *mmalloc(void *md, size_t size) mdp->heapinfo[block].busy.type = log; mdp->heapinfo[block].busy.info.frag.nfree = i - 1; mdp->heapinfo[block].busy.info.frag.first = i - 1; - - mdp->heapstats.chunks_free += (BLOCKSIZE >> log) - 1; - mdp->heapstats.bytes_free += BLOCKSIZE - (1 << log); - mdp->heapstats.bytes_used -= BLOCKSIZE - (1 << log); } } else { /* Large allocation to receive one or more blocks. @@ -217,7 +208,6 @@ void *mmalloc(void *md, size_t size) block = mdp->heapinfo[0].free.prev; mdp->heapinfo[block].free.size += (blocks - lastblocks); - mdp->heapstats.bytes_free += (blocks - lastblocks) * BLOCKSIZE; continue; } result = morecore(mdp, blocks * BLOCKSIZE); @@ -228,8 +218,6 @@ void *mmalloc(void *md, size_t size) mdp->heapinfo[block].busy.type = 0; mdp->heapinfo[block].busy.info.block.size = blocks; mdp->heapinfo[block].busy.info.block.busy_size = size; - mdp->heapstats.chunks_used++; - mdp->heapstats.bytes_used += blocks * BLOCKSIZE; return (result); } } @@ -256,15 +244,11 @@ void *mmalloc(void *md, size_t size) = mdp->heapinfo[block].free.prev; mdp->heapinfo[mdp->heapinfo[block].free.prev].free.next = mdp->heapindex = mdp->heapinfo[block].free.next; - mdp->heapstats.chunks_free--; } mdp->heapinfo[block].busy.type = 0; mdp->heapinfo[block].busy.info.block.size = blocks; mdp->heapinfo[block].busy.info.block.busy_size = size; - mdp->heapstats.chunks_used++; - mdp->heapstats.bytes_used += blocks * BLOCKSIZE; - mdp->heapstats.bytes_free -= blocks * BLOCKSIZE; } //printf("(%s) Done mallocing. Result is %p\n",xbt_thread_self_name(),result);fflush(stdout); return (result); diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index c122547ce6..4c9dbfdc16 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -118,20 +118,6 @@ struct list { struct list *prev; }; -/* Statistics available to the user. - FIXME: By design, the internals of the malloc package are no longer - exported to the user via an include file, so access to this data needs - to be via some other mechanism, such as mmstat_ where the - return value is the the user is interested in. */ - -struct mstats { - size_t bytes_total; /* Total size of the heap. */ - size_t chunks_used; /* Chunks allocated by the user. */ - size_t bytes_used; /* Byte total of user-allocated chunks. */ - size_t chunks_free; /* Chunks in the free list. */ - size_t bytes_free; /* Byte total of chunks in the free list. */ -}; - /* Internal structure that defines the format of the malloc-descriptor. This gets written to the base address of the region that mmalloc is managing, and thus also becomes the file header for the mapped file, @@ -180,10 +166,6 @@ struct mdesc { malloc_info *heapinfo; - /* Instrumentation. */ - - struct mstats heapstats; - /* Free list headers for each fragment size. */ /* Free lists for each fragment size. */ diff --git a/src/xbt/mmalloc/mmstats.c b/src/xbt/mmalloc/mmstats.c deleted file mode 100644 index 4342d191f9..0000000000 --- a/src/xbt/mmalloc/mmstats.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Access the statistics maintained by `mmalloc'. - Copyright 1990, 1991, 1992 Free Software Foundation - - Written May 1989 by Mike Haertel. - Modified Mar 1992 by Fred Fish. (fnf@cygnus.com) */ - -/* Copyright (c) 2010. The SimGrid Team. - * All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#include "mmprivate.h" - -/* FIXME: See the comment in mmprivate.h where struct mstats is defined. - None of the internal mmalloc structures should be externally visible - outside the library. */ - -struct mstats mmstats(void *md) -{ - struct mstats result; - struct mdesc *mdp; - - mdp = MD_TO_MDP(md); - result.bytes_total = (char *) mdp->top - (char *) mdp; - result.chunks_used = mdp->heapstats.chunks_used; - result.bytes_used = mdp->heapstats.bytes_used; - result.chunks_free = mdp->heapstats.chunks_free; - result.bytes_free = mdp->heapstats.bytes_free; - return (result); -}