From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
"Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Ian Campbell <Ian.Campbell@citrix.com>,
"stefano.stabellini@eu.citrix.com"
<stefano.stabellini@eu.citrix.com>
Subject: [PATCH] PVH linux: Use ballooning to allocate grant table pages
Date: Thu, 31 Jan 2013 18:30:15 -0800 [thread overview]
Message-ID: <20130131183015.13bc2bff@mantra.us.oracle.com> (raw)
This patch fixes a fixme in Linux to use alloc_xenballooned_pages() to
allocate pfns for grant table pages instead of kmalloc. This also
simplifies add to physmap on the xen side a bit.
Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
---
drivers/xen/grant-table.c | 37 ++++++++++++++++++++++++++-----------
1 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 9c0019d..d731f39 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -47,6 +47,7 @@
#include <xen/grant_table.h>
#include <xen/interface/memory.h>
#include <xen/hvc-console.h>
+#include <xen/balloon.h>
#include <asm/xen/hypercall.h>
#include <asm/xen/interface.h>
@@ -1138,27 +1139,41 @@ static void gnttab_request_version(void)
grant_table_version);
}
+static int xlated_setup_gnttab_pages(int numpages, void **addr)
+{
+ int i, rc;
+ unsigned long pfns[numpages];
+ struct page *pages[numpages];
+
+ rc = alloc_xenballooned_pages(numpages, pages, 0);
+ if (rc != 0) {
+ pr_warn("%s Could not balloon alloc %d pfns rc:%d\n", __func__,
+ numpages, rc);
+ return -ENOMEM;
+ }
+ for (i = 0; i < numpages; i++)
+ pfns[i] = page_to_pfn(pages[i]);
+
+ rc = arch_gnttab_map_shared(pfns, numpages, numpages, addr);
+ return rc;
+}
+
int gnttab_resume(void)
{
- unsigned int max_nr_gframes;
- char *kmsg = "Failed to kmalloc pages for pv in hvm grant frames\n";
+ unsigned int rc, max_nr_gframes;
gnttab_request_version();
max_nr_gframes = gnttab_max_grant_frames();
if (max_nr_gframes < nr_grant_frames)
return -ENOSYS;
- /* PVH note: xen will free existing kmalloc'd mfn in
- * XENMEM_add_to_physmap. TBD/FIXME: use xen ballooning instead of
- * kmalloc(). */
if (xen_pv_domain() && xen_feature(XENFEAT_auto_translated_physmap) &&
!gnttab_shared.addr) {
- gnttab_shared.addr =
- kmalloc(max_nr_gframes * PAGE_SIZE, GFP_KERNEL);
- if (!gnttab_shared.addr) {
- pr_warn("%s", kmsg);
- return -ENOMEM;
- }
+
+ rc = xlated_setup_gnttab_pages(max_nr_gframes,
+ &gnttab_shared.addr);
+ if (rc != 0)
+ return rc;
}
if (xen_pv_domain())
return gnttab_map(0, nr_grant_frames - 1);
--
1.7.2.3
next reply other threads:[~2013-02-01 2:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-01 2:30 Mukesh Rathor [this message]
2013-02-01 2:44 ` [Xen-devel] [PATCH] PVH linux: Use ballooning to allocate grant table pages Mukesh Rathor
2013-02-01 22:00 ` Mukesh Rathor
2013-02-01 23:51 ` Mukesh Rathor
2013-02-06 15:49 ` Konrad Rzeszutek Wilk
2013-02-06 21:31 ` Mukesh Rathor
-- strict thread matches above, loose matches on Subject: below --
2013-02-05 22:55 Mukesh Rathor
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=20130131183015.13bc2bff@mantra.us.oracle.com \
--to=mukesh.rathor@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=Xen-devel@lists.xensource.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.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).