[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v6 1/7] xen/mm: Refactor claim deduction for later functional changes



Refactor claim deduction to make the claims accounting model easier to
follow ahead of later functional changes.

Three new callers will need to deduct claims, and two of them will also
need the number of pages deducted to be returned.

No functional change.

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@xxxxxxxxxx>
---
History:

Functionally unchanged since v4, only minor cleanups have been applied and:
- Updated the function name deduct_global_claims() to follow standard naming.
- Moved the other function into another commit as it had no users here.
---
 xen/common/page_alloc.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index b1edef87124f..80577aa4d50c 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -518,6 +518,19 @@ unsigned long domain_adjust_tot_pages(struct domain *d, 
long pages)
     return d->tot_pages;
 }
 
+/* Deduct up to the given amount of pages from the global claims of a domain */
+static unsigned long deduct_global_claims(struct domain *d,
+                                          unsigned long reduction)
+{
+    reduction = min(reduction, d->outstanding_pages + 0UL);
+    ASSERT(reduction <= outstanding_claims);
+
+    outstanding_claims -= reduction;
+    d->outstanding_pages -= reduction;
+
+    return reduction;
+}
+
 int domain_set_outstanding_pages(struct domain *d, unsigned long pages)
 {
     int ret = -ENOMEM;
@@ -535,8 +548,7 @@ int domain_set_outstanding_pages(struct domain *d, unsigned 
long pages)
     /* pages==0 means "unset" the claim. */
     if ( pages == 0 )
     {
-        outstanding_claims -= d->outstanding_pages;
-        d->outstanding_pages = 0;
+        deduct_global_claims(d, d->outstanding_pages);
         ret = 0;
         goto out;
     }
@@ -1067,11 +1079,7 @@ static struct page_info *alloc_heap_pages(
          * the domain being destroyed before creation is finished.  Losing part
          * of the claim makes no difference.
          */
-        unsigned long outstanding = min(d->outstanding_pages + 0UL, request);
-
-        BUG_ON(outstanding > outstanding_claims);
-        outstanding_claims -= outstanding;
-        d->outstanding_pages -= outstanding;
+        deduct_global_claims(d, request);
     }
 
     check_low_mem_virq();
-- 
2.39.5




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.