diff options
author | Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> | 2018-07-20 05:01:44 -0400 |
---|---|---|
committer | Boris Ostrovsky <boris.ostrovsky@oracle.com> | 2018-07-26 23:05:13 -0400 |
commit | ae4c51a50c990d6feba7058c181dc8f22ca5f1d8 (patch) | |
tree | 3cec1163486e161d33569c386d2f51e01011a279 /include/xen | |
parent | 8c3799ee25e1fda159099af09f5f2e86091e41d4 (diff) |
xen/balloon: Share common memory reservation routines
Memory {increase|decrease}_reservation and VA mappings update/reset
code used in balloon driver can be made common, so other drivers can
also re-use the same functionality without open-coding.
Create a dedicated file for the shared code and export corresponding
symbols for other kernel modules.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'include/xen')
-rw-r--r-- | include/xen/mem-reservation.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/xen/mem-reservation.h b/include/xen/mem-reservation.h new file mode 100644 index 000000000000..80b52b4945e9 --- /dev/null +++ b/include/xen/mem-reservation.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | |||
3 | /* | ||
4 | * Xen memory reservation utilities. | ||
5 | * | ||
6 | * Copyright (c) 2003, B Dragovic | ||
7 | * Copyright (c) 2003-2004, M Williamson, K Fraser | ||
8 | * Copyright (c) 2005 Dan M. Smith, IBM Corporation | ||
9 | * Copyright (c) 2010 Daniel Kiper | ||
10 | * Copyright (c) 2018 Oleksandr Andrushchenko, EPAM Systems Inc. | ||
11 | */ | ||
12 | |||
13 | #ifndef _XENMEM_RESERVATION_H | ||
14 | #define _XENMEM_RESERVATION_H | ||
15 | |||
16 | #include <linux/highmem.h> | ||
17 | |||
18 | #include <xen/page.h> | ||
19 | |||
20 | static inline void xenmem_reservation_scrub_page(struct page *page) | ||
21 | { | ||
22 | #ifdef CONFIG_XEN_SCRUB_PAGES | ||
23 | clear_highpage(page); | ||
24 | #endif | ||
25 | } | ||
26 | |||
27 | #ifdef CONFIG_XEN_HAVE_PVMMU | ||
28 | void __xenmem_reservation_va_mapping_update(unsigned long count, | ||
29 | struct page **pages, | ||
30 | xen_pfn_t *frames); | ||
31 | |||
32 | void __xenmem_reservation_va_mapping_reset(unsigned long count, | ||
33 | struct page **pages); | ||
34 | #endif | ||
35 | |||
36 | static inline void xenmem_reservation_va_mapping_update(unsigned long count, | ||
37 | struct page **pages, | ||
38 | xen_pfn_t *frames) | ||
39 | { | ||
40 | #ifdef CONFIG_XEN_HAVE_PVMMU | ||
41 | if (!xen_feature(XENFEAT_auto_translated_physmap)) | ||
42 | __xenmem_reservation_va_mapping_update(count, pages, frames); | ||
43 | #endif | ||
44 | } | ||
45 | |||
46 | static inline void xenmem_reservation_va_mapping_reset(unsigned long count, | ||
47 | struct page **pages) | ||
48 | { | ||
49 | #ifdef CONFIG_XEN_HAVE_PVMMU | ||
50 | if (!xen_feature(XENFEAT_auto_translated_physmap)) | ||
51 | __xenmem_reservation_va_mapping_reset(count, pages); | ||
52 | #endif | ||
53 | } | ||
54 | |||
55 | int xenmem_reservation_increase(int count, xen_pfn_t *frames); | ||
56 | |||
57 | int xenmem_reservation_decrease(int count, xen_pfn_t *frames); | ||
58 | |||
59 | #endif | ||