Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : add stats in mmalloc
[simgrid.git] / src / xbt / mmalloc / mmprivate.h
index 507a27d..d0eb81c 100644 (file)
@@ -53,7 +53,8 @@
  * need to enlist the free fragments.
  */
 
-#define SMALLEST_POSSIBLE_MALLOC (sizeof(struct list))
+//#define SMALLEST_POSSIBLE_MALLOC (sizeof(struct list))
+#define SMALLEST_POSSIBLE_MALLOC (16*sizeof(struct list))
 #define MAX_FRAGMENT_PER_BLOCK (BLOCKSIZE / SMALLEST_POSSIBLE_MALLOC)
 
 /* The difference between two pointers is a signed int.  On machines where
@@ -95,6 +96,16 @@ struct list {
   struct list *prev;
 };
 
+/* Statistics available to the user. */
+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. */
+};
+
 /* Data structure giving per-block information.
  *
  * There is one such structure in the mdp->heapinfo array per block used in that heap,
@@ -131,7 +142,7 @@ typedef struct {
       size_t nfree;           /* Free fragments in a fragmented block.  */
       size_t first;           /* First free fragment of the block.  */
       unsigned short frag_size[MAX_FRAGMENT_PER_BLOCK];
-      //void *bt[XBT_BACKTRACE_SIZE][MAX_FRAGMENT_PER_BLOCK]; /* Where it was malloced (or realloced lastly) */
+      void *bt[MAX_FRAGMENT_PER_BLOCK][XBT_BACKTRACE_SIZE]; /* Where it was malloced (or realloced lastly) */
     } busy_frag;
     struct {
       size_t size; /* Size (in blocks) of a large cluster.  */
@@ -221,12 +232,18 @@ struct mdesc {
 
   int fd;
 
+  /* Instrumentation.  */
+
+  struct mstats heapstats;
+
 };
 
 int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2);
 
 void mmalloc_display_info(void *h);
 
+//void *get_end_addr_heap(void *s_heap);
+
 /* Bits to look at in the malloc descriptor flags word */
 
 #define MMALLOC_DEVZERO                (1 << 0)        /* Have mapped to /dev/zero */