From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: george.dunlap@eu.citrix.com
Subject: [PATCH 3 of 3 v3] xen, pod: Only sweep in an emergency, and only for 4k pages
Date: Thu, 28 Jun 2012 15:19:44 +0100 [thread overview]
Message-ID: <90f2f1728f906b1fb2e2.1340893184@elijah> (raw)
In-Reply-To: <patchbomb.1340893181@elijah>
# HG changeset patch
# User George Dunlap <george.dunlap@eu.citrix.com>
# Date 1340893085 -3600
# Node ID 90f2f1728f906b1fb2e2d70e5a88b54d0fc190d8
# Parent 9de241075c7f622758f00223805b0279635ff4d9
xen,pod: Only sweep in an emergency, and only for 4k pages
Testing has shown that doing sweeps for superpages slows down boot
significantly, but does not result in a significantly higher number of
superpages after boot. Early sweeping for 4k pages causes superpages
to be broken up unnecessarily.
Only sweep if we're really out of memory.
v2:
- Move unrelated code-motion hunk to another patch
v3:
- Remove now-unused reclaim_super from pod struct
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
@@ -897,34 +897,6 @@ p2m_pod_zero_check(struct p2m_domain *p2
}
#define POD_SWEEP_LIMIT 1024
-static void
-p2m_pod_emergency_sweep_super(struct p2m_domain *p2m)
-{
- unsigned long i, start, limit;
-
- if ( p2m->pod.reclaim_super == 0 )
- {
- p2m->pod.reclaim_super = (p2m->pod.max_guest>>PAGE_ORDER_2M)<<PAGE_ORDER_2M;
- p2m->pod.reclaim_super -= SUPERPAGE_PAGES;
- }
-
- start = p2m->pod.reclaim_super;
- limit = (start > POD_SWEEP_LIMIT) ? (start - POD_SWEEP_LIMIT) : 0;
-
- for ( i=p2m->pod.reclaim_super ; i > 0 ; i -= SUPERPAGE_PAGES )
- {
- p2m_pod_zero_check_superpage(p2m, i);
- /* Stop if we're past our limit and we have found *something*.
- *
- * NB that this is a zero-sum game; we're increasing our cache size
- * by increasing our 'debt'. Since we hold the p2m lock,
- * (entry_count - count) must remain the same. */
- if ( !page_list_empty(&p2m->pod.super) && i < limit )
- break;
- }
-
- 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
@@ -1039,27 +1011,12 @@ p2m_pod_demand_populate(struct p2m_domai
return 0;
}
- /* Once we've ballooned down enough that we can fill the remaining
- * PoD entries from the cache, don't sweep even if the particular
- * list we want to use is empty: that can lead to thrashing zero pages
- * through the cache for no good reason. */
- if ( p2m->pod.entry_count > p2m->pod.count )
- {
+ /* Only sweep if we're actually out of memory. Doing anything else
+ * causes unnecessary time and fragmentation of superpages in the p2m. */
+ if ( p2m->pod.count == 0 )
+ p2m_pod_emergency_sweep(p2m);
- /* If we're low, start a sweep */
- if ( order == PAGE_ORDER_2M && page_list_empty(&p2m->pod.super) )
- /* Note that sweeps scan other ranges in the p2m. In an scenario
- * in which p2m locks are fine-grained, this may result in deadlock.
- * Using trylock on the gfn's as we sweep would avoid it. */
- p2m_pod_emergency_sweep_super(p2m);
-
- if ( page_list_empty(&p2m->pod.single) &&
- ( ( order == PAGE_ORDER_4K )
- || (order == PAGE_ORDER_2M && page_list_empty(&p2m->pod.super) ) ) )
- /* Same comment regarding deadlock applies */
- p2m_pod_emergency_sweep(p2m);
- }
-
+ /* If the sweep failed, give up. */
if ( p2m->pod.count == 0 )
goto 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
@@ -284,7 +284,6 @@ struct p2m_domain {
single; /* Non-super lists */
int count, /* # of pages in cache lists */
entry_count; /* # of pages in p2m marked pod */
- 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
next prev parent reply other threads:[~2012-06-28 14:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 14:19 [PATCH 0 of 3 v3] xen, pod: Populate-on-demand reclaim improvements George Dunlap
2012-06-28 14:19 ` [PATCH 1 of 3 v3] xen, pod: Try to reclaim superpages when ballooning down George Dunlap
2012-06-28 14:19 ` [PATCH 2 of 3 v3] xen, pod: Zero-check recently populated pages (checklast) George Dunlap
2012-06-28 14:19 ` George Dunlap [this message]
2012-06-28 15:16 ` [PATCH 0 of 3 v3] xen, pod: Populate-on-demand reclaim improvements Tim Deegan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=90f2f1728f906b1fb2e2.1340893184@elijah \
--to=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).