Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 693394b8 authored by Stefano Stabellini's avatar Stefano Stabellini Committed by Konrad Rzeszutek Wilk
Browse files

xen: add an "highmem" parameter to alloc_xenballooned_pages



Add an highmem parameter to alloc_xenballooned_pages, to allow callers to
request lowmem or highmem pages.

Fix the code style of free_xenballooned_pages' prototype.

Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent 0f4b49ea
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -501,20 +501,24 @@ EXPORT_SYMBOL_GPL(balloon_set_new_target);
 * alloc_xenballooned_pages - get pages that have been ballooned out
 * alloc_xenballooned_pages - get pages that have been ballooned out
 * @nr_pages: Number of pages to get
 * @nr_pages: Number of pages to get
 * @pages: pages returned
 * @pages: pages returned
 * @highmem: highmem or lowmem pages
 * @return 0 on success, error otherwise
 * @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;
	int pgno = 0;
	struct page* page;
	struct page* page;
	mutex_lock(&balloon_mutex);
	mutex_lock(&balloon_mutex);
	while (pgno < nr_pages) {
	while (pgno < nr_pages) {
		page = balloon_retrieve(true);
		page = balloon_retrieve(highmem);
		if (page) {
		if (page && PageHighMem(page) == highmem) {
			pages[pgno++] = page;
			pages[pgno++] = page;
		} else {
		} else {
			enum bp_state st;
			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)
			if (st != BP_DONE)
				goto out_undo;
				goto out_undo;
		}
		}
+1 −1
Original line number Original line Diff line number Diff line
@@ -123,7 +123,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
	    NULL == add->pages)
	    NULL == add->pages)
		goto err;
		goto err;


	if (alloc_xenballooned_pages(count, add->pages))
	if (alloc_xenballooned_pages(count, add->pages, false /* lowmem */))
		goto err;
		goto err;


	for (i = 0; i < count; i++) {
	for (i = 0; i < count; i++) {
+3 −2
Original line number Original line Diff line number Diff line
@@ -25,7 +25,8 @@ extern struct balloon_stats balloon_stats;


void balloon_set_new_target(unsigned long target);
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);
void free_xenballooned_pages(int nr_pages, struct page **pages);


struct sys_device;
struct sys_device;