Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
we don't need any stats about the amount of free chunks and such
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 1 Feb 2012 15:14:36 +0000 (16:14 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 1 Feb 2012 15:14:36 +0000 (16:14 +0100)
include/xbt/mmalloc.h
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mm.c
src/xbt/mmalloc/mm_legacy.c
src/xbt/mmalloc/mmalloc.c
src/xbt/mmalloc/mmprivate.h
src/xbt/mmalloc/mmstats.c [deleted file]

index b416105..e03b4f4 100644 (file)
@@ -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);
 
index d86b0fe..185fe6b 100644 (file)
@@ -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
index ee44855..adc31bb 100644 (file)
@@ -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"
index 74bc428..1415ad6 100644 (file)
@@ -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);
 
 }
 
index e9e8588..a3d29c4 100644 (file)
@@ -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);
index c122547..4c9dbfd 100644 (file)
@@ -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_<something> where the
-   return value is the <something> 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 (file)
index 4342d19..0000000
+++ /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);
-}