[xen staging] make domain_adjust_tot_pages() __must_check

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] make domain_adjust_tot_pages() __must_check

patchbot
commit c46dba0d72e519743823c76c676858ad1af48b90
Author:     Jan Beulich <[hidden email]>
AuthorDate: Thu Dec 6 12:19:04 2018 +0100
Commit:     Jan Beulich <[hidden email]>
CommitDate: Thu Dec 6 12:19:04 2018 +0100

    make domain_adjust_tot_pages() __must_check
   
    Even if unlikely, donate_page() should not ignore the possible need to
    obtain a domain reference. To make people look more closely when they
    add new uses of domain_adjust_tot_pages(), force its return value to be
    checked. This in turn requires a benign change to assign_pages().
   
    Signed-off-by: Jan Beulich <[hidden email]>
    Acked-by: Andrew Cooper <[hidden email]>
---
 xen/arch/x86/mm.c       | 3 ++-
 xen/common/page_alloc.c | 4 +---
 xen/include/xen/mm.h    | 3 ++-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 28a003063e..b3350eee35 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4009,7 +4009,8 @@ int donate_page(
     {
         if ( d->tot_pages >= d->max_pages )
             goto fail;
-        domain_adjust_tot_pages(d, 1);
+        if ( unlikely(domain_adjust_tot_pages(d, 1) == 1) )
+            get_knownalive_domain(d);
     }
 
     page->count_info = PGC_allocated | 1;
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index fd3b0aaa83..b314b5cee8 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -2273,10 +2273,8 @@ int assign_pages(
             goto out;
         }
 
-        if ( unlikely(d->tot_pages == 0) )
+        if ( unlikely(domain_adjust_tot_pages(d, 1 << order) == (1 << order)) )
             get_knownalive_domain(d);
-
-        domain_adjust_tot_pages(d, 1 << order);
     }
 
     for ( i = 0; i < (1 << order); i++ )
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 054d02e6c0..e971147234 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -190,7 +190,8 @@ int destroy_xen_mappings(unsigned long v, unsigned long e);
  */
 int populate_pt_range(unsigned long virt, unsigned long nr_mfns);
 /* Claim handling */
-unsigned long domain_adjust_tot_pages(struct domain *d, long pages);
+unsigned long __must_check domain_adjust_tot_pages(struct domain *d,
+    long pages);
 int domain_set_outstanding_pages(struct domain *d, unsigned long pages);
 void get_outstanding_claims(uint64_t *free_pages, uint64_t *outstanding_pages);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog