Index: trunk/kernel/mm/mapper.c
===================================================================
--- trunk/kernel/mm/mapper.c	(revision 408)
+++ trunk/kernel/mm/mapper.c	(revision 435)
@@ -143,6 +143,10 @@
     error_t       error;
 
-mapper_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper %x\n",
-__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , mapper );
+#if CONFIG_DEBUG_MAPPER_GET_PAGE
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle )
+printk("\n[DBG] %s : thread %x enter for page %d / mapper %x / cycle %d\n",
+__FUNCTION__ , CURRENT_THREAD , index , mapper , cycle );
+#endif
 
     thread_t * this = CURRENT_THREAD;
@@ -171,7 +175,8 @@
         {
 
-mapper_dmsg("\n[DBG] %s : core[%x,%d] missing page => load from device\n",
-__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid );
-
+#if (CONFIG_DEBUG_MAPPER_GET_PAGE & 1)
+if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle )
+printk("\n[DBG] %s : missing page => load from device\n", __FUNCTION__ );
+#endif
             // allocate one page from PPM
             req.type  = KMEM_PAGE;
@@ -230,8 +235,4 @@
             // reset the page INLOAD flag to make the page available to all readers
             page_clear_flag( page , PG_INLOAD );
-
-mapper_dmsg("\n[DBG] %s : missing page loaded / ppn = %x\n",
-__FUNCTION__ , ppm_page2ppn(XPTR(local_cxy,page)) );
-
         }
         else if( page_is_flag( page , PG_INLOAD ) )   // page is loaded by another thread
@@ -256,6 +257,10 @@
     }
 
-mapper_dmsg("\n[DBG] %s : exit for page %d / mapper %x / page_desc = %x\n",
-__FUNCTION__ , index , mapper , page );
+#if CONFIG_DEBUG_MAPPER_GET_PAGE
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle )
+printk("\n[DBG] %s : thread %x exit for page %d / ppn %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, index, ppm_page2ppn(XPTR(local_cxy, page)), cycle );
+#endif
 
     return page;
@@ -312,6 +317,10 @@
     uint8_t  * buf_ptr;        // current buffer  address
 
-    mapper_dmsg("\n[DBG] %s : enters / to_buf = %d / buffer = %x\n",
-                __FUNCTION__ , to_buffer , buffer );
+#if CONFIG_DEBUG_MAPPER_MOVE_USER
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle )
+printk("\n[DBG] %s : thread %x enter / to_buf %d / buffer %x / cycle %d\n",
+__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer , cycle );
+#endif
 
     // compute offsets of first and last bytes in file
@@ -338,6 +347,9 @@
         else                       page_count = CONFIG_PPM_PAGE_SIZE;
 
-        mapper_dmsg("\n[DBG] %s : index = %d / offset = %d / count = %d\n",
-                    __FUNCTION__ , index , page_offset , page_count );
+#if (CONFIG_DEBUG_MAPPER_MOVE_USER & 1)
+if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle )
+printk("\n[DBG] %s : index = %d / offset = %d / count = %d\n",
+__FUNCTION__ , index , page_offset , page_count );
+#endif
 
         // get page descriptor
@@ -353,7 +365,4 @@
         buf_ptr = (uint8_t *)buffer + done;
 
-        mapper_dmsg("\n[DBG] %s : index = %d / buf_ptr = %x / map_ptr = %x\n",
-                    __FUNCTION__ , index , buf_ptr , map_ptr );
-
         // move fragment
         if( to_buffer )
@@ -370,6 +379,10 @@
     }
 
-    mapper_dmsg("\n[DBG] %s : exit for buffer %x\n",
-                __FUNCTION__, buffer );
+#if CONFIG_DEBUG_MAPPER_MOVE_USER
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle )
+printk("\n[DBG] %s : thread %x exit / to_buf %d / buffer %x / cycle %d\n",
+__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer , cycle );
+#endif
 
     return 0;
@@ -399,6 +412,10 @@
     uint8_t * buffer_ptr = (uint8_t *)GET_PTR( buffer_xp );
 
-mapper_dmsg("\n[DBG] %s : core[%x,%d] / to_buf = %d / buf_cxy = %x / buf_ptr = %x / size = %x\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, to_buffer, buffer_cxy, buffer_ptr, size );
+#if CONFIG_DEBUG_MAPPER_MOVE_KERNEL
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
+printk("\n[DBG] %s : thread %x enter / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n",
+__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer_cxy , buffer_ptr , cycle );
+#endif
 
     // compute offsets of first and last bytes in file
@@ -410,6 +427,8 @@
     uint32_t last  = max_byte >> CONFIG_PPM_PAGE_SHIFT;
 
-mapper_dmsg("\n[DBG] %s : core[%x,%d] / first_page = %d / last_page = %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first, last );
+#if (CONFIG_DEBUG_MAPPER_MOVE_KERNEL & 1)
+if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
+printk("\n[DBG] %s : first_page %d / last_page %d\n", __FUNCTION__, first, last );
+#endif
 
     // compute source and destination clusters
@@ -440,6 +459,9 @@
         else                       page_count = CONFIG_PPM_PAGE_SIZE;
 
-mapper_dmsg("\n[DBG] %s : core[%x;%d] / page_index = %d / offset = %d / bytes = %d\n",
-__FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, index, page_offset, page_count );
+#if (CONFIG_DEBUG_MAPPER_MOVE_KERNEL & 1)
+if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
+printk("\n[DBG] %s : page_index = %d / offset = %d / bytes = %d\n",
+__FUNCTION__ , index , page_offset , page_count );
+#endif
 
         // get page descriptor
@@ -472,6 +494,10 @@
     }
 
-mapper_dmsg("\n[DBG] %s : core_cxy[%x,%d] / exit / buf_cxy = %x / buf_ptr = %x / size = %x\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, buffer_cxy, buffer_ptr, size );
+#if CONFIG_DEBUG_MAPPER_MOVE_KERNEL
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
+printk("\n[DBG] %s : thread %x exit / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n",
+__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer_cxy , buffer_ptr , cycle );
+#endif
 
     return 0;
