Skip to content

Commit

Permalink
xen/balloon: rename alloc/free_xenballooned_pages
Browse files Browse the repository at this point in the history
alloc_xenballooned_pages() and free_xenballooned_pages() are used as
direct replacements of xen_alloc_unpopulated_pages() and
xen_free_unpopulated_pages() in case CONFIG_XEN_UNPOPULATED_ALLOC isn't
defined.

Guard both functions with !CONFIG_XEN_UNPOPULATED_ALLOC and rename them
to the xen_*() variants they are replacing. This allows to remove some
ifdeffery from the xen.h header file. Adapt the prototype of the
functions to match.

Signed-off-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20211102092234.17852-1-jgross@suse.com
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
  • Loading branch information
Juergen Gross authored and Boris Ostrovsky committed Nov 4, 2021
1 parent 40fdea0 commit 121f2fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
24 changes: 13 additions & 11 deletions drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ void balloon_set_new_target(unsigned long target)
}
EXPORT_SYMBOL_GPL(balloon_set_new_target);

static int add_ballooned_pages(int nr_pages)
#ifndef CONFIG_XEN_UNPOPULATED_ALLOC
static int add_ballooned_pages(unsigned int nr_pages)
{
enum bp_state st;

Expand Down Expand Up @@ -608,14 +609,14 @@ static int add_ballooned_pages(int nr_pages)
}

/**
* alloc_xenballooned_pages - get pages that have been ballooned out
* xen_alloc_unpopulated_pages - get pages that have been ballooned out
* @nr_pages: Number of pages to get
* @pages: pages returned
* @return 0 on success, error otherwise
*/
int alloc_xenballooned_pages(int nr_pages, struct page **pages)
int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages)
{
int pgno = 0;
unsigned int pgno = 0;
struct page *page;
int ret;

Expand Down Expand Up @@ -650,7 +651,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
return 0;
out_undo:
mutex_unlock(&balloon_mutex);
free_xenballooned_pages(pgno, pages);
xen_free_unpopulated_pages(pgno, pages);
/*
* NB: free_xenballooned_pages will only subtract pgno pages, but since
* target_unpopulated is incremented with nr_pages at the start we need
Expand All @@ -659,16 +660,16 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
balloon_stats.target_unpopulated -= nr_pages - pgno;
return ret;
}
EXPORT_SYMBOL(alloc_xenballooned_pages);
EXPORT_SYMBOL(xen_alloc_unpopulated_pages);

/**
* free_xenballooned_pages - return pages retrieved with get_ballooned_pages
* xen_free_unpopulated_pages - return pages retrieved with get_ballooned_pages
* @nr_pages: Number of pages
* @pages: pages to return
*/
void free_xenballooned_pages(int nr_pages, struct page **pages)
void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages)
{
int i;
unsigned int i;

mutex_lock(&balloon_mutex);

Expand All @@ -685,9 +686,9 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)

mutex_unlock(&balloon_mutex);
}
EXPORT_SYMBOL(free_xenballooned_pages);
EXPORT_SYMBOL(xen_free_unpopulated_pages);

#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC)
#if defined(CONFIG_XEN_PV)
static void __init balloon_add_region(unsigned long start_pfn,
unsigned long pages)
{
Expand All @@ -710,6 +711,7 @@ static void __init balloon_add_region(unsigned long start_pfn,
balloon_stats.total_pages += extra_pfn_end - start_pfn;
}
#endif
#endif

static int __init balloon_init(void)
{
Expand Down
3 changes: 0 additions & 3 deletions include/xen/balloon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ extern struct balloon_stats balloon_stats;

void balloon_set_new_target(unsigned long target);

int alloc_xenballooned_pages(int nr_pages, struct page **pages);
void free_xenballooned_pages(int nr_pages, struct page **pages);

#ifdef CONFIG_XEN_BALLOON
void xen_balloon_init(void);
#else
Expand Down
6 changes: 0 additions & 6 deletions include/xen/xen.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
extern u64 xen_saved_max_mem_size;
#endif

#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
#else
#define xen_alloc_unpopulated_pages alloc_xenballooned_pages
#define xen_free_unpopulated_pages free_xenballooned_pages
#include <xen/balloon.h>
#endif

#endif /* _XEN_XEN_H */

0 comments on commit 121f2fa

Please sign in to comment.