* [PATCH v4 1/2] xen: add an "highmem" parameter to alloc_xenballooned_pages
@ 2011-09-08 18:45 Stefano Stabellini
2011-09-21 20:31 ` [Xen-devel] " Konrad Rzeszutek Wilk
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Stabellini @ 2011-09-08 18:45 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk
Cc: Jeremy Fitzhardinge, linux-kernel, xen-devel, Stefano Stabellini
Add an highmem parameter to alloc_xenballooned_pages, to allow callers to
request lowmem or highmem pages.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
drivers/xen/balloon.c | 12 ++++++++----
drivers/xen/gntdev.c | 2 +-
include/xen/balloon.h | 3 ++-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 5dfd8f8..7f7d463 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -501,20 +501,24 @@ EXPORT_SYMBOL_GPL(balloon_set_new_target);
* alloc_xenballooned_pages - get pages that have been ballooned out
* @nr_pages: Number of pages to get
* @pages: pages returned
+ * @highmem: highmem or lowmem pages
* @return 0 on success, error otherwise
*/
-int alloc_xenballooned_pages(int nr_pages, struct page** pages)
+int alloc_xenballooned_pages(int nr_pages, struct page** pages, bool highmem)
{
int pgno = 0;
struct page* page;
mutex_lock(&balloon_mutex);
while (pgno < nr_pages) {
- page = balloon_retrieve(true);
- if (page) {
+ page = balloon_retrieve(highmem);
+ if (page && PageHighMem(page) == highmem) {
pages[pgno++] = page;
} else {
enum bp_state st;
- st = decrease_reservation(nr_pages - pgno, GFP_HIGHUSER);
+ if (page)
+ balloon_append(page);
+ st = decrease_reservation(nr_pages - pgno,
+ highmem ? GFP_HIGHUSER : GFP_USER);
if (st != BP_DONE)
goto out_undo;
}
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index f914b26..7b9b1d1 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -123,7 +123,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
NULL == add->pages)
goto err;
- if (alloc_xenballooned_pages(count, add->pages))
+ if (alloc_xenballooned_pages(count, add->pages, false /* lowmem */))
goto err;
for (i = 0; i < count; i++) {
diff --git a/include/xen/balloon.h b/include/xen/balloon.h
index 76f7538..b1a8233 100644
--- a/include/xen/balloon.h
+++ b/include/xen/balloon.h
@@ -25,7 +25,8 @@ extern struct balloon_stats balloon_stats;
void balloon_set_new_target(unsigned long target);
-int alloc_xenballooned_pages(int nr_pages, struct page** pages);
+int alloc_xenballooned_pages(int nr_pages, struct page** pages,
+ bool highmem);
void free_xenballooned_pages(int nr_pages, struct page** pages);
struct sys_device;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [Xen-devel] [PATCH v4 1/2] xen: add an "highmem" parameter to alloc_xenballooned_pages
2011-09-08 18:45 [PATCH v4 1/2] xen: add an "highmem" parameter to alloc_xenballooned_pages Stefano Stabellini
@ 2011-09-21 20:31 ` Konrad Rzeszutek Wilk
0 siblings, 0 replies; 2+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-09-21 20:31 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Jeremy Fitzhardinge, xen-devel, linux-kernel
On Thu, Sep 08, 2011 at 07:45:08PM +0100, Stefano Stabellini wrote:
> Add an highmem parameter to alloc_xenballooned_pages, to allow callers to
> request lowmem or highmem pages.
<grumble grumble>
+ scripts/checkpatch.pl --no-signoff /tmp/git.patch
ERROR: "foo** bar" should be "foo **bar"
#467: FILE: include/xen/balloon.h:28:
+int alloc_xenballooned_pages(int nr_pages, struct page** pages,
total: 1 errors, 0 warnings, 461 lines checked
Please fix and repost.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
> drivers/xen/balloon.c | 12 ++++++++----
> drivers/xen/gntdev.c | 2 +-
> include/xen/balloon.h | 3 ++-
> 3 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index 5dfd8f8..7f7d463 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -501,20 +501,24 @@ EXPORT_SYMBOL_GPL(balloon_set_new_target);
> * alloc_xenballooned_pages - get pages that have been ballooned out
> * @nr_pages: Number of pages to get
> * @pages: pages returned
> + * @highmem: highmem or lowmem pages
> * @return 0 on success, error otherwise
> */
> -int alloc_xenballooned_pages(int nr_pages, struct page** pages)
> +int alloc_xenballooned_pages(int nr_pages, struct page** pages, bool highmem)
> {
> int pgno = 0;
> struct page* page;
> mutex_lock(&balloon_mutex);
> while (pgno < nr_pages) {
> - page = balloon_retrieve(true);
> - if (page) {
> + page = balloon_retrieve(highmem);
> + if (page && PageHighMem(page) == highmem) {
> pages[pgno++] = page;
> } else {
> enum bp_state st;
> - st = decrease_reservation(nr_pages - pgno, GFP_HIGHUSER);
> + if (page)
> + balloon_append(page);
> + st = decrease_reservation(nr_pages - pgno,
> + highmem ? GFP_HIGHUSER : GFP_USER);
> if (st != BP_DONE)
> goto out_undo;
> }
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index f914b26..7b9b1d1 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -123,7 +123,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
> NULL == add->pages)
> goto err;
>
> - if (alloc_xenballooned_pages(count, add->pages))
> + if (alloc_xenballooned_pages(count, add->pages, false /* lowmem */))
> goto err;
>
> for (i = 0; i < count; i++) {
> diff --git a/include/xen/balloon.h b/include/xen/balloon.h
> index 76f7538..b1a8233 100644
> --- a/include/xen/balloon.h
> +++ b/include/xen/balloon.h
> @@ -25,7 +25,8 @@ extern struct balloon_stats balloon_stats;
>
> void balloon_set_new_target(unsigned long target);
>
> -int alloc_xenballooned_pages(int nr_pages, struct page** pages);
> +int alloc_xenballooned_pages(int nr_pages, struct page** pages,
> + bool highmem);
> void free_xenballooned_pages(int nr_pages, struct page** pages);
>
> struct sys_device;
> --
> 1.7.2.3
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-21 20:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-08 18:45 [PATCH v4 1/2] xen: add an "highmem" parameter to alloc_xenballooned_pages Stefano Stabellini
2011-09-21 20:31 ` [Xen-devel] " Konrad Rzeszutek Wilk
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).