Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision a80687e5d0c412f3bad3c9783431cf59986f9006)
+++ kernel/generic/src/sysinfo/stats.c	(revision da9891837c5accbfe18c82141e098d672c4025c5)
@@ -55,6 +55,5 @@
 #define LOAD_INTERVAL  5
 
-/**
- * Fixed-point representation of:
+/** Fixed-point representation of
  *
  * 1 / exp(5 sec / 1 min)
@@ -64,7 +63,18 @@
  */
 static load_t load_exp[LOAD_STEPS] = {1884, 2014, 2037};
+
+/** Running average of the number of ready threads */
 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0};
+
+/** Load calculation spinlock */
 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");
 
+/** Get system uptime
+ *
+ * @param item Sysinfo item (unused).
+ *
+ * @return System uptime (in secords).
+ *
+ */
 static unative_t get_stats_uptime(struct sysinfo_item *item)
 {
@@ -73,6 +83,16 @@
 }
 
+/** Get statistics of all CPUs
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data containing several stats_cpu_t structures.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_cpus(struct sysinfo_item *item, size_t *size)
 {
+	/* Assumption: config.cpu_count is constant */
 	stats_cpu_t *stats_cpus =
 	    (stats_cpu_t *) malloc(sizeof(stats_cpu_t) * config.cpu_count,
@@ -83,4 +103,5 @@
 	}
 	
+	/* Each CPU structure is locked separatelly */
 	ipl_t ipl = interrupts_disable();
 	
@@ -103,4 +124,14 @@
 }
 
+/** Count number of tasks
+ *
+ * AVL task tree walker for counting tasks.
+ *
+ * @param node AVL task tree node (unused).
+ * @param arg  Pointer to the counter.
+ *
+ * @param Always true (continue the walk).
+ *
+ */
 static bool task_count_walker(avltree_node_t *node, void *arg)
 {
@@ -111,4 +142,15 @@
 }
 
+/** Gather tasks
+ *
+ * AVL task tree walker for gathering task IDs. Interrupts should
+ * be already disabled while walking the tree.
+ *
+ * @param node AVL task tree node.
+ * @param arg  Pointer to the iterator into the array of task IDs.
+ *
+ * @param Always true (continue the walk).
+ *
+ */
 static bool task_serialize_walker(avltree_node_t *node, void *arg)
 {
@@ -116,6 +158,8 @@
 	task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
 	
+	/* Interrupts are already disabled */
 	spinlock_lock(&(task->lock));
 	
+	/* Record the ID and increment the iterator */
 	**ids = task->taskid;
 	(*ids)++;
@@ -126,4 +170,13 @@
 }
 
+/** Get task IDs
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data containing task IDs of all tasks.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_tasks(struct sysinfo_item *item, size_t *size)
 {
@@ -132,8 +185,10 @@
 	spinlock_lock(&tasks_lock);
 	
+	/* First walk the task tree to count the tasks */
 	size_t count = 0;
 	avltree_walk(&tasks_tree, task_count_walker, (void *) &count);
 	
 	if (count == 0) {
+		/* No tasks found (strange) */
 		spinlock_unlock(&tasks_lock);
 		interrupts_restore(ipl);
@@ -146,4 +201,5 @@
 	    (task_id_t *) malloc(sizeof(task_id_t) * count, FRAME_ATOMIC);
 	if (task_ids == NULL) {
+		/* No free space for allocation */
 		spinlock_unlock(&tasks_lock);
 		interrupts_restore(ipl);
@@ -153,4 +209,5 @@
 	}
 	
+	/* Walk tha task tree again to gather the IDs */
 	task_id_t *iterator = task_ids;
 	avltree_walk(&tasks_tree, task_serialize_walker, (void *) &iterator);
@@ -163,4 +220,11 @@
 }
 
+/** Get the size of a virtual address space
+ *
+ * @param as Address space.
+ *
+ * @return Size of the mapped virtual address space (bytes).
+ *
+ */
 static size_t get_task_virtmem(as_t *as)
 {
@@ -169,4 +233,5 @@
 	size_t result = 0;
 	
+	/* Walk the B+ tree and count pages */
 	link_t *cur;
 	for (cur = as->as_area_btree.leaf_head.next;
@@ -190,14 +255,32 @@
 }
 
+/** Get task statistics
+ *
+ * Get statistics of a given task. The task ID is passed
+ * as a string (current limitation of the sysinfo interface,
+ * but it is still reasonable for the given purpose).
+ *
+ * @param name Task ID (string-encoded number).
+ *
+ * @return Sysinfo return holder. The type of the returned
+ *         data is either SYSINFO_VAL_UNDEFINED (unknown
+ *         task ID or memory allocation error) or
+ *         SYSINFO_VAL_FUNCTION_DATA (in that case the
+ *         generated data should be freed within the
+ *         sysinfo request context).
+ *
+ */
 static sysinfo_return_t get_stats_task(const char *name)
 {
-	
+	/* Initially no return value */
 	sysinfo_return_t ret;
 	ret.tag = SYSINFO_VAL_UNDEFINED;
 	
+	/* Parse the task ID */
 	task_id_t task_id;
 	if (str_uint64(name, NULL, 0, true, &task_id) != EOK)
 		return ret;
 	
+	/* Allocate stats_task_t structure */
 	stats_task_t *stats_task =
 	    (stats_task_t *) malloc(sizeof(stats_task_t), FRAME_ATOMIC);
@@ -205,4 +288,5 @@
 		return ret;
 	
+	/* Messing with task structures, avoid deadlock */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&tasks_lock);
@@ -210,4 +294,5 @@
 	task_t *task = task_find_by_id(task_id);
 	if (task == NULL) {
+		/* No task with this ID */
 		spinlock_unlock(&tasks_lock);
 		interrupts_restore(ipl);
@@ -216,7 +301,9 @@
 	}
 	
+	/* Hand-over-hand locking */
 	spinlock_lock(&task->lock);
 	spinlock_unlock(&tasks_lock);
 	
+	/* Copy task's statistics */
 	str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
 	stats_task->virtmem = get_task_virtmem(task->as);
@@ -229,4 +316,5 @@
 	interrupts_restore(ipl);
 	
+	/* Correct return value */
 	ret.tag = SYSINFO_VAL_FUNCTION_DATA;
 	ret.data.data = (void *) stats_task;
@@ -236,4 +324,13 @@
 }
 
+/** Get physical memory statistics
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data containing stats_physmem_t.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_physmem(struct sysinfo_item *item, size_t *size)
 {
@@ -252,4 +349,13 @@
 }
 
+/** Get system load
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data several load_t values.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_load(struct sysinfo_item *item, size_t *size)
 {
@@ -261,4 +367,5 @@
 	}
 	
+	/* To always get consistent values acquire the spinlock */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&load_lock);
@@ -324,4 +431,5 @@
 	
 	while (true) {
+		/* Mutually exclude with get_stats_load() */
 		ipl_t ipl = interrupts_disable();
 		spinlock_lock(&load_lock);
@@ -340,4 +448,7 @@
 }
 
+/** Register sysinfo statistical items
+ *
+ */
 void stats_init(void)
 {
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision a80687e5d0c412f3bad3c9783431cf59986f9006)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision da9891837c5accbfe18c82141e098d672c4025c5)
@@ -41,13 +41,21 @@
 #include <errno.h>
 
+/** Maximal sysinfo path length */
 #define SYSINFO_MAX_PATH  2048
 
 bool fb_exported = false;
 
+/** Global sysinfo tree root item */
 static sysinfo_item_t *global_root = NULL;
+
+/** Sysinfo SLAB cache */
 static slab_cache_t *sysinfo_item_slab;
 
+/** Sysinfo spinlock */
 SPINLOCK_STATIC_INITIALIZE_NAME(sysinfo_lock, "sysinfo_lock");
 
+/** Sysinfo item constructor
+ *
+ */
 static int sysinfo_item_constructor(void *obj, int kmflag)
 {
@@ -63,4 +71,11 @@
 }
 
+/** Sysinfo item destructor
+ *
+ * Note that the return value is not perfectly correct
+ * since more space might get actually freed thanks
+ * to the disposal of item->name
+ *
+ */
 static int sysinfo_item_destructor(void *obj)
 {
@@ -73,4 +88,9 @@
 }
 
+/** Initialize sysinfo subsystem
+ *
+ * Create SLAB cache for sysinfo items.
+ *
+ */
 void sysinfo_init(void)
 {
@@ -80,9 +100,20 @@
 }
 
-/** Recursively find item in sysinfo tree
+/** Recursively find an item in sysinfo tree
  *
  * Should be called with interrupts disabled
  * and sysinfo_lock held.
  *
+ * @param name    Current sysinfo path suffix.
+ * @param subtree Current sysinfo (sub)tree root item.
+ * @param ret     If the return value is NULL, this argument
+ *                can be either also NULL (i.e. no item was
+ *                found and no data was generated) or the
+ *                original pointer is used to store the value
+ *                generated by a generated subtree function.
+ *
+ * @return Found item or NULL if no item in the fixed tree
+ *         was found (N.B. ret).
+ *
  */
 static sysinfo_item_t *sysinfo_find_item(const char *name,
@@ -94,4 +125,5 @@
 	sysinfo_item_t *cur = subtree;
 	
+	/* Walk all siblings */
 	while (cur != NULL) {
 		size_t i = 0;
@@ -118,5 +150,5 @@
 				return NULL;
 			default:
-				/* Not found */
+				/* Not found, no data generated */
 				*ret = NULL;
 				return NULL;
@@ -127,4 +159,5 @@
 	}
 	
+	/* Not found, no data generated */
 	*ret = NULL;
 	return NULL;
@@ -135,4 +168,12 @@
  * Should be called with interrupts disabled
  * and sysinfo_lock held.
+ *
+ * @param name     Current sysinfo path suffix.
+ * @param psubtree Pointer to an already existing (sub)tree root
+ *                 item or where to store a new tree root item.
+ *
+ * @return Existing or newly allocated sysinfo item or NULL
+ *         if the current tree configuration does not allow to
+ *         create a new item.
  *
  */
@@ -172,4 +213,5 @@
 	sysinfo_item_t *cur = *psubtree;
 	
+	/* Walk all siblings */
 	while (cur != NULL) {
 		size_t i = 0;
@@ -199,5 +241,5 @@
 			default:
 				/* Subtree items handled by a function, this
-				 * cannot be overriden.
+				 * cannot be overriden by a constant item.
 				 */
 				return NULL;
@@ -235,5 +277,4 @@
 		}
 		
-		/* Get next sibling */
 		cur = cur->next;
 	}
@@ -244,7 +285,16 @@
 }
 
+/** Set sysinfo item with a constant numeric value
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param val  Value to store in the item.
+ *
+ */
 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root,
     unative_t val)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -263,7 +313,21 @@
 }
 
+/** Set sysinfo item with a constant binary data
+ *
+ * Note that sysinfo only stores the pointer to the
+ * binary data and does not touch it in any way. The
+ * data should be static and immortal.
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param data Binary data.
+ * @param size Size of the binary data.
+ *
+ */
 void sysinfo_set_item_data(const char *name, sysinfo_item_t **root,
     void *data, size_t size)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -283,7 +347,16 @@
 }
 
+/** Set sysinfo item with a generated numeric value
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param fn   Numeric value generator function.
+ *
+ */
 void sysinfo_set_item_fn_val(const char *name, sysinfo_item_t **root,
     sysinfo_fn_val_t fn)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -302,7 +375,21 @@
 }
 
+/** Set sysinfo item with a generated binary data
+ *
+ * Note that each time the generator function is called
+ * it is supposed to return a new dynamically allocated
+ * data. This data is then freed by sysinfo in the context
+ * of the current sysinfo request.
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param fn   Binary data generator function.
+ *
+ */
 void sysinfo_set_item_fn_data(const char *name, sysinfo_item_t **root,
     sysinfo_fn_data_t fn)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -321,6 +408,14 @@
 }
 
+/** Set sysinfo item with an undefined value
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ *
+ */
 void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -337,7 +432,16 @@
 }
 
+/** Set sysinfo item with a generated subtree
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param fn   Subtree generator function.
+ *
+ */
 void sysinfo_set_subtree_fn(const char *name, sysinfo_item_t **root,
     sysinfo_fn_subtree_t fn)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -347,4 +451,7 @@
 	
 	sysinfo_item_t *item = sysinfo_create_path(name, root);
+	
+	/* Change the type of the subtree only if it is not already
+	   a fixed subtree */
 	if ((item != NULL) && (item->subtree_type != SYSINFO_SUBTREE_TABLE)) {
 		item->subtree_type = SYSINFO_SUBTREE_FUNCTION;
@@ -357,4 +464,6 @@
 
 /** Sysinfo dump indentation helper routine
+ *
+ * @param depth Number of indentation characters to print.
  *
  */
@@ -374,4 +483,7 @@
  * there is no better simple solution.
  *
+ * @param root  Root item of the current (sub)tree.
+ * @param depth Current depth in the sysinfo tree.
+ *
  */
 static void sysinfo_dump_internal(sysinfo_item_t *root, unsigned int depth)
@@ -379,4 +491,5 @@
 	sysinfo_item_t *cur = root;
 	
+	/* Walk all siblings */
 	while (cur != NULL) {
 		sysinfo_indent(depth);
@@ -386,4 +499,5 @@
 		size_t size;
 		
+		/* Display node value and type */
 		switch (cur->val_type) {
 		case SYSINFO_VAL_UNDEFINED:
@@ -405,4 +519,6 @@
 		case SYSINFO_VAL_FUNCTION_DATA:
 			data = cur->val.fn_data(cur, &size);
+			
+			/* N.B.: The generated binary data should be freed */
 			if (data != NULL)
 				free(data);
@@ -415,4 +531,5 @@
 		}
 		
+		/* Recursivelly nest into the subtree */
 		switch (cur->subtree_type) {
 		case SYSINFO_SUBTREE_NONE:
@@ -434,6 +551,15 @@
 }
 
+/** Dump the structure of sysinfo tree
+ *
+ * @param root  Root item of the sysinfo (sub)tree.
+ *              If it is NULL then consider the global
+ *              sysinfo tree.
+ *
+ */
 void sysinfo_dump(sysinfo_item_t *root)
 {
+	/* Avoid other functions to mess with sysinfo
+	   while we are dumping it */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -448,9 +574,16 @@
 }
 
-/** Return sysinfo item determined by name
+/** Return sysinfo item value determined by name
  *
  * Should be called with interrupts disabled
  * and sysinfo_lock held.
  *
+ * @param name Sysinfo path.
+ * @param root Root item of the sysinfo (sub)tree.
+ *             If it is NULL then consider the global
+ *             sysinfo tree.
+ *
+ * @return Item value (constant or generated).
+ *
  */
 static sysinfo_return_t sysinfo_get_item(const char *name, sysinfo_item_t **root)
@@ -459,4 +592,5 @@
 		root = &global_root;
 	
+	/* Try to find the item or generate data */
 	sysinfo_return_t ret;
 	sysinfo_return_t *ret_ptr = &ret;
@@ -464,4 +598,6 @@
 	
 	if (item != NULL) {
+		/* Item found in the fixed sysinfo tree */
+		
 		ret.tag = item->val_type;
 		switch (item->val_type) {
@@ -482,6 +618,9 @@
 		}
 	} else {
-		if (ret_ptr == NULL)
+		/* No item in the fixed sysinfo tree */
+		if (ret_ptr == NULL) {
+			/* Even no data was generated */
 			ret.tag = SYSINFO_VAL_UNDEFINED;
+		}
 	}
 	
@@ -492,5 +631,10 @@
  *
  * Should be called with interrupts disabled
- * and sysinfo_lock held.
+ * and sysinfo_lock held. The path string passed from
+ * the user space has to be properly null-terminated
+ * (the last passed character must be null).
+ *
+ * @param ptr  Sysinfo path in the user address space.
+ * @param size Size of the path string.
  *
  */
@@ -514,14 +658,33 @@
 }
 
+/** Get the sysinfo value type (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ *
+ * @return Item value type.
+ *
+ */
 unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
 	
+	/* Map generated value types to constant types
+	   (user space does not care whether the
+	   value is constant or generated) */
 	if (ret.tag == SYSINFO_VAL_FUNCTION_VAL)
 		ret.tag = SYSINFO_VAL_VAL;
@@ -535,13 +698,31 @@
 }
 
+/** Get the sysinfo numerical value (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ * @param value_ptr User space pointer where to store the
+ *                  numberical value.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
 unative_t sys_sysinfo_get_value(void *path_ptr, size_t path_size,
     void *value_ptr)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	int rc;
 	
+	/* Only constant or generated numerical value is returned */
 	if ((ret.tag == SYSINFO_VAL_VAL) || (ret.tag == SYSINFO_VAL_FUNCTION_VAL))
 		rc = copy_to_uspace(value_ptr, &ret.val, sizeof(ret.val));
@@ -549,4 +730,5 @@
 		rc = EINVAL;
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
@@ -558,13 +740,31 @@
 }
 
+/** Get the sysinfo binary data size (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ * @param size_ptr  User space pointer where to store the
+ *                  binary data size.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
 unative_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size,
     void *size_ptr)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	int rc;
 	
+	/* Only the size of constant or generated binary data is considered */
 	if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA))
 		rc = copy_to_uspace(size_ptr, &ret.data.size,
@@ -573,4 +773,5 @@
 		rc = EINVAL;
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
@@ -582,14 +783,38 @@
 }
 
+/** Get the sysinfo binary data (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * The user space buffer must be sized exactly according
+ * to the size of the binary data, otherwise the request
+ * fails.
+ *
+ * @param path_ptr    Sysinfo path in the user address space.
+ * @param path_size   Size of the path string.
+ * @param buffer_ptr  User space pointer to the buffer where
+ *                    to store the binary data.
+ * @param buffer_size User space buffer size.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
 unative_t sys_sysinfo_get_data(void *path_ptr, size_t path_size,
     void *buffer_ptr, size_t buffer_size)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	int rc;
 	
+	/* Only constant or generated binary data is considered */
 	if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) {
+		/* Check destination buffer size */
 		if (ret.data.size == buffer_size)
 			rc = copy_to_uspace(buffer_ptr, ret.data.data,
@@ -600,4 +825,5 @@
 		rc = EINVAL;
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
