Skip to content

Commit 121f2fa

Browse files
jgross1bostrovs
authored andcommitted
xen/balloon: rename alloc/free_xenballooned_pages
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent 40fdea0 commit 121f2fa

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

drivers/xen/balloon.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ void balloon_set_new_target(unsigned long target)
580580
}
581581
EXPORT_SYMBOL_GPL(balloon_set_new_target);
582582

583-
static int add_ballooned_pages(int nr_pages)
583+
#ifndef CONFIG_XEN_UNPOPULATED_ALLOC
584+
static int add_ballooned_pages(unsigned int nr_pages)
584585
{
585586
enum bp_state st;
586587

@@ -608,14 +609,14 @@ static int add_ballooned_pages(int nr_pages)
608609
}
609610

610611
/**
611-
* alloc_xenballooned_pages - get pages that have been ballooned out
612+
* xen_alloc_unpopulated_pages - get pages that have been ballooned out
612613
* @nr_pages: Number of pages to get
613614
* @pages: pages returned
614615
* @return 0 on success, error otherwise
615616
*/
616-
int alloc_xenballooned_pages(int nr_pages, struct page **pages)
617+
int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages)
617618
{
618-
int pgno = 0;
619+
unsigned int pgno = 0;
619620
struct page *page;
620621
int ret;
621622

@@ -650,7 +651,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
650651
return 0;
651652
out_undo:
652653
mutex_unlock(&balloon_mutex);
653-
free_xenballooned_pages(pgno, pages);
654+
xen_free_unpopulated_pages(pgno, pages);
654655
/*
655656
* NB: free_xenballooned_pages will only subtract pgno pages, but since
656657
* target_unpopulated is incremented with nr_pages at the start we need
@@ -659,16 +660,16 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
659660
balloon_stats.target_unpopulated -= nr_pages - pgno;
660661
return ret;
661662
}
662-
EXPORT_SYMBOL(alloc_xenballooned_pages);
663+
EXPORT_SYMBOL(xen_alloc_unpopulated_pages);
663664

664665
/**
665-
* free_xenballooned_pages - return pages retrieved with get_ballooned_pages
666+
* xen_free_unpopulated_pages - return pages retrieved with get_ballooned_pages
666667
* @nr_pages: Number of pages
667668
* @pages: pages to return
668669
*/
669-
void free_xenballooned_pages(int nr_pages, struct page **pages)
670+
void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages)
670671
{
671-
int i;
672+
unsigned int i;
672673

673674
mutex_lock(&balloon_mutex);
674675

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

686687
mutex_unlock(&balloon_mutex);
687688
}
688-
EXPORT_SYMBOL(free_xenballooned_pages);
689+
EXPORT_SYMBOL(xen_free_unpopulated_pages);
689690

690-
#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC)
691+
#if defined(CONFIG_XEN_PV)
691692
static void __init balloon_add_region(unsigned long start_pfn,
692693
unsigned long pages)
693694
{
@@ -710,6 +711,7 @@ static void __init balloon_add_region(unsigned long start_pfn,
710711
balloon_stats.total_pages += extra_pfn_end - start_pfn;
711712
}
712713
#endif
714+
#endif
713715

714716
static int __init balloon_init(void)
715717
{

include/xen/balloon.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ extern struct balloon_stats balloon_stats;
2626

2727
void balloon_set_new_target(unsigned long target);
2828

29-
int alloc_xenballooned_pages(int nr_pages, struct page **pages);
30-
void free_xenballooned_pages(int nr_pages, struct page **pages);
31-
3229
#ifdef CONFIG_XEN_BALLOON
3330
void xen_balloon_init(void);
3431
#else

include/xen/xen.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
5252
extern u64 xen_saved_max_mem_size;
5353
#endif
5454

55-
#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
5655
int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
5756
void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
58-
#else
59-
#define xen_alloc_unpopulated_pages alloc_xenballooned_pages
60-
#define xen_free_unpopulated_pages free_xenballooned_pages
61-
#include <xen/balloon.h>
62-
#endif
6357

6458
#endif /* _XEN_XEN_H */

0 commit comments

Comments
 (0)