History

xen/balloon: Bring alloc(free)_xenballooned_pages helpers back

This patch rolls back some of the changes introduced by commit 121f2faca2c0a "xen/balloon: rename alloc/free_xenballooned_pages" in order to make possible to still allocate xenballooned pages if CONFIG_XEN_UNPOPULATED_ALLOC is enabled. On Arm the unpopulated pages will be allocated on top of extended regions provided by Xen via device-tree (the subsequent patches will add required bits to support unpopulated-alloc feature on Arm). The problem is that extended regions feature has been introduced into Xen quite recently (during 4.16 release cycle). So this effectively means that Linux must only use unpopulated-alloc on Arm if it is running on "new Xen" which advertises these regions. But, it will only be known after parsing the "hypervisor" node at boot time, so before doing that we cannot assume anything. In order to keep working if CONFIG_XEN_UNPOPULATED_ALLOC is enabled and the extended regions are not advertised (Linux is running on "old Xen", etc) we need the fallback to alloc_xenballooned_pages(). This way we wouldn't reduce the amount of memory usable (wasting RAM pages) for any of the external mappings anymore (and eliminate XSA-300) with "new Xen", but would be still functional ballooning out RAM pages with "old Xen". Also rename alloc(free)_xenballooned_pages to xen_alloc(free)_ballooned_pages and make xen_alloc(free)_unpopulated_pages static inline in xen.h if CONFIG_XEN_UNPOPULATED_ALLOC is disabled.

Oleksandr Tyshchenko committed 4 years ago

Commit 9dd060a1 parent 5e1cdb83 files · +26 −11Browse files

Showing the changes to include (2 of 3 files). Show all

Unified · Split

2 files
  1. include/xen/balloon.h +3 −0
  2. include/xen/xen.h +14 −0
include/xen/balloon.h+3−0
@@ -26,6 +26,9 @@ extern struct balloon_stats balloon_stats; · 25 unmodified lines
26 26
27void balloon_set_new_target(unsigned long target);27void balloon_set_new_target(unsigned long target);
28 28
29int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages);
30void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages);
31
29#ifdef CONFIG_XEN_BALLOON32#ifdef CONFIG_XEN_BALLOON
30void xen_balloon_init(void);33void xen_balloon_init(void);
31#else34#else
include/xen/xen.h+14−0
@@ -52,7 +52,21 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, · 51 unmodified lines
52extern u64 xen_saved_max_mem_size;52extern u64 xen_saved_max_mem_size;
53#endif53#endif
54 54
55#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
55int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);56int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
56void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);57void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
58#else
59#include <xen/balloon.h>
60static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages,
61 struct page **pages)
62{
63 return xen_alloc_ballooned_pages(nr_pages, pages);
64}
65static inline void xen_free_unpopulated_pages(unsigned int nr_pages,
66 struct page **pages)
67{
68 xen_free_ballooned_pages(nr_pages, pages);
69}
70#endif
57 71
58#endif /* _XEN_XEN_H */72#endif /* _XEN_XEN_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t