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

[PATCH 1/5] xen/mm: Refactor retiring claims in preparation for functional changes



Refactor retiring claims into a function to make the claims accounting
model easier to follow ahead of adding functional changes.

Those functional changes are NUMA claims and retiring claims when
offlining pages if all those pages on the host are claimed. For these
functional changes, we need to return the number of retired claims.

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

This 1st commit of this series is shared with another series which fixes a
number of bugs in reserve_offline_page(). If you could ack it to be merged
independent of the review of this series, we can shave it off both series
in the next review rounds of both series.

History:

Except from the function name change and extending it to return the number
of retired pages (which is required by both series) this commit is the
equivalent of commit 1 of the NUMA claims series v4, with minor changes:

1) The review comments have been applied.
2) In earlier series, I had chosen to use "releasing" and "consuming".
   Instead, speak of "retiring" claims (as they are no longer active),
   which can be used in all contexts, when using the claim for an allocation,
   when resetting a claim and when we've to recall claims when offlining.
2) The 2nd function made sense to be migrated to be part of the main NUMA
   claims commit so it is no longer a part of this commit.
---
 xen/common/page_alloc.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index b1edef87124f..3b0909cc3ce1 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -518,6 +518,24 @@ unsigned long domain_adjust_tot_pages(struct domain *d, 
long pages)
     return d->tot_pages;
 }
 
+/* Retire a portion of the global claims of a domain on global memory */
+static unsigned long claims_retire_global(struct domain *d,
+                                          unsigned long pages_to_retire)
+{
+    unsigned long retired;
+
+    ASSERT(spin_is_locked(&heap_lock));
+
+    /* If the withdrawal is larger than the claims, don't withdraw beyond */
+    retired = min(d->outstanding_pages + 0UL, pages_to_retire);
+
+    /* Assert the invariant of outstanding_claims not going negative */
+    ASSERT(retired <= outstanding_claims);
+    outstanding_claims -= retired;
+    d->outstanding_pages -= retired;
+    return retired;
+}
+
 int domain_set_outstanding_pages(struct domain *d, unsigned long pages)
 {
     int ret = -ENOMEM;
@@ -535,8 +553,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;
+        claims_retire_global(d, d->outstanding_pages);
         ret = 0;
         goto out;
     }
@@ -1067,11 +1084,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;
+        claims_retire_global(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®.