x86/mem_sharing: Fix saved mfns stat for failed unsharing
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 26 Apr 2012 09:03:08 +0000 (10:03 +0100)
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 26 Apr 2012 09:03:08 +0000 (10:03 +0100)
If unsharing fails, the decrease of the nr_saved_mfns stat was not being
undone. This would result in an underflow of the stat, as the retry would later
decrease the counter again.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/mem_sharing.c

index d4488ec9f6f8406fa7e465798f594096a2c38f25..aec92c6143f310af7b7bff1bfd880e7f26d5a2bd 100644 (file)
@@ -997,6 +997,8 @@ gfn_found:
     page = alloc_domheap_page(d, 0);
     if ( !page ) 
     {
+        /* Undo dec of nr_saved_mfns, as the retry will decrease again. */
+        atomic_inc(&nr_saved_mfns);
         mem_sharing_page_unlock(old_page);
         put_gfn(d, gfn);
         /* Caller is responsible for placing an event