0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LINUX_HUGETLB_VMEMMAP_H
0010 #define _LINUX_HUGETLB_VMEMMAP_H
0011 #include <linux/hugetlb.h>
0012
0013 #ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
0014 int hugetlb_vmemmap_restore(const struct hstate *h, struct page *head);
0015 void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head);
0016
0017
0018
0019
0020
0021 #define HUGETLB_VMEMMAP_RESERVE_SIZE PAGE_SIZE
0022
0023 static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h)
0024 {
0025 return pages_per_huge_page(h) * sizeof(struct page);
0026 }
0027
0028
0029
0030
0031
0032 static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h)
0033 {
0034 int size = hugetlb_vmemmap_size(h) - HUGETLB_VMEMMAP_RESERVE_SIZE;
0035
0036 if (!is_power_of_2(sizeof(struct page)))
0037 return 0;
0038 return size > 0 ? size : 0;
0039 }
0040 #else
0041 static inline int hugetlb_vmemmap_restore(const struct hstate *h, struct page *head)
0042 {
0043 return 0;
0044 }
0045
0046 static inline void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head)
0047 {
0048 }
0049
0050 static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h)
0051 {
0052 return 0;
0053 }
0054 #endif
0055
0056 static inline bool hugetlb_vmemmap_optimizable(const struct hstate *h)
0057 {
0058 return hugetlb_vmemmap_optimizable_size(h) != 0;
0059 }
0060 #endif