From a34ac68e8b6fab7df41203b8d61806087099f739 Mon Sep 17 00:00:00 2001 From: adash Date: Wed, 10 Feb 2010 02:22:03 +0000 Subject: [PATCH] add sandbox checks for excessive memory allocation and make all exponential delay variables as thread locals --- Robust/src/Runtime/DSTM/interface/dstm.h | 2 ++ Robust/src/Runtime/DSTM/interface/sandbox.c | 17 +++++++++++++++++ Robust/src/Runtime/DSTM/interface/sandbox.h | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 21 ++++++++++++++------- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index b9791968..b7913809 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -59,6 +59,8 @@ //#define SHUTDOWNINTERVAL 3 //M #define RETRYINTERVAL 100 //N (For MatrixMultiply, 2DFFT, 2DConv benchmarks) #define SHUTDOWNINTERVAL 1 //M +#define NUM_TRY_TO_COMMIT 2 +#define MEM_ALLOC_THRESHOLD 20485760//20MB #include #include diff --git a/Robust/src/Runtime/DSTM/interface/sandbox.c b/Robust/src/Runtime/DSTM/interface/sandbox.c index e42ca4ac..29e1bbd6 100644 --- a/Robust/src/Runtime/DSTM/interface/sandbox.c +++ b/Robust/src/Runtime/DSTM/interface/sandbox.c @@ -255,6 +255,7 @@ int verify(nodeElem_t *pile) { return -1; } +/* Check looping */ void checkObjects() { if (abortenabled&&checktrans()) { printf("Loop Abort\n"); @@ -269,6 +270,22 @@ void checkObjects() { transaction_check_counter=*counter_reset_pointer; } +/* Check excessive memory allocation */ +void check_mem_alloc() { + if (abortenabled&&checktrans()) { + printf("Excessive Allocation\n"); + trans_allocation_bytes=0; + transaction_check_counter=(*counter_reset_pointer=HIGH_CHECK_FREQUENCY); +#ifdef TRANSSTATS + numTransAbort++; +#endif + objstrDelete(t_cache); + t_chashDelete(); + _longjmp(aborttrans, 1); + } + trans_allocation_bytes=0; +} + /* Obtain a backtrace and print it to stdout */ void print_trace() { void *array[100]; diff --git a/Robust/src/Runtime/DSTM/interface/sandbox.h b/Robust/src/Runtime/DSTM/interface/sandbox.h index d2f5fd6b..21ff07d0 100644 --- a/Robust/src/Runtime/DSTM/interface/sandbox.h +++ b/Robust/src/Runtime/DSTM/interface/sandbox.h @@ -16,7 +16,7 @@ extern __thread jmp_buf aborttrans; extern __thread int abortenabled; extern __thread int* counter_reset_pointer; extern __thread int transaction_check_counter; - +extern __thread int trans_allocation_bytes; /* Global Variables */ #define CHECK_OBJECTS 51 diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 1eeca47f..430c12b5 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -58,9 +58,14 @@ int bigindex1=0; #endif /* Thread transaction variables */ - __thread objstr_t *t_cache; __thread struct ___Object___ *revertlist; +__thread struct timespec exponential_backoff; +__thread int count_exponential_backoff; +__thread const int max_exponential_backoff = 1000; // safety limit +__thread int trans_allocation_bytes; + + #ifdef ABORTREADERS __thread int t_abort; __thread jmp_buf aborttrans; @@ -92,10 +97,6 @@ sockPoolHashTable_t *transPrefetchSockPool; sockPoolHashTable_t *transRequestSockPool; pthread_mutex_t notifymutex; pthread_mutex_t atomicObjLock; -struct timespec exponential_backoff; -static int count_exponential_backoff = 0; -static const int max_exponential_backoff = 1000; // safety limit - /*********************************** * Global Variables for statistics @@ -553,6 +554,7 @@ void transStart() { t_cache = objstrCreate(1048576); t_chashCreate(CHASH_SIZE, CLOADFACTOR); revertlist=NULL; + trans_allocation_bytes = 0; #ifdef ABORTREADERS t_abort=0; #endif @@ -837,6 +839,11 @@ objheader_t *transCreateObj(unsigned int size) { tmp->rcount = 1; STATUS(tmp) = NEW; t_chashInsert(OID(tmp), tmp); + trans_allocation_bytes += size; + /* Validate the read set if allocation is exceeds threshold */ + if(trans_allocation_bytes > MEM_ALLOC_THRESHOLD) { + check_mem_alloc(); + } #ifdef COMPILER return &tmp[1]; //want space after object header @@ -958,8 +965,10 @@ int transCommit() { int treplyretryCount = 0; + /* Initialize timeout for exponential delay */ exponential_backoff.tv_sec = 0; exponential_backoff.tv_nsec = (long)(10000);//10 microsec + count_exponential_backoff = 0; do { treplyretry = 0; @@ -1188,10 +1197,8 @@ int transCommit() { /* Retry trans commit procedure during soft_abort case */ } while (treplyretry); - /* Reset to initial timeout for exponential delay */ exponential_backoff.tv_sec = 0; exponential_backoff.tv_nsec = (long)(10000);//10 microsec_ - count_exponential_backoff = 0; if(finalResponse == TRANS_ABORT) { #ifdef TRANSSTATS -- 2.34.1