[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130131184446.654a2289@mantra.us.oracle.com>
Date: Thu, 31 Jan 2013 18:44:46 -0800
From: Mukesh Rathor <mukesh.rathor@...cle.com>
To: Mukesh Rathor <mukesh.rathor@...cle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
"Xen-devel@...ts.xensource.com" <Xen-devel@...ts.xensource.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Ian Campbell <Ian.Campbell@...rix.com>,
"stefano.stabellini@...citrix.com" <stefano.stabellini@...citrix.com>
Subject: Re: [Xen-devel] [PATCH] PVH linux: Use ballooning to allocate grant
table pages
On Thu, 31 Jan 2013 18:30:15 -0800
Mukesh Rathor <mukesh.rathor@...cle.com> wrote:
> 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.
Looking at it again, I realized rc should be signed in gnttab_resume().
Below again. Thanks.
Signed-off-by: Mukesh Rathor <mukesh.rathor@...cle.com>
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 9c0019d..7a630bb 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,42 @@ 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)
{
+ int rc;
unsigned int max_nr_gframes;
- char *kmsg = "Failed to kmalloc pages for pv in hvm grant frames\n";
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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists