mirror of https://gitee.com/openkylin/linux.git
xen/balloon: make alloc_xenballoon_pages() always allocate low pages
All users of alloc_xenballoon_pages() wanted low memory pages, so remove the option for high memory. Signed-off-by: David Vrabel <david.vrabel@citrix.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
b2ac6aa8f7
commit
81b286e0f1
|
@ -133,7 +133,7 @@ static int __init xlated_setup_gnttab_pages(void)
|
||||||
kfree(pages);
|
kfree(pages);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
rc = alloc_xenballooned_pages(nr_grant_frames, pages, 0 /* lowmem */);
|
rc = alloc_xenballooned_pages(nr_grant_frames, pages);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
|
pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
|
||||||
nr_grant_frames, rc);
|
nr_grant_frames, rc);
|
||||||
|
|
|
@ -136,17 +136,16 @@ static void balloon_append(struct page *page)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
|
/* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
|
||||||
static struct page *balloon_retrieve(bool prefer_highmem)
|
static struct page *balloon_retrieve(bool require_lowmem)
|
||||||
{
|
{
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
|
||||||
if (list_empty(&ballooned_pages))
|
if (list_empty(&ballooned_pages))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (prefer_highmem)
|
page = list_entry(ballooned_pages.next, struct page, lru);
|
||||||
page = list_entry(ballooned_pages.prev, struct page, lru);
|
if (require_lowmem && PageHighMem(page))
|
||||||
else
|
return NULL;
|
||||||
page = list_entry(ballooned_pages.next, struct page, lru);
|
|
||||||
list_del(&page->lru);
|
list_del(&page->lru);
|
||||||
|
|
||||||
if (PageHighMem(page))
|
if (PageHighMem(page))
|
||||||
|
@ -521,24 +520,20 @@ 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: allow highmem pages
|
|
||||||
* @return 0 on success, error otherwise
|
* @return 0 on success, error otherwise
|
||||||
*/
|
*/
|
||||||
int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
|
int alloc_xenballooned_pages(int nr_pages, struct page **pages)
|
||||||
{
|
{
|
||||||
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(highmem);
|
page = balloon_retrieve(true);
|
||||||
if (page && (highmem || !PageHighMem(page))) {
|
if (page) {
|
||||||
pages[pgno++] = page;
|
pages[pgno++] = page;
|
||||||
} else {
|
} else {
|
||||||
enum bp_state st;
|
enum bp_state st;
|
||||||
if (page)
|
st = decrease_reservation(nr_pages - pgno, GFP_USER);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,7 +687,7 @@ int gnttab_alloc_pages(int nr_pages, struct page **pages)
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = alloc_xenballooned_pages(nr_pages, pages, false);
|
ret = alloc_xenballooned_pages(nr_pages, pages);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ static int alloc_empty_pages(struct vm_area_struct *vma, int numpgs)
|
||||||
if (pages == NULL)
|
if (pages == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
rc = alloc_xenballooned_pages(numpgs, pages, 0);
|
rc = alloc_xenballooned_pages(numpgs, pages);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
pr_warn("%s Could not alloc %d pfns rc:%d\n", __func__,
|
pr_warn("%s Could not alloc %d pfns rc:%d\n", __func__,
|
||||||
numpgs, rc);
|
numpgs, rc);
|
||||||
|
|
|
@ -614,8 +614,7 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,
|
||||||
if (!node)
|
if (!node)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
err = alloc_xenballooned_pages(nr_grefs, node->hvm.pages,
|
err = alloc_xenballooned_pages(nr_grefs, node->hvm.pages);
|
||||||
false /* lowmem */);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ 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 device;
|
struct device;
|
||||||
|
|
Loading…
Reference in New Issue