The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
dymelor.h File Reference

Dynamic Memory Logger and Restorer (DyMeLoR) More...

#include <math.h>
#include <string.h>
#include <core/core.h>
#include <datatypes/bitmap.h>
#include <mm/state.h>
#include <core/timer.h>
+ Include dependency graph for dymelor.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _malloc_area
 This structure let DyMeLoR handle one malloc area (for serving given-size memory requests) More...
 
struct  _malloc_state
 Definition of the memory map. More...
 
struct  segment
 
struct  slab_header
 
struct  slab_chain
 
struct  buddy
 

Macros

#define LP_PREALLOCATION_INITIAL_ADDRESS   (void *)0x0000008000000000
 
#define MIN_CHUNK_SIZE   128U
 
#define MAX_CHUNK_SIZE   4194304
 
#define NUM_AREAS   (log2(MAX_CHUNK_SIZE) - log2(MIN_CHUNK_SIZE) + 1)
 
#define MAX_NUM_AREAS   (NUM_AREAS * 32)
 
#define MAX_LIMIT_NUM_AREAS   MAX_NUM_AREAS
 
#define MIN_NUM_CHUNKS   512
 
#define MAX_NUM_CHUNKS   4096
 
#define MAX_LOG_THRESHOLD   1.7
 
#define MIN_LOG_THRESHOLD   1.7
 
#define INCREMENTAL_GRANULARITY   50
 
#define LITTLE_SIZE   32
 
#define CHECK_SIZE   0.25
 
#define GET_CACHE_LINE_NUMBER(P)   ((unsigned long)((P >> 4) & (CACHE_SIZE - 1)))
 
#define SET_LOG_MODE_BIT(m_area)   (((malloc_area*)(m_area))->chunk_size |= (1UL << 0))
 
#define RESET_LOG_MODE_BIT(m_area)   (((malloc_area*)(m_area))->chunk_size &= ~(1UL << 0))
 
#define CHECK_LOG_MODE_BIT(m_area)   (((malloc_area*)(m_area))->chunk_size & (1UL << 0))
 
#define SET_AREA_LOCK_BIT(m_area)   (((malloc_area*)(m_area))->chunk_size |= (1UL << 1))
 
#define RESET_AREA_LOCK_BIT(m_area)   (((malloc_area*)(m_area))->chunk_size &= ~(1UL << 1))
 
#define CHECK_AREA_LOCK_BIT(m_area)   (((malloc_area*)(m_area))->chunk_size & (1UL << 1))
 
#define UNTAGGED_CHUNK_SIZE(m_area)   (((malloc_area*)(m_area))->chunk_size & ~((1UL << 0) | (1UL << 1)))
 
#define POWEROF2(x)   (1UL << (1 + (63 - __builtin_clzl((x) - 1))))
 
#define IS_POWEROF2(x)   ((x) != 0 && ((x) & ((x) - 1)) == 0)
 
#define PER_LP_PREALLOCATED_MEMORY   (262144L * PAGE_SIZE)
 
#define is_incremental(ckpt)   (((malloc_state *)ckpt)->is_incremental == true)
 
#define get_top_pointer(ptr)   ((unsigned long long *)((char *)ptr - sizeof(unsigned long long)))
 
#define get_area_top_pointer(ptr)   ( (malloc_area **)(*get_top_pointer(ptr)) )
 
#define get_area(ptr)   ( *(get_area_top_pointer(ptr)) )
 
#define PER_LP_PREALLOCATED_MEMORY   (262144L * PAGE_SIZE)
 
#define BUDDY_GRANULARITY   PAGE_SIZE
 
#define PAGE_SIZE
 
#define BUDDY_BLOCK_SIZE_EXP   12
 

Typedefs

typedef struct _malloc_area malloc_area
 
typedef struct _malloc_state malloc_state
 

Functions

void set_force_full (unsigned int, int)
 
void dirty_mem (void *, int)
 
size_t get_state_size (int)
 
size_t get_log_size (malloc_state *)
 
size_t get_inc_log_size (void *)
 
int get_granularity (void)
 
size_t dirty_size (unsigned int, void *, double *)
 
malloc_statemalloc_state_init (void)
 
void * do_malloc (struct lp_struct *, size_t)
 
void do_free (struct lp_struct *, void *ptr)
 
void * allocate_lp_memory (struct lp_struct *, size_t)
 
void free_lp_memory (struct lp_struct *, void *)
 
void * __wrap_malloc (size_t)
 
void __wrap_free (void *)
 
void * __wrap_realloc (void *, size_t)
 
void * __wrap_calloc (size_t, size_t)
 
struct buddybuddy_new (size_t requested_size)
 
void buddy_destroy (struct buddy *self)
 
void * allocate_buddy_memory (struct buddy *self, void *base_mem, size_t requested_size)
 
void free_buddy_memory (struct buddy *self, void *base_mem, void *ptr)
 

Variables

size_t __page_size
 

Detailed Description

Dynamic Memory Logger and Restorer (DyMeLoR)

LP's memory manager.

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Roberto Toccaceli
Alessandro Pellegrini
Roberto Vitali
Francesco Quaglia
Date
April 02, 2008

Definition in file dymelor.h.

Macro Definition Documentation

#define PAGE_SIZE
Value:
({ \
if(unlikely(__page_size == 0))\
__page_size = getpagesize();\
__page_size;\
})
#define unlikely(exp)
Optimize the branch as likely not taken.
Definition: core.h:74

Definition at line 148 of file dymelor.h.

Function Documentation

void* __wrap_calloc ( size_t  nmemb,
size_t  size 
)

This is the wrapper of the real stdlib calloc(). Whenever the application level software calls calloc, the call is redirected to this piece of code which relies on wrap_malloc

Author
Roberto Vitali
Parameters
nmembThe number of elements to be allocated
sizeThe size of each allocated member
Returns
A pointer to the newly allocated buffer

Definition at line 664 of file dymelor.c.

+ Here is the call graph for this function:

void __wrap_free ( void *  ptr)

This is the wrapper of the real stdlib free(). Whenever the application level software calls free, the call is redirected to this piece of code which will set the chunk in the corresponding malloc_area as not allocated.

For further information, please see the paper: R. Toccaceli, F. Quaglia DyMeLoR: Dynamic Memory Logger and Restorer Library for Optimistic Simulation Objects with Generic Memory Layout Proceedings of the 22nd Workshop on Principles of Advanced and Distributed Simulation 2008

Author
Roberto Toccaceli
Francesco Quaglia
Parameters
ptrA memory buffer to be free'd

Definition at line 589 of file dymelor.c.

+ Here is the caller graph for this function:

void* __wrap_malloc ( size_t  size)

This is the wrapper of the real stdlib malloc(). Whenever the application level software calls malloc, the call is redirected to this piece of code which uses the memory preallocated by the DyMeLoR subsystem for serving the request. If the memory in the malloc_area is exhausted, a new one is created, relying on the stdlib malloc. In future releases, this wrapper will be integrated with the Memory Management subsystem, which is not yet ready for production.

Author
Roberto Toccaceli
Francesco Quaglia
Parameters
sizeSize of the allocation
Returns
A pointer to the allocated memory

Definition at line 553 of file dymelor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* __wrap_realloc ( void *  ptr,
size_t  size 
)

This is the wrapper of the real stdlib realloc(). Whenever the application level software calls realloc, the call is redirected to this piece of code which rely on wrap_malloc

Author
Roberto Vitali
Parameters
ptrThe pointer to be buffer to be reallocated
sizeThe size of the allocation
Returns
A pointer to the newly allocated buffer

Definition at line 615 of file dymelor.c.

+ Here is the call graph for this function:

struct buddy* buddy_new ( size_t  requested_size)

allocate a new buddy structure

Parameters
lpA pointer to the lp_struct of the LP from whose buddy we are allocating memory
requested_sizesize in bytes of the memory area to manage
Returns
pointer to the allocated buddy structure

Definition at line 75 of file buddy.c.

void dirty_mem ( void *  base,
int  size 
)

This function marks a memory chunk as dirty. It is invoked from assembly modules invoked by calls injected by the instrumentor, and from the third-party library wrapper. Invocations from other parts of the kernel should be handled with great care.

Author
Alessandro Pellegrini
Roberto Vitali
Parameters
baseThe initial to the start address of the update
sizeThe number of bytes being updated

Definition at line 445 of file dymelor.c.

void* do_malloc ( struct lp_struct ,
size_t   
)

Definition at line 167 of file dymelor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t get_log_size ( malloc_state logged_state)

This function returns the whole size of a state. It can be used as the total size to pack a log

Author
Alessandro Pellegrini
Roberto Vitali
Parameters
logged_stateThe pointer to the log, or to the state
Returns
The whole size of the state (metadata included)

Definition at line 526 of file dymelor.c.

+ Here is the caller graph for this function:

malloc_state* malloc_state_init ( void  )

This function inizializes a malloc_state.

Definition at line 78 of file dymelor.c.

+ Here is the call graph for this function: