Index: trunk/kernel/mm/kcm.c
===================================================================
--- trunk/kernel/mm/kcm.c	(revision 657)
+++ trunk/kernel/mm/kcm.c	(revision 672)
@@ -2,5 +2,5 @@
  * kcm.c -  Kernel Cache Manager implementation.
  *
- * Author  Alain Greiner    (2016,2017,2018,2019)
+ * Author  Alain Greiner    (2016,2017,2018,2019,2020)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -60,5 +60,5 @@
     uint64_t status = kcm_page->status;
 
-assert( (count < max) , "kcm_page should not be full" );
+assert( __FUNCTION__, (count < max) , "kcm_page should not be full" );
 
     uint32_t index  = 1;
@@ -94,5 +94,5 @@
 	void * ptr = (void *)((intptr_t)kcm_page + (index * size) );
 
-#if (DEBUG_KCM & 1)
+#if DEBUG_KCM 
 thread_t * this  = CURRENT_THREAD;
 uint32_t   cycle = (uint32_t)hal_get_cycles();
@@ -132,6 +132,12 @@
     uint64_t mask = ((uint64_t)0x1) << index;
 
-assert( (status & mask) , "released block not allocated : status (%x,%x) / mask(%x,%x)",
-GET_CXY(status), GET_PTR(status), GET_CXY(mask  ), GET_PTR(mask  ) );
+    if( (status & mask) == 0 )
+    {
+        printk("\n[WARNING] in %s : block[%x,%x] not allocated / kcm %x / kcm_page %x\n",
+        __FUNCTION__, local_cxy, block_ptr, kcm, kcm_page );
+        printk("   status %L / mask %L / sts & msk %L\n", status, mask, (status & mask) );
+        kcm_remote_display( local_cxy , kcm );
+        return;
+    }
 
     // update status & count in kcm_page 
@@ -149,9 +155,9 @@
 	}
 
-#if (DEBUG_KCM & 1)
+#if DEBUG_KCM 
 thread_t * this  = CURRENT_THREAD;
 uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_KCM < cycle )
-printk("\n[%s] thread[%x,%x] released block %x in page %x / size %d / count %d / cycle %d\n",
+printk("\n[%s] thread[%x,%x] block %x / page %x / size %d / count %d / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, block_ptr, kcm_page, size, count - 1, cycle );
 #endif
@@ -219,5 +225,7 @@
 {
 
-assert( ((order > 5) && (order < 12)) , "order must be in [6,11]" );
+assert( __FUNCTION__, ((order > 5) && (order < 12)) , "order must be in [6,11]" );
+
+assert( __FUNCTION__, (CONFIG_PPM_PAGE_SHIFT == 12) , "check status bit_vector width" );
 
 	// initialize lock
@@ -286,5 +294,5 @@
     if( order < 6 ) order = 6;
 
-assert( (order < 12) , "order = %d / must be less than 12" , order );
+assert( __FUNCTION__, (order < 12) , "order = %d / must be less than 12" , order );
 
     // get local pointer on relevant KCM allocator
@@ -303,5 +311,5 @@
 thread_t * this  = CURRENT_THREAD;
 uint32_t   cycle = (uint32_t)hal_get_cycles();
-if( (DEBUG_KCM < cycle) && (local_cxy == 1) )
+if( DEBUG_KCM < cycle )
 {
 printk("\n[%s] thread[%x,%x] enters / order %d / page %x / kcm %x / page_status (%x|%x)\n",
@@ -325,11 +333,8 @@
 
 #if DEBUG_KCM
-if( (DEBUG_KCM < cycle) && (local_cxy == 1) )
-{
+if( DEBUG_KCM < cycle )
 printk("\n[%s] thread[%x,%x] exit / order %d / block %x / kcm %x / page_status (%x|%x)\n",
 __FUNCTION__, this->process->pid, this->trdid, order, block_ptr, kcm_ptr,
 GET_CXY( kcm_page->status ), GET_PTR( kcm_page->status ) );
-kcm_remote_display( local_cxy , kcm_ptr );
-}
 #endif
 
@@ -345,5 +350,5 @@
 
 // check argument
-assert( (block_ptr != NULL) , "block pointer cannot be NULL" );
+assert( __FUNCTION__, (block_ptr != NULL) , "block pointer cannot be NULL" );
 
     // get local pointer on KCM page
@@ -389,4 +394,5 @@
 }  // end kcm_free() 
 
+
 /////////////////////////////////////////////////////////////////////////////////////
 //        Remote access functions
@@ -414,5 +420,5 @@
     uint32_t size   = 1 << order;
 
-assert( (count < max) , "kcm_page should not be full" );
+assert( __FUNCTION__, (count < max) , "kcm_page should not be full" );
 
     uint32_t index  = 1;
@@ -485,7 +491,14 @@
 
     // compute mask in bit vector
-    uint64_t mask = 1 << index;
-
-assert( (status & mask) , "released page not allocated" );
+    uint64_t mask = ((uint64_t)0x1) << index;
+
+    if( (status & mask) == 0 )
+    {
+        printk("\n[WARNING] in %s : block[%x,%x] not allocated / kcm %x / kcm_page %x\n",
+        __FUNCTION__, kcm_cxy, block_ptr, kcm_ptr, kcm_page );
+        printk("   status %L / mask %L / sts & msk %L\n", status, mask, (status & mask) );
+        kcm_remote_display( kcm_cxy , kcm_ptr );
+        return;
+    }
 
     // update status & count in kcm_page 
@@ -507,5 +520,5 @@
 uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_KCM_REMOTE < cycle )
-printk("\n[%s] thread[%x,%x] released block %x in page %x / cluster %x / size %x / count %d\n",
+printk("\n[%s] thread[%x,%x] block %x / page %x / cluster %x / size %x / count %d\n",
 __FUNCTION__, this->process->pid, this->trdid, block_ptr, kcm_page, size, count - 1 )
 #endif
@@ -564,5 +577,5 @@
 }  // end kcm_remote_get_page()
 
-/////////////////////////////////////////
+//////////////////////////////////////////
 void * kcm_remote_alloc( cxy_t    kcm_cxy,
                          uint32_t order )
@@ -574,5 +587,5 @@
     if( order < 6 ) order = 6;
 
-assert( (order < 12) , "order = %d / must be less than 12" , order );
+assert( __FUNCTION__, (order < 12) , "order = %d / must be less than 12" , order );
 
     // get local pointer on relevant KCM allocator
@@ -620,5 +633,5 @@
 
 // check argument
-assert( (block_ptr != NULL) , "block pointer cannot be NULL" );
+assert( __FUNCTION__, (block_ptr != NULL) , "block pointer cannot be NULL" );
 
     // get local pointer on remote KCM page
