From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: george.dunlap@eu.citrix.com
Subject: [PATCH 4 of 4] xen, pod: Try to reclaim superpages when ballooning down
Date: Wed, 27 Jun 2012 17:57:31 +0100 [thread overview]
Message-ID: <71a22d6d940f27d8dfbc.1340816251@elijah> (raw)
In-Reply-To: <patchbomb.1340816247@elijah>
# HG changeset patch
# User George Dunlap <george.dunlap@eu.citrix.com>
# Date 1340815812 -3600
# Node ID 71a22d6d940f27d8dfbcfc12d1377e4622f981bd
# Parent c71f52608fd8867062cc40a1354305f2af17b2c3
xen,pod: Try to reclaim superpages when ballooning down
Windows balloon drivers can typically only get 4k pages from the kernel,
and so hand them back at that level. Try to regain superpages by checking
the superpage frame that the 4k page is in to see if we can reclaim the whole
thing for the PoD cache.
This also modifies p2m_pod_zero_check_superpage() to return SUPERPAGE_PAGES on
success.
v2:
- Rewritten to simply to the check as in demand-fault case, without needing
to know that the p2m entry is a superpage.
- Also, took out the re-writing of the reclaim loop, leaving it optimized for
4k pages (by far the most common case), and simplifying the patch.
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
@@ -488,6 +488,10 @@ p2m_pod_offline_or_broken_replace(struct
return;
}
+static int
+p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn);
+
+
/* This function is needed for two reasons:
* + To properly handle clearing of PoD entries
* + To "steal back" memory being freed for the PoD cache, rather than
@@ -505,8 +509,8 @@ p2m_pod_decrease_reservation(struct doma
int i;
struct p2m_domain *p2m = p2m_get_hostp2m(d);
- int steal_for_cache = 0;
- int pod = 0, nonpod = 0, ram = 0;
+ int steal_for_cache;
+ int pod, nonpod, ram;
gfn_lock(p2m, gpfn, order);
pod_lock(p2m);
@@ -516,13 +520,15 @@ p2m_pod_decrease_reservation(struct doma
if ( p2m->pod.entry_count == 0 )
goto out_unlock;
+ if ( unlikely(d->is_dying) )
+ goto out_unlock;
+
+recount:
+ pod = nonpod = ram = 0;
+
/* Figure out if we need to steal some freed memory for our cache */
steal_for_cache = ( p2m->pod.entry_count > p2m->pod.count );
- if ( unlikely(d->is_dying) )
- goto out_unlock;
-
- /* See what's in here. */
/* FIXME: Add contiguous; query for PSE entries? */
for ( i=0; i<(1<<order); i++)
{
@@ -556,7 +562,16 @@ p2m_pod_decrease_reservation(struct doma
goto out_entry_check;
}
- /* FIXME: Steal contig 2-meg regions for cache */
+ /* Try to grab entire superpages if possible. Since the common case is for drivers
+ * to pass back singleton pages, see if we can take the whole page back and mark the
+ * rest PoD. */
+ if ( steal_for_cache
+ && p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES-1)))
+ {
+ /* Since order may be arbitrary, we may have taken more or less
+ * than we were actually asked to; so just re-count from scratch */
+ goto recount;
+ }
/* Process as long as:
* + There are PoD entries to handle, or
@@ -758,6 +773,8 @@ p2m_pod_zero_check_superpage(struct p2m_
p2m_pod_cache_add(p2m, mfn_to_page(mfn0), PAGE_ORDER_2M);
p2m->pod.entry_count += SUPERPAGE_PAGES;
+ ret = SUPERPAGE_PAGES;
+
out_reset:
if ( reset )
set_p2m_entry(p2m, gfn, mfn0, 9, type0, p2m->default_access);
next prev parent reply other threads:[~2012-06-27 16:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 16:57 [PATCH 0 of 4] xen, pod: Populate-on-demand reclaim improvements George Dunlap
2012-06-27 16:57 ` [PATCH 1 of 4] xen,pod: Cosmetic code motion George Dunlap
2012-06-28 12:04 ` Tim Deegan
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
2012-06-27 16:57 ` [PATCH 3 of 4] xen, pod: Only sweep in an emergency, and only for 4k pages George Dunlap
2012-06-28 12:48 ` Tim Deegan
2012-06-27 16:57 ` George Dunlap [this message]
2012-06-28 12:45 ` [PATCH 4 of 4] xen, pod: Try to reclaim superpages when ballooning down Tim Deegan
2012-06-28 12:53 ` [PATCH 0 of 4] xen, pod: Populate-on-demand reclaim improvements Tim Deegan
2012-06-28 13:04 ` George Dunlap
2012-06-28 13:51 ` George Dunlap
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=71a22d6d940f27d8dfbc.1340816251@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).