From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org, david.vrabel@citrix.com, JBeulich@suse.com
Cc: xen-devel@lists.xensource.com,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 8/8] xen/setup: Combine the two hypercall functions - since they are quite similar.
Date: Mon, 16 Apr 2012 13:15:39 -0400 [thread overview]
Message-ID: <1334596539-18172-9-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1334596539-18172-1-git-send-email-konrad.wilk@oracle.com>
They use the same set of arguments, so it is just the matter
of using the proper hypercall.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/xen/setup.c | 81 ++++++++++++++++++-------------------------------
1 files changed, 30 insertions(+), 51 deletions(-)
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index b44d409..506a3e6 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -83,8 +83,8 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
__set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
}
-static unsigned long __init xen_release_chunk(unsigned long start,
- unsigned long end)
+static unsigned long __init xen_do_chunk(unsigned long start,
+ unsigned long end, bool release)
{
struct xen_memory_reservation reservation = {
.address_bits = 0,
@@ -95,60 +95,36 @@ static unsigned long __init xen_release_chunk(unsigned long start,
unsigned long pfn;
int ret;
- for(pfn = start; pfn < end; pfn++) {
- unsigned long mfn = pfn_to_mfn(pfn);
-
- /* Make sure pfn exists to start with */
- if (mfn == INVALID_P2M_ENTRY || mfn_to_pfn(mfn) != pfn)
- continue;
-
- set_xen_guest_handle(reservation.extent_start, &mfn);
- reservation.nr_extents = 1;
-
- ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
- &reservation);
- WARN(ret != 1, "Failed to release pfn %lx err=%d\n", pfn, ret);
- if (ret == 1) {
- __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
- len++;
- }
- }
- if (len)
- printk(KERN_INFO "Freeing %lx-%lx pfn range: %lu pages freed\n",
- start, end, len);
-
- return len;
-}
-static unsigned long __init xen_populate_physmap(unsigned long start,
- unsigned long end)
-{
- struct xen_memory_reservation reservation = {
- .address_bits = 0,
- .extent_order = 0,
- .domid = DOMID_SELF
- };
- unsigned long len = 0;
- int ret;
-
for (pfn = start; pfn < end; pfn++) {
unsigned long frame;
+ unsigned long mfn = pfn_to_mfn(pfn);
- /* Make sure pfn does not exists to start with */
- if (pfn_to_mfn(pfn) != INVALID_P2M_ENTRY)
- continue;
-
- frame = pfn;
+ if (release) {
+ /* Make sure pfn exists to start with */
+ if (mfn == INVALID_P2M_ENTRY || mfn_to_pfn(mfn) != pfn)
+ continue;
+ frame = mfn;
+ } else {
+ if (mfn != INVALID_P2M_ENTRY)
+ continue;
+ frame = pfn;
+ }
set_xen_guest_handle(reservation.extent_start, &frame);
reservation.nr_extents = 1;
- ret = HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation);
- WARN(ret != 1, "Failed to populate pfn %lx err=%d\n", pfn, ret);
+ ret = HYPERVISOR_memory_op(release ? XENMEM_decrease_reservation : XENMEM_populate_physmap,
+ &reservation);
+ WARN(ret != 1, "Failed to %s pfn %lx err=%d\n",
+ release ? "release" : "populate", pfn, ret);
+
if (ret == 1) {
- if (!early_set_phys_to_machine(pfn, frame)) {
+ if (!early_set_phys_to_machine(pfn, release ? INVALID_P2M_ENTRY : frame)) {
+ if (release)
+ break;
set_xen_guest_handle(reservation.extent_start, &frame);
reservation.nr_extents = 1;
ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
- &reservation);
+ &reservation);
break;
}
len++;
@@ -156,8 +132,11 @@ static unsigned long __init xen_populate_physmap(unsigned long start,
break;
}
if (len)
- printk(KERN_INFO "Populated %lx-%lx pfn range: %lu pages added\n",
- start, end, len);
+ printk(KERN_INFO "%s %lx-%lx pfn range: %lu pages %s\n",
+ release ? "Freeing" : "Populating",
+ start, end, len,
+ release ? "freed" : "added");
+
return len;
}
static unsigned long __init xen_populate_chunk(
@@ -211,7 +190,7 @@ static unsigned long __init xen_populate_chunk(
if (credits > capacity)
credits = capacity;
- pfns = xen_populate_physmap(dest_pfn, dest_pfn + credits);
+ pfns = xen_do_chunk(dest_pfn, dest_pfn + credits, false);
done += pfns;
credits_left -= pfns;
*last_pfn = (dest_pfn + pfns);
@@ -249,8 +228,8 @@ static unsigned long __init xen_set_identity_and_release(
if (start_pfn < end_pfn) {
if (start_pfn < nr_pages)
- released += xen_release_chunk(
- start_pfn, min(end_pfn, nr_pages));
+ released += xen_do_chunk(
+ start_pfn, min(end_pfn, nr_pages), true);
identity += set_phys_range_identity(
start_pfn, end_pfn);
--
1.7.7.5
next prev parent reply other threads:[~2012-04-16 17:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-16 17:15 [PATCH] auto balloon initial domain and fix dom0_mem=X inconsistencies (v5) Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 1/8] xen/p2m: Move code around to allow for better re-usage Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 2/8] xen/p2m: Allow alloc_p2m_middle to call reserve_brk depending on argument Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 3/8] xen/p2m: Collapse early_alloc_p2m_middle redundant checks Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 4/8] xen/p2m: An early bootup variant of set_phys_to_machine Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 6/8] xen/setup: Work properly with 'dom0_mem=X' or with not dom0_mem Konrad Rzeszutek Wilk
2012-05-03 11:54 ` [Xen-devel] " David Vrabel
2012-04-16 17:15 ` [PATCH 7/8] xen/setup: Populate freed MFNs from non-RAM E820 entries and gaps to E820 RAM Konrad Rzeszutek Wilk
2012-05-03 11:56 ` [Xen-devel] " David Vrabel
2012-04-16 17:15 ` Konrad Rzeszutek Wilk [this message]
2012-05-03 11:58 ` [Xen-devel] [PATCH 8/8] xen/setup: Combine the two hypercall functions - since they are quite similar David Vrabel
2012-05-03 15:37 ` Konrad Rzeszutek Wilk
2012-05-01 16:37 ` [PATCH] auto balloon initial domain and fix dom0_mem=X inconsistencies (v5) Konrad Rzeszutek Wilk
2012-05-02 9:05 ` Jan Beulich
2012-05-03 11:48 ` David Vrabel
2012-05-03 15:15 ` [Xen-devel] " David Vrabel
2012-05-03 16:27 ` David Vrabel
2012-05-07 18:48 ` Konrad Rzeszutek Wilk
2012-05-08 18:12 ` David Vrabel
2012-05-08 18:24 ` Konrad Rzeszutek Wilk
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=1334596539-18172-9-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=JBeulich@suse.com \
--cc=david.vrabel@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--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).