diff mbox

[v3,14/15] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest

Message ID 20171002125941.11274-15-julien.grall@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Julien Grall Oct. 2, 2017, 12:59 p.m. UTC
Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>

---

Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

    Changes in v3:
        - Add Wei's reviewed-by

    Changes in v2:
        - Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 11 +++++------
 xen/include/asm-x86/p2m.h |  4 ++--
 2 files changed, 7 insertions(+), 8 deletions(-)

Comments

George Dunlap Oct. 2, 2017, 4:23 p.m. UTC | #1
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Wei Liu <wei.liu2@citrix.com>

Reviewed-by: George Dunlap <george.dunlap@citrix.com>
diff mbox

Patch

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 55f2fa4f18..8d50a0db85 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -977,10 +977,10 @@  p2m_pod_emergency_sweep(struct p2m_domain *p2m)
     p2m_type_t t;
 
 
-    if ( p2m->pod.reclaim_single == 0 )
+    if ( gfn_eq(p2m->pod.reclaim_single, _gfn(0)) )
         p2m->pod.reclaim_single = p2m->pod.max_guest;
 
-    start = p2m->pod.reclaim_single;
+    start = gfn_x(p2m->pod.reclaim_single);
     limit = (start > POD_SWEEP_LIMIT) ? (start - POD_SWEEP_LIMIT) : 0;
 
     /* FIXME: Figure out how to avoid superpages */
@@ -990,7 +990,7 @@  p2m_pod_emergency_sweep(struct p2m_domain *p2m)
      * careful about spinlock recursion limits and POD_SWEEP_STRIDE.
      */
     p2m_lock(p2m);
-    for ( i = p2m->pod.reclaim_single; i > 0 ; i-- )
+    for ( i = gfn_x(p2m->pod.reclaim_single); i > 0 ; i-- )
     {
         p2m_access_t a;
         (void)p2m->get_entry(p2m, _gfn(i), &t, &a, 0, NULL, NULL);
@@ -1020,7 +1020,7 @@  p2m_pod_emergency_sweep(struct p2m_domain *p2m)
         p2m_pod_zero_check(p2m, gfns, j);
 
     p2m_unlock(p2m);
-    p2m->pod.reclaim_single = i ? i - 1 : i;
+    p2m->pod.reclaim_single = _gfn(i ? i - 1 : i);
 
 }
 
@@ -1135,8 +1135,7 @@  p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
         goto out_of_memory;
 
     /* Keep track of the highest gfn demand-populated by a guest fault */
-    if ( gfn_x(gfn) > p2m->pod.max_guest )
-        p2m->pod.max_guest = gfn_x(gfn);
+    p2m->pod.max_guest = gfn_max(gfn, p2m->pod.max_guest);
 
     /*
      * Get a page f/ the cache.  A NULL return value indicates that the
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 1ae9216404..e8a9dca480 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -316,8 +316,8 @@  struct p2m_domain {
                          single;       /* Non-super lists                   */
         long             count,        /* # of pages in cache lists         */
                          entry_count;  /* # of pages in p2m marked pod      */
-        unsigned long    reclaim_single; /* Last gpfn of a scan */
-        unsigned long    max_guest;    /* gpfn of max guest demand-populate */
+        gfn_t            reclaim_single; /* Last gfn of a scan */
+        gfn_t            max_guest;    /* gfn of max guest demand-populate */
 
         /*
          * Tracking of the most recently populated PoD pages, for eager