Muchun Song | f41f2ed | 2021-06-30 18:47:13 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Free some vmemmap pages of HugeTLB |
| 4 | * |
| 5 | * Copyright (c) 2020, Bytedance. All rights reserved. |
| 6 | * |
| 7 | * Author: Muchun Song <songmuchun@bytedance.com> |
| 8 | */ |
| 9 | #ifndef _LINUX_HUGETLB_VMEMMAP_H |
| 10 | #define _LINUX_HUGETLB_VMEMMAP_H |
| 11 | #include <linux/hugetlb.h> |
| 12 | |
| 13 | #ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP |
Muchun Song | ad2fa37 | 2021-06-30 18:47:21 -0700 | [diff] [blame] | 14 | int alloc_huge_page_vmemmap(struct hstate *h, struct page *head); |
Muchun Song | f41f2ed | 2021-06-30 18:47:13 -0700 | [diff] [blame] | 15 | void free_huge_page_vmemmap(struct hstate *h, struct page *head); |
Muchun Song | 7749058 | 2021-06-30 18:47:33 -0700 | [diff] [blame] | 16 | void hugetlb_vmemmap_init(struct hstate *h); |
Muchun Song | b65d4ad | 2021-06-30 18:47:17 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * How many vmemmap pages associated with a HugeTLB page that can be freed |
| 20 | * to the buddy allocator. |
Muchun Song | b65d4ad | 2021-06-30 18:47:17 -0700 | [diff] [blame] | 21 | */ |
| 22 | static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h) |
| 23 | { |
Muchun Song | 7749058 | 2021-06-30 18:47:33 -0700 | [diff] [blame] | 24 | return h->nr_free_vmemmap_pages; |
Muchun Song | b65d4ad | 2021-06-30 18:47:17 -0700 | [diff] [blame] | 25 | } |
Muchun Song | f41f2ed | 2021-06-30 18:47:13 -0700 | [diff] [blame] | 26 | #else |
Muchun Song | ad2fa37 | 2021-06-30 18:47:21 -0700 | [diff] [blame] | 27 | static inline int alloc_huge_page_vmemmap(struct hstate *h, struct page *head) |
| 28 | { |
| 29 | return 0; |
| 30 | } |
| 31 | |
Muchun Song | f41f2ed | 2021-06-30 18:47:13 -0700 | [diff] [blame] | 32 | static inline void free_huge_page_vmemmap(struct hstate *h, struct page *head) |
| 33 | { |
| 34 | } |
Muchun Song | b65d4ad | 2021-06-30 18:47:17 -0700 | [diff] [blame] | 35 | |
Muchun Song | 7749058 | 2021-06-30 18:47:33 -0700 | [diff] [blame] | 36 | static inline void hugetlb_vmemmap_init(struct hstate *h) |
| 37 | { |
| 38 | } |
| 39 | |
Muchun Song | b65d4ad | 2021-06-30 18:47:17 -0700 | [diff] [blame] | 40 | static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
Muchun Song | f41f2ed | 2021-06-30 18:47:13 -0700 | [diff] [blame] | 44 | #endif /* CONFIG_HUGETLB_PAGE_FREE_VMEMMAP */ |
| 45 | #endif /* _LINUX_HUGETLB_VMEMMAP_H */ |