blob: cb2bef8f9e736a531fc6da1d9a4e9492346f6eef [file] [log] [blame]
Muchun Songf41f2ed2021-06-30 18:47:13 -07001// 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 Songad2fa372021-06-30 18:47:21 -070014int alloc_huge_page_vmemmap(struct hstate *h, struct page *head);
Muchun Songf41f2ed2021-06-30 18:47:13 -070015void free_huge_page_vmemmap(struct hstate *h, struct page *head);
Muchun Song77490582021-06-30 18:47:33 -070016void hugetlb_vmemmap_init(struct hstate *h);
Muchun Songb65d4ad2021-06-30 18:47:17 -070017
18/*
19 * How many vmemmap pages associated with a HugeTLB page that can be freed
20 * to the buddy allocator.
Muchun Songb65d4ad2021-06-30 18:47:17 -070021 */
22static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
23{
Muchun Song77490582021-06-30 18:47:33 -070024 return h->nr_free_vmemmap_pages;
Muchun Songb65d4ad2021-06-30 18:47:17 -070025}
Muchun Songf41f2ed2021-06-30 18:47:13 -070026#else
Muchun Songad2fa372021-06-30 18:47:21 -070027static inline int alloc_huge_page_vmemmap(struct hstate *h, struct page *head)
28{
29 return 0;
30}
31
Muchun Songf41f2ed2021-06-30 18:47:13 -070032static inline void free_huge_page_vmemmap(struct hstate *h, struct page *head)
33{
34}
Muchun Songb65d4ad2021-06-30 18:47:17 -070035
Muchun Song77490582021-06-30 18:47:33 -070036static inline void hugetlb_vmemmap_init(struct hstate *h)
37{
38}
39
Muchun Songb65d4ad2021-06-30 18:47:17 -070040static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
41{
42 return 0;
43}
Muchun Songf41f2ed2021-06-30 18:47:13 -070044#endif /* CONFIG_HUGETLB_PAGE_FREE_VMEMMAP */
45#endif /* _LINUX_HUGETLB_VMEMMAP_H */