From: Bob Liu <lliubbo@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: keir@xen.org, ian.campbell@citrix.com,
George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
JBeulich@suse.com
Subject: [PATCH v2 2/3] xen: introduce function merge_free_trunks
Date: Mon, 30 Jun 2014 21:39:43 +0800 [thread overview]
Message-ID: <1404135584-29206-2-git-send-email-bob.liu@oracle.com> (raw)
In-Reply-To: <1404135584-29206-1-git-send-email-bob.liu@oracle.com>
Separated from free_heap_pages(), will be used by idle vcpu scrubbing.
Signed-off-by: Bob Liu <bob.liu@oracle.com>
---
xen/common/page_alloc.c | 118 +++++++++++++++++++++++++----------------------
1 file changed, 64 insertions(+), 54 deletions(-)
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index c184f86..ab293c8 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -831,11 +831,73 @@ static int reserve_offlined_page(struct page_info *head)
return count;
}
+static void merge_free_trunks(struct page_info *pg, unsigned int order,
+ unsigned int node, unsigned int zone, bool_t need_scrub)
+{
+ unsigned long mask;
+
+ ASSERT(spin_is_locked(&heap_lock));
+
+ /* Merge chunks as far as possible. */
+ while ( order < MAX_ORDER )
+ {
+ mask = 1UL << order;
+
+ if ( (page_to_mfn(pg) & mask) )
+ {
+ /* Merge with predecessor block? */
+ if ( !mfn_valid(page_to_mfn(pg-mask)) ||
+ !page_state_is(pg-mask, free) ||
+ (PFN_ORDER(pg-mask) != order) ||
+ (phys_to_nid(page_to_maddr(pg-mask)) != node) )
+ break;
+ /* If we need scrub, only merge with PGC_need_scrub pages */
+ if ( need_scrub )
+ {
+ if ( !test_bit(_PGC_need_scrub, &(pg-mask)->count_info) )
+ break;
+ }
+ else
+ {
+ if ( test_bit(_PGC_need_scrub, &(pg-mask)->count_info) )
+ break;
+ }
+ pg -= mask;
+ page_list_del(pg, &heap(node, zone, order));
+ }
+ else
+ {
+ /* Merge with successor block? */
+ if ( !mfn_valid(page_to_mfn(pg+mask)) ||
+ !page_state_is(pg+mask, free) ||
+ (PFN_ORDER(pg+mask) != order) ||
+ (phys_to_nid(page_to_maddr(pg+mask)) != node) )
+ break;
+ if ( need_scrub )
+ {
+ if ( !test_bit(_PGC_need_scrub, &(pg+mask)->count_info) )
+ break;
+ }
+ else
+ {
+ if ( test_bit(_PGC_need_scrub, &(pg+mask)->count_info) )
+ break;
+ }
+ page_list_del(pg + mask, &heap(node, zone, order));
+ }
+
+ order++;
+ }
+
+ PFN_ORDER(pg) = order;
+ page_list_add_tail(pg, &heap(node, zone, order));
+}
+
/* Free 2^@order set of pages. */
static void free_heap_pages(
struct page_info *pg, unsigned int order, bool_t need_scrub)
{
- unsigned long mask, mfn = page_to_mfn(pg);
+ unsigned long mfn = page_to_mfn(pg);
unsigned int i, node = phys_to_nid(page_to_maddr(pg)), tainted = 0;
unsigned int zone = page_to_zone(pg);
@@ -891,59 +953,7 @@ static void free_heap_pages(
}
}
- /* Merge chunks as far as possible. */
- while ( order < MAX_ORDER )
- {
- mask = 1UL << order;
-
- if ( (page_to_mfn(pg) & mask) )
- {
- /* Merge with predecessor block? */
- if ( !mfn_valid(page_to_mfn(pg-mask)) ||
- !page_state_is(pg-mask, free) ||
- (PFN_ORDER(pg-mask) != order) ||
- (phys_to_nid(page_to_maddr(pg-mask)) != node) )
- break;
- /* If we need scrub, only merge with PGC_need_scrub pages */
- if ( need_scrub )
- {
- if ( !test_bit(_PGC_need_scrub, &(pg-mask)->count_info) )
- break;
- }
- else
- {
- if ( test_bit(_PGC_need_scrub, &(pg-mask)->count_info) )
- break;
- }
- pg -= mask;
- page_list_del(pg, &heap(node, zone, order));
- }
- else
- {
- /* Merge with successor block? */
- if ( !mfn_valid(page_to_mfn(pg+mask)) ||
- !page_state_is(pg+mask, free) ||
- (PFN_ORDER(pg+mask) != order) ||
- (phys_to_nid(page_to_maddr(pg+mask)) != node) )
- break;
- if ( need_scrub )
- {
- if ( !test_bit(_PGC_need_scrub, &(pg+mask)->count_info) )
- break;
- }
- else
- {
- if ( test_bit(_PGC_need_scrub, &(pg+mask)->count_info) )
- break;
- }
- page_list_del(pg + mask, &heap(node, zone, order));
- }
-
- order++;
- }
-
- PFN_ORDER(pg) = order;
- page_list_add_tail(pg, &heap(node, zone, order));
+ merge_free_trunks(pg, order, node, zone, need_scrub);
if ( tainted )
reserve_offlined_page(pg);
--
1.7.10.4
next prev parent reply other threads:[~2014-06-30 13:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 13:39 [PATCH v2 1/3] xen: delay page scrubbing to allocation path Bob Liu
2014-06-30 13:39 ` Bob Liu [this message]
2014-06-30 15:58 ` [PATCH v2 2/3] xen: introduce function merge_free_trunks Jan Beulich
2014-07-01 8:14 ` Bob Liu
2014-07-01 8:27 ` Jan Beulich
2014-06-30 13:39 ` [PATCH v2 3/3] xen: use idle vcpus to scrub pages Bob Liu
2014-07-01 9:12 ` Jan Beulich
2014-07-01 12:25 ` Bob Liu
2014-07-01 12:59 ` Jan Beulich
2014-07-02 6:27 ` Bob Liu
2014-07-07 12:20 ` Bob Liu
2014-07-15 9:16 ` Bob Liu
2014-07-23 0:38 ` Konrad Rzeszutek Wilk
2014-07-23 1:30 ` Bob Liu
2014-07-23 7:28 ` Jan Beulich
2014-07-24 2:08 ` Bob Liu
2014-07-24 6:24 ` Jan Beulich
2014-07-25 0:42 ` Bob Liu
2014-07-25 6:51 ` Jan Beulich
2014-07-25 7:28 ` Bob Liu
2014-07-25 7:36 ` Jan Beulich
2014-07-25 8:18 ` Bob Liu
2014-07-25 8:28 ` Jan Beulich
2014-06-30 15:56 ` [PATCH v2 1/3] xen: delay page scrubbing to allocation path Jan Beulich
2014-07-01 8:12 ` Bob Liu
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=1404135584-29206-2-git-send-email-bob.liu@oracle.com \
--to=lliubbo@gmail.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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).