You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2016/10/05 17:07:25 UTC

[1/2] incubator-mnemonic git commit: MNEMONIC-136: Upgrade commons-resgc to v0.8.10 MNEMONIC-135: Refactor function/structure names of pmalloc service MNEMONIC-134: Not used write locker to guard close()/fini() MNEMONIC-133: Make some common functions in

Repository: incubator-mnemonic
Updated Branches:
  refs/heads/master 8b91fcec4 -> 404502bee


MNEMONIC-136: Upgrade commons-resgc to v0.8.10
MNEMONIC-135: Refactor function/structure names of pmalloc service
MNEMONIC-134: Not used write locker to guard close()/fini()
MNEMONIC-133: Make some common functions inline


Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/3c22e177
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/3c22e177
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/3c22e177

Branch: refs/heads/master
Commit: 3c22e17799967b2817b50014c65cd08cc40b960b
Parents: 8b91fce
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Mon Oct 3 13:15:34 2016 -0700
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Wed Oct 5 09:26:45 2016 -0700

----------------------------------------------------------------------
 .../src/main/native/common.c                    |   9 +-
 ...ice_memoryservice_internal_PMemServiceImpl.c |   2 +
 .../src/main/native/common.c                    |   9 +-
 ...ice_memoryservice_internal_VMemServiceImpl.c |   4 +-
 .../src/main/native/common.c                    |  15 +-
 .../src/main/native/common.h                    |   8 +-
 ..._memoryservice_internal_PMallocServiceImpl.c | 180 ++++++++++---------
 pom.xml                                         |   2 +-
 8 files changed, 122 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/common.c b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/common.c
index 9a20fcc..98a5e8e 100644
--- a/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/common.c
+++ b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/common.c
@@ -26,7 +26,8 @@
  *  Throws a RuntimeException, with either an explicit message or the message
  *  corresponding to the current system error value.
  */
-void throw(JNIEnv* env, const char* msg) {
+inline void
+throw(JNIEnv* env, const char* msg) {
   if (msg == NULL)
     msg = sys_errlist[errno];
 
@@ -34,7 +35,8 @@ void throw(JNIEnv* env, const char* msg) {
   (*env)->ThrowNew(env, xklass, msg);
 }
 
-void* addr_from_java(jlong addr) {
+inline void*
+addr_from_java(jlong addr) {
   // This assert fails in a variety of ways on 32-bit systems.
   // It is impossible to predict whether native code that converts
   // pointers to longs will sign-extend or zero-extend the addresses.
@@ -42,7 +44,8 @@ void* addr_from_java(jlong addr) {
   return (void*) (uintptr_t) addr;
 }
 
-jlong addr_to_java(void* p) {
+inline jlong
+addr_to_java(void* p) {
   assert(p == (void*) (uintptr_t) p);
   return (long) (uintptr_t) p;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMemServiceImpl.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMemServiceImpl.c b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMemServiceImpl.c
index f7ade7e..7597f30 100644
--- a/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMemServiceImpl.c
+++ b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMemServiceImpl.c
@@ -387,6 +387,7 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMemService
 __attribute__((destructor)) void fini(void) {
   int i;
   PMPool *pool;
+  pthread_rwlock_wrlock(&g_pmp_rwlock);
   if (NULL != g_pmpool_arr) {
     for (i = 0; i < g_pmpool_count; ++i) {
       pool = g_pmpool_arr + i;
@@ -402,5 +403,6 @@ __attribute__((destructor)) void fini(void) {
     g_pmpool_arr = NULL;
     g_pmpool_count = 0;
   }
+  pthread_rwlock_unlock(&g_pmp_rwlock);
   pthread_rwlock_destroy(&g_pmp_rwlock);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
index ca060df..2fa660a 100644
--- a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
+++ b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
@@ -26,7 +26,8 @@
  *  Throws a RuntimeException, with either an explicit message or the message
  *  corresponding to the current system error value.
  */
-void throw(JNIEnv* env, const char* msg) {
+inline void
+throw(JNIEnv* env, const char* msg) {
   if (msg == NULL)
     msg = sys_errlist[errno];
 
@@ -34,7 +35,8 @@ void throw(JNIEnv* env, const char* msg) {
   (*env)->ThrowNew(env, xklass, msg);
 }
 
-void* addr_from_java(jlong addr) {
+inline void*
+addr_from_java(jlong addr) {
   // This assert fails in a variety of ways on 32-bit systems.
   // It is impossible to predict whether native code that converts
   // pointers to longs will sign-extend or zero-extend the addresses.
@@ -42,7 +44,8 @@ void* addr_from_java(jlong addr) {
   return (void*) (uintptr_t) addr;
 }
 
-jlong addr_to_java(void* p) {
+inline jlong
+addr_to_java(void* p) {
   assert(p == (void*) (uintptr_t) p);
   return (long) (uintptr_t) p;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_VMemServiceImpl.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_VMemServiceImpl.c b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_VMemServiceImpl.c
index 8be1721..63ffe4c 100644
--- a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_VMemServiceImpl.c
+++ b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_VMemServiceImpl.c
@@ -245,7 +245,7 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_VMemService
 (JNIEnv *env, jobject this, jlong id)
 {
   VMPool *pool;
-  pthread_rwlock_rdlock(&g_vmem_rwlock);
+  pthread_rwlock_wrlock(&g_vmem_rwlock);
   pool = g_vmpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   if (NULL != pool->vmp) {
@@ -260,6 +260,7 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_VMemService
 __attribute__((destructor)) void fini(void) {
   int i;
   VMPool *pool;
+  pthread_rwlock_wrlock(&g_vmem_rwlock);
   if (NULL != g_vmpool_arr) {
     for (i = 0; i < g_vmpool_count; ++i) {
       pool = g_vmpool_arr + i;
@@ -273,5 +274,6 @@ __attribute__((destructor)) void fini(void) {
     g_vmpool_arr = NULL;
     g_vmpool_count = 0;
   }
+  pthread_rwlock_unlock(&g_vmem_rwlock);
   pthread_rwlock_destroy(&g_vmem_rwlock);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
index 7f7a157..b5e5a9a 100644
--- a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
+++ b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
@@ -26,7 +26,8 @@
  *  Throws a RuntimeException, with either an explicit message or the message
  *  corresponding to the current system error value.
  */
-void throw(JNIEnv* env, const char* msg) {
+inline void
+throw(JNIEnv* env, const char* msg) {
   if (msg == NULL)
     msg = sys_errlist[errno];
 
@@ -34,7 +35,8 @@ void throw(JNIEnv* env, const char* msg) {
   (*env)->ThrowNew(env, xklass, msg);
 }
 
-void* addr_from_java(jlong addr) {
+inline void*
+addr_from_java(jlong addr) {
   // This assert fails in a variety of ways on 32-bit systems.
   // It is impossible to predict whether native code that converts
   // pointers to longs will sign-extend or zero-extend the addresses.
@@ -42,13 +44,14 @@ void* addr_from_java(jlong addr) {
   return (void*) (uintptr_t) addr;
 }
 
-jlong addr_to_java(void* p) {
+inline jlong
+addr_to_java(void* p) {
   assert(p == (void*) (uintptr_t) p);
   return (long) (uintptr_t) p;
 }
 
 inline void *
-prealloc(PMPool *pool, void *p, size_t size, int initzero) {
+pmalrealloc(PMALPool *pool, void *p, size_t size, int initzero) {
   void *ret = NULL;
   void *nativebuf = NULL;
   if (NULL == p) {
@@ -68,14 +71,14 @@ prealloc(PMPool *pool, void *p, size_t size, int initzero) {
 }
 
 inline void
-pfree(PMPool *pool, void *p) {
+pmalfree(PMALPool *pool, void *p) {
   if (p != NULL) {
     pmfree(pool->pmp, p);
   }
 }
 
 inline size_t
-psize(PMPool *pool, void *p) {
+pmalsize(PMALPool *pool, void *p) {
   size_t ret = 0;
   void* nativebuf;
   if (p != NULL) {

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.h
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.h b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.h
index c4316ff..449a851 100644
--- a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.h
+++ b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.h
@@ -54,13 +54,13 @@ typedef struct {
   void *pmp;
   size_t capacity;
   pthread_mutex_t mutex;
-} PMPool;
+} PMALPool;
 
-void *prealloc(PMPool *pool, void *p, size_t size, int initzero);
+void *pmalrealloc(PMALPool *pool, void *p, size_t size, int initzero);
 
-void pfree(PMPool *pool, void *p);
+void pmalfree(PMALPool *pool, void *p);
 
-size_t psize(PMPool *pool, void *p);
+size_t pmalsize(PMALPool *pool, void *p);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl.c b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl.c
index 8a8e23c..d26192b 100644
--- a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl.c
+++ b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl.c
@@ -18,10 +18,10 @@
 
 #include "org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl.h"
 
-static PMPool *g_pmpool_arr = NULL;
-static size_t g_pmpool_count = 0;
+static PMALPool *g_pmalpool_arr = NULL;
+static size_t g_pmalpool_count = 0;
 
-static pthread_rwlock_t g_pmp_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_rwlock_t g_pmalp_rwlock = PTHREAD_RWLOCK_INITIALIZER;
 
 /******************************************************************************
  ** JNI implementations
@@ -30,28 +30,28 @@ static pthread_rwlock_t g_pmp_rwlock = PTHREAD_RWLOCK_INITIALIZER;
 JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nallocate(JNIEnv* env,
     jobject this, jlong id, jlong size, jboolean initzero) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
-  void* nativebuf = prealloc(pool, NULL, size, initzero);
+  void* nativebuf = pmalrealloc(pool, NULL, size, initzero);
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return addr_to_java(nativebuf);
 }
 
 JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nreallocate(JNIEnv* env,
     jobject this, jlong id, jlong addr, jlong size, jboolean initzero) {
-  PMPool *pool;
+  PMALPool *pool;
   void* nativebuf = NULL;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   void* p = addr_from_java(addr);
-  nativebuf = prealloc(pool, p, size, initzero);
+  nativebuf = pmalrealloc(pool, p, size, initzero);
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return addr_to_java(nativebuf);
 }
 
@@ -60,24 +60,24 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServ
     JNIEnv* env,
     jobject this, jlong id,
     jlong addr) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   void* nativebuf = addr_from_java(addr);
-  pfree(pool, nativebuf);
+  pmalfree(pool, nativebuf);
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 JNIEXPORT
 void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nsync(
     JNIEnv* env,
     jobject this, jlong id, jlong addr, jlong len, jboolean autodetect) {
-  PMPool *pool;
+  PMALPool *pool;
   void *nativebuf;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   void *p = addr_from_java(addr);
   if (autodetect) {
     if (NULL != p) {
@@ -91,17 +91,17 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServ
       pmsync(pool->pmp, p, len);
     }
   }
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 JNIEXPORT
 void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_npersist(
     JNIEnv* env,
     jobject this, jlong id, jlong addr, jlong len, jboolean autodetect) {
-  PMPool *pool;
+  PMALPool *pool;
   void *nativebuf;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   void *p = addr_from_java(addr);
   if (autodetect) {
     if (NULL != p) {
@@ -115,17 +115,17 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServ
       pmsync(pool->pmp, p, len);
     }
   }
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 JNIEXPORT
 void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nflush(
     JNIEnv* env,
     jobject this, jlong id, jlong addr, jlong len, jboolean autodetect) {
-  PMPool *pool;
+  PMALPool *pool;
   void *nativebuf;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   void *p = addr_from_java(addr);
   if (autodetect) {
     if (NULL != p) {
@@ -139,7 +139,7 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServ
       pmsync(pool->pmp, p, len);
     }
   }
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 JNIEXPORT
@@ -153,28 +153,28 @@ JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_ncapacity(
     JNIEnv* env,
     jobject this, jlong id) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   jlong ret = pool->capacity;
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
 JNIEXPORT
 jobject JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_ncreateByteBuffer(
     JNIEnv *env, jobject this, jlong id, jlong size) {
-  PMPool *pool;
+  PMALPool *pool;
   jobject ret = NULL;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
-  void* nativebuf = prealloc(pool, NULL, size, 0);
+  void* nativebuf = pmalrealloc(pool, NULL, size, 0);
   if (NULL != nativebuf) {
     ret = (*env)->NewDirectByteBuffer(env, nativebuf, size);
   }
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
@@ -193,12 +193,12 @@ jobject JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocS
 JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nretrieveSize(JNIEnv *env,
     jobject this, jlong id, jlong addr) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   void* p = addr_from_java(addr);
-  jlong ret = psize(pool, p);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  jlong ret = pmalsize(pool, p);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
@@ -219,64 +219,64 @@ jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocSer
 JNIEXPORT
 jobject JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nresizeByteBuffer(
     JNIEnv *env, jobject this, jlong id, jobject bytebuf, jlong size) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   jobject ret = NULL;
   if (NULL != bytebuf) {
     void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
     if (nativebuf != NULL) {
-      nativebuf = prealloc(pool, nativebuf, size, 0);
+      nativebuf = pmalrealloc(pool, nativebuf, size, 0);
       if (NULL != nativebuf) {
         ret = (*env)->NewDirectByteBuffer(env, nativebuf, size);
       }
     }
   }
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
 JNIEXPORT
 void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_ndestroyByteBuffer(
     JNIEnv *env, jobject this, jlong id, jobject bytebuf) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   if (NULL != bytebuf) {
     void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
-    pfree(pool, nativebuf);
+    pmalfree(pool, nativebuf);
   }
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 JNIEXPORT
 void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nsetHandler(
     JNIEnv *env, jobject this, jlong id, jlong key, jlong value) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   if (key < PMALLOC_KEYS && key >= 0) {
     pmalloc_setkey(pool->pmp, key, (void*)value);
   }
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_ngetHandler(JNIEnv *env,
     jobject this, jlong id, jlong key) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   jlong ret = (key < PMALLOC_KEYS && key >= 0) ? (long) pmalloc_getkey(pool->pmp, key) : 0;
   pthread_mutex_unlock(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
@@ -289,45 +289,45 @@ jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocSer
 JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_ngetBaseAddress(JNIEnv *env,
     jobject this, jlong id) {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_rdlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   jlong ret = (long) b_addr(pool->pmp);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
 JNIEXPORT
 jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_ninit(JNIEnv *env,
     jclass this, jlong capacity, jstring pathname, jboolean isnew) {
-  PMPool *pool;
+  PMALPool *pool;
   size_t ret = -1;
   void *md = NULL;
-  pthread_rwlock_wrlock(&g_pmp_rwlock);
+  pthread_rwlock_wrlock(&g_pmalp_rwlock);
   const char* mpathname = (*env)->GetStringUTFChars(env, pathname, NULL);
   if (NULL == mpathname) {
-    pthread_rwlock_unlock(&g_pmp_rwlock);
+    pthread_rwlock_unlock(&g_pmalp_rwlock);
     throw(env, "Big memory path not specified!");
   }
   if ((md = pmopen(mpathname, NULL,
                    PMALLOC_MIN_POOL_SIZE > capacity ? PMALLOC_MIN_POOL_SIZE : capacity)) == NULL) {
-    pthread_rwlock_unlock(&g_pmp_rwlock);
+    pthread_rwlock_unlock(&g_pmalp_rwlock);
     throw(env, "Big memory init failure!");
   }
   (*env)->ReleaseStringUTFChars(env, pathname, mpathname);
-  g_pmpool_arr = realloc(g_pmpool_arr, (g_pmpool_count + 1) * sizeof(PMPool));
-  if (NULL != g_pmpool_arr) {
-    pool = g_pmpool_arr + g_pmpool_count;
+  g_pmalpool_arr = realloc(g_pmalpool_arr, (g_pmalpool_count + 1) * sizeof(PMALPool));
+  if (NULL != g_pmalpool_arr) {
+    pool = g_pmalpool_arr + g_pmalpool_count;
     pool->pmp = md;
     pool->capacity = pmcapacity(pool->pmp);
     pthread_mutex_init(&pool->mutex, NULL);
-    ret = g_pmpool_count;
-    ++g_pmpool_count;
+    ret = g_pmalpool_count;
+    ++g_pmalpool_count;
   } else {
-    pthread_rwlock_unlock(&g_pmp_rwlock);
+    pthread_rwlock_unlock(&g_pmalp_rwlock);
     throw(env, "Big memory init Out of memory!");
   }
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
   return ret;
 }
 
@@ -335,9 +335,9 @@ JNIEXPORT
 void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServiceImpl_nclose
 (JNIEnv *env, jobject this, jlong id)
 {
-  PMPool *pool;
-  pthread_rwlock_rdlock(&g_pmp_rwlock);
-  pool = g_pmpool_arr + id;
+  PMALPool *pool;
+  pthread_rwlock_wrlock(&g_pmalp_rwlock);
+  pool = g_pmalpool_arr + id;
   pthread_mutex_lock(&pool->mutex);
   if (NULL != pool->pmp) {
     pmclose(pool->pmp);
@@ -346,15 +346,16 @@ void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_PMallocServ
   }
   pthread_mutex_unlock(&pool->mutex);
   pthread_mutex_destroy(&pool->mutex);
-  pthread_rwlock_unlock(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
 }
 
 __attribute__((destructor)) void fini(void) {
   int i;
-  PMPool *pool;
-  if (NULL != g_pmpool_arr) {
-    for (i = 0; i < g_pmpool_count; ++i) {
-      pool = g_pmpool_arr + i;
+  PMALPool *pool;
+  pthread_rwlock_wrlock(&g_pmalp_rwlock);
+  if (NULL != g_pmalpool_arr) {
+    for (i = 0; i < g_pmalpool_count; ++i) {
+      pool = g_pmalpool_arr + i;
       if (NULL != pool->pmp) {
         pmclose(pool->pmp);
         pool->pmp = NULL;
@@ -362,9 +363,10 @@ __attribute__((destructor)) void fini(void) {
         pthread_mutex_destroy(&pool->mutex);
       }
     }
-    free(g_pmpool_arr);
-    g_pmpool_arr = NULL;
-    g_pmpool_count = 0;
+    free(g_pmalpool_arr);
+    g_pmalpool_arr = NULL;
+    g_pmalpool_count = 0;
   }
-  pthread_rwlock_destroy(&g_pmp_rwlock);
+  pthread_rwlock_unlock(&g_pmalp_rwlock);
+  pthread_rwlock_destroy(&g_pmalp_rwlock);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/3c22e177/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8b97d05..7525b8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -161,7 +161,7 @@
       <dependency>
         <groupId>org.flowcomputing.commons</groupId>
         <artifactId>commons-resgc</artifactId>
-        <version>0.8.9</version>
+        <version>0.8.10</version>
       </dependency>
       <dependency>
         <groupId>org.flowcomputing.commons</groupId>


[2/2] incubator-mnemonic git commit: MNEMONIC-132: Terminate called without an active exception

Posted by ga...@apache.org.
MNEMONIC-132: Terminate called without an active exception


Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/404502be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/404502be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/404502be

Branch: refs/heads/master
Commit: 404502bee1600cb712d759833848dfe065f302f5
Parents: 3c22e17
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Wed Oct 5 09:46:53 2016 -0700
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Wed Oct 5 09:46:53 2016 -0700

----------------------------------------------------------------------
 README.md         | 2 +-
 docker/Dockerfile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/404502be/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 22d6d4d..be3fea1 100644
--- a/README.md
+++ b/README.md
@@ -226,7 +226,7 @@ Please see the file LICENSE for information on how this library is licensed.
 To build this library, you may need to install some required packages on the build system:
 
 * **Maven** -- the building tool v3.2.1 or above [Required]
-* **NVML** -- the NVM library (Please compile this library that is tagged with 1.1 release with pandoc dependency) (http://pmem.io) [Optional if mnemonic-nvml-vmem-service/mnemonic-nvml-pmem-service are excluded, e.g. on MacOSX]
+* **NVML** -- the NVM library (Please compile this library that was revised with 630862e82f) (http://pmem.io) [Optional if mnemonic-nvml-vmem-service/mnemonic-nvml-pmem-service are excluded, e.g. on MacOSX]
 * **JDK** -- the Java Develop Kit 1.6 or above (please properly configure JAVA_HOME) [Required]
 * **PMFS** -- the PMFS should be properly installed and configured on Linux system if you want to simulate read latency [Optional]
 * **PMalloc** -- a supported durable memory native library(Latest) at https://github.com/NonVolatileComputing/pmalloc.git [Optional if mnemonic-pmalloc-service is excluded]

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/404502be/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 657f51e..b57dd1b 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -57,7 +57,7 @@ RUN cd /ws && git clone https://github.com/NonVolatileComputing/pmalloc.git && \
     cd pmalloc && mkdir build && cd build && cmake .. && make && make install
 
 RUN cd /ws && git clone https://github.com/pmem/nvml.git && \
-    cd nvml && git checkout tags/1.1 && make && make install
+    cd nvml && git checkout 630862e82f && make && make install
 
 RUN echo export MAVEN_OPTS="\" $([[ \"x\" != \"x${proxy_host}\" ]] && echo -DproxySet=\\\"true\\\" -DproxyHost=${proxy_host} -DproxyPort=${proxy_port}) \"" \
     > /etc/profile.d/mvn.sh && chmod +x /etc/profile.d/mvn.sh