xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2 of 4] xen, pod: Zero-check recently populated pages (checklast)
  2012-06-27 16:57 [PATCH 0 of 4] xen, pod: Populate-on-demand reclaim improvements George Dunlap
@ 2012-06-27 16:57 ` George Dunlap
  2012-06-28 12:48   ` Tim Deegan
  0 siblings, 1 reply; 3+ messages in thread
From: George Dunlap @ 2012-06-27 16:57 UTC (permalink / raw)
  To: xen-devel; +Cc: george.dunlap

# HG changeset patch
# User George Dunlap <george.dunlap@eu.citrix.com>
# Date 1340815812 -3600
# Node ID ea827c449088a1017b6e5a9564eb33df70f8a9c6
# Parent  b4e1fec1c98f6cbad666a972f473854518c25500
xen,pod: Zero-check recently populated pages (checklast)

When demand-populating pages due to guest accesses, check recently populated
pages to see if we can reclaim them for the cache.  This should keep the PoD
cache filled when the start-of-day scrubber is going through.

The number 128 was chosen by experiment.  Windows does its page
scrubbing in parallel; while a small nubmer like 4 works well for
single VMs, it breaks down as multiple vcpus are scrubbing different
pages in parallel.  Increasing to 128 works well for higher numbers of
vcpus.

v2:
 - Wrapped some long lines
 - unsigned int for index, unsigned long for array

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -909,6 +909,27 @@ p2m_pod_emergency_sweep_super(struct p2m
     p2m->pod.reclaim_super = i ? i - SUPERPAGE_PAGES : 0;
 }
 
+/* When populating a new superpage, look at recently populated superpages
+ * hoping that they've been zeroed.  This will snap up zeroed pages as soon as 
+ * the guest OS is done with them. */
+static void
+p2m_pod_check_last_super(struct p2m_domain *p2m, unsigned long gfn_aligned)
+{
+    unsigned long check_gfn;
+
+    ASSERT(p2m->pod.last_populated_index < POD_HISTORY_MAX);
+
+    check_gfn = p2m->pod.last_populated[p2m->pod.last_populated_index];
+
+    p2m->pod.last_populated[p2m->pod.last_populated_index] = gfn_aligned;
+
+    p2m->pod.last_populated_index =
+        ( p2m->pod.last_populated_index + 1 ) % POD_HISTORY_MAX;
+
+    p2m->pod.reclaim_super += p2m_pod_zero_check_superpage(p2m, check_gfn);
+}
+
+
 #define POD_SWEEP_STRIDE  16
 static void
 p2m_pod_emergency_sweep(struct p2m_domain *p2m)
@@ -1066,6 +1087,12 @@ p2m_pod_demand_populate(struct p2m_domai
         __trace_var(TRC_MEM_POD_POPULATE, 0, sizeof(t), &t);
     }
 
+    /* Check the last guest demand-populate */
+    if ( p2m->pod.entry_count > p2m->pod.count 
+         && order == 9
+         && q & P2M_ALLOC )
+        p2m_pod_check_last_super(p2m, gfn_aligned);
+
     pod_unlock(p2m);
     return 0;
 out_of_memory:
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -287,6 +287,10 @@ struct p2m_domain {
         unsigned         reclaim_super; /* Last gpfn of a scan */
         unsigned         reclaim_single; /* Last gpfn of a scan */
         unsigned         max_guest;    /* gpfn of max guest demand-populate */
+#define POD_HISTORY_MAX 128
+        /* gpfn of last guest superpage demand-populated */
+        unsigned long    last_populated[POD_HISTORY_MAX]; 
+        unsigned int     last_populated_index;
         mm_lock_t        lock;         /* Locking of private pod structs,   *
                                         * not relying on the p2m lock.      */
     } pod;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2 of 4] xen, pod: Zero-check recently populated pages (checklast)
       [not found] <mailman.8077.1340818561.1399.xen-devel@lists.xen.org>
@ 2012-06-27 17:44 ` Andres Lagar-Cavilla
  0 siblings, 0 replies; 3+ messages in thread
From: Andres Lagar-Cavilla @ 2012-06-27 17:44 UTC (permalink / raw)
  To: xen-devel; +Cc: george.dunlap

> # HG changeset patch
> # User George Dunlap <george.dunlap@eu.citrix.com>
> # Date 1340815812 -3600
> # Node ID ea827c449088a1017b6e5a9564eb33df70f8a9c6
> # Parent  b4e1fec1c98f6cbad666a972f473854518c25500
> xen,pod: Zero-check recently populated pages (checklast)
>
> When demand-populating pages due to guest accesses, check recently
> populated
> pages to see if we can reclaim them for the cache.  This should keep the
> PoD
> cache filled when the start-of-day scrubber is going through.
>
> The number 128 was chosen by experiment.  Windows does its page
> scrubbing in parallel; while a small nubmer like 4 works well for
> single VMs, it breaks down as multiple vcpus are scrubbing different
> pages in parallel.  Increasing to 128 works well for higher numbers of
> vcpus.
>
> v2:
>  - Wrapped some long lines
>  - unsigned int for index, unsigned long for array
>
> Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
>
> diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
> --- a/xen/arch/x86/mm/p2m-pod.c
> +++ b/xen/arch/x86/mm/p2m-pod.c
> @@ -909,6 +909,27 @@ p2m_pod_emergency_sweep_super(struct p2m
>      p2m->pod.reclaim_super = i ? i - SUPERPAGE_PAGES : 0;
>  }
>
> +/* When populating a new superpage, look at recently populated superpages
> + * hoping that they've been zeroed.  This will snap up zeroed pages as
> soon as
> + * the guest OS is done with them. */
> +static void
> +p2m_pod_check_last_super(struct p2m_domain *p2m, unsigned long
> gfn_aligned)
> +{
> +    unsigned long check_gfn;
> +
> +    ASSERT(p2m->pod.last_populated_index < POD_HISTORY_MAX);
> +
> +    check_gfn = p2m->pod.last_populated[p2m->pod.last_populated_index];
> +
> +    p2m->pod.last_populated[p2m->pod.last_populated_index] = gfn_aligned;
> +
> +    p2m->pod.last_populated_index =
> +        ( p2m->pod.last_populated_index + 1 ) % POD_HISTORY_MAX;
> +
> +    p2m->pod.reclaim_super += p2m_pod_zero_check_superpage(p2m,
> check_gfn);
> +}
> +
> +
>  #define POD_SWEEP_STRIDE  16
>  static void
>  p2m_pod_emergency_sweep(struct p2m_domain *p2m)
> @@ -1066,6 +1087,12 @@ p2m_pod_demand_populate(struct p2m_domai
>          __trace_var(TRC_MEM_POD_POPULATE, 0, sizeof(t), &t);
>      }
>
> +    /* Check the last guest demand-populate */
> +    if ( p2m->pod.entry_count > p2m->pod.count
> +         && order == 9
s/9/PAGE_ORDER_2M/

Otherwise the series looks good to me.
Andres
> +         && q & P2M_ALLOC )
> +        p2m_pod_check_last_super(p2m, gfn_aligned);
> +
>      pod_unlock(p2m);
>      return 0;
>  out_of_memory:
> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -287,6 +287,10 @@ struct p2m_domain {
>          unsigned         reclaim_super; /* Last gpfn of a scan */
>          unsigned         reclaim_single; /* Last gpfn of a scan */
>          unsigned         max_guest;    /* gpfn of max guest
> demand-populate */
> +#define POD_HISTORY_MAX 128
> +        /* gpfn of last guest superpage demand-populated */
> +        unsigned long    last_populated[POD_HISTORY_MAX];
> +        unsigned int     last_populated_index;
>          mm_lock_t        lock;         /* Locking of private pod structs,
>   *
>                                          * not relying on the p2m lock.
>   */
>      } pod;
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2 of 4] xen, pod: Zero-check recently populated pages (checklast)
  2012-06-27 16:57 ` [PATCH 2 of 4] xen, pod: Zero-check recently populated pages (checklast) George Dunlap
@ 2012-06-28 12:48   ` Tim Deegan
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Deegan @ 2012-06-28 12:48 UTC (permalink / raw)
  To: George Dunlap; +Cc: xen-devel

At 17:57 +0100 on 27 Jun (1340819849), George Dunlap wrote:
> # HG changeset patch
> # User George Dunlap <george.dunlap@eu.citrix.com>
> # Date 1340815812 -3600
> # Node ID ea827c449088a1017b6e5a9564eb33df70f8a9c6
> # Parent  b4e1fec1c98f6cbad666a972f473854518c25500
> xen,pod: Zero-check recently populated pages (checklast)
> 
> When demand-populating pages due to guest accesses, check recently populated
> pages to see if we can reclaim them for the cache.  This should keep the PoD
> cache filled when the start-of-day scrubber is going through.
> 
> The number 128 was chosen by experiment.  Windows does its page
> scrubbing in parallel; while a small nubmer like 4 works well for
> single VMs, it breaks down as multiple vcpus are scrubbing different
> pages in parallel.  Increasing to 128 works well for higher numbers of
> vcpus.
> 
> v2:
>  - Wrapped some long lines
>  - unsigned int for index, unsigned long for array
> 
> Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>

Acked-by: Tim Deegan <tim@xen.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-28 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.8077.1340818561.1399.xen-devel@lists.xen.org>
2012-06-27 17:44 ` [PATCH 2 of 4] xen, pod: Zero-check recently populated pages (checklast) Andres Lagar-Cavilla
2012-06-27 16:57 [PATCH 0 of 4] xen, pod: Populate-on-demand reclaim improvements George Dunlap
2012-06-27 16:57 ` [PATCH 2 of 4] xen, pod: Zero-check recently populated pages (checklast) George Dunlap
2012-06-28 12:48   ` Tim Deegan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).