Index: trunk/kernel/mm/kmem.c
===================================================================
--- trunk/kernel/mm/kmem.c	(revision 433)
+++ trunk/kernel/mm/kmem.c	(revision 435)
@@ -145,6 +145,10 @@
 	assert( ((type > 1) && (type < KMEM_TYPES_NR) ) , __FUNCTION__ , "illegal KCM type" );
 
-	kmem_dmsg("\n[DBG] %s : enters / KCM type %s missing in cluster %x\n",
-	          __FUNCTION__ , kmem_type_str( type ) , local_cxy );
+#if CONFIG_DEBUG_KMEM
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_KMEM < cycle )
+printk("\n[DBG] %s : thread %x enter / KCM type %s missing in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), local_cxy, cycle );
+#endif
 
 	cluster_t * cluster = LOCAL_CLUSTER;
@@ -169,6 +173,10 @@
 	hal_fence();
 
-	kmem_dmsg("\n[DBG] %s : exit / KCM type %s created in cluster %x\n",
-	          __FUNCTION__ , kmem_type_str( type ) , local_cxy );
+#if CONFIG_DEBUG_KMEM
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_KMEM < cycle )
+printk("\n[DBG] %s : thread %x exit / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, cycle );
+#endif
 
 	return 0;
@@ -192,17 +200,14 @@
 	assert( (type < KMEM_TYPES_NR) , __FUNCTION__ , "illegal KMEM request type" );
 
-	kmem_dmsg("\n[DBG] %s : enters in cluster %x for type %s\n",
-		      __FUNCTION__ , local_cxy , kmem_type_str( type ) );
+#if CONFIG_DEBUG_KMEM
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_KMEM < cycle )
+printk("\n[DBG] %s : thread %x enter / type %s / cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), local_cxy, cycle );
+#endif
 
 	// analyse request type
 	if( type == KMEM_PAGE )                        // PPM allocator
 	{
-
-#if CONFIG_DEBUG_KMEM_ALLOC
-if( CONFIG_DEBUG_KMEM_ALLOC < (uint32_t)hal_get_cycles() )
-printk("\n[DBG] in %s : thread %x enter for %d page(s)\n",
-__FUNCTION__ , CURRENT_THREAD , 1<<size );
-#endif
-
 		// allocate the number of requested pages
 		ptr = (void *)ppm_alloc_pages( size );
@@ -217,12 +222,9 @@
 		if( flags & AF_ZERO ) page_zero( (page_t *)ptr );
 
-		kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / page = %x / base = %x\n",
-		          __FUNCTION__, local_cxy , kmem_type_str( type ) ,
-		          (intptr_t)ptr , (intptr_t)ppm_page2base( ptr ) );
-
-#if CONFIG_DEBUG_KMEM_ALLOC
-if( CONFIG_DEBUG_KMEM_ALLOC < (uint32_t)hal_get_cycles() )
-printk("\n[DBG] in %s : thread %x exit / %d page(s) allocated / ppn = %x\n",
-__FUNCTION__ , CURRENT_THREAD , 1<<size , ppm_page2ppn( XPTR( local_cxy , ptr ) ) );
+#if CONFIG_DEBUG_KMEM
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_KMEM < cycle )
+printk("\n[DBG] %s : thread %x exit / %d page(s) allocated / ppn %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, 1<<size, ppm_page2ppn(XPTR(local_cxy,ptr)), cycle );
 #endif
 
@@ -242,7 +244,11 @@
 		if( flags & AF_ZERO ) memset( ptr , 0 , size );
 
-		kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / base = %x / size = %d\n",
-		          __FUNCTION__, local_cxy , kmem_type_str( type ) ,
-		          (intptr_t)ptr , req->size );
+#if CONFIG_DEBUG_KMEM
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_KMEM < cycle )
+printk("\n[DBG] %s : thread %x exit / type %s allocated / base %x / size %d / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), (intptr_t)ptr, size, cycle );
+#endif
+
 	}
 	else                                           // KCM allocator
@@ -269,7 +275,12 @@
 		if( flags & AF_ZERO ) memset( ptr , 0 , kmem_type_size( type ) );
 
-		kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / base = %x / size = %d\n",
-		          __FUNCTION__, local_cxy , kmem_type_str( type ) ,
-		          (intptr_t)ptr , kmem_type_size( type ) );
+#if CONFIG_DEBUG_KMEM
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_KMEM < cycle )
+printk("\n[DBG] %s : thread %x exit / type %s allocated / base %x / size %d / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, kmem_type_str(type), (intptr_t)ptr, 
+kmem_type_size(type), cycle );
+#endif
+
 	}
 
