2021-07-01 09:47:13 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
2022-04-29 14:16:14 +08:00
|
|
|
* Optimize vmemmap pages associated with HugeTLB
|
2021-07-01 09:47:13 +08:00
|
|
|
*
|
|
|
|
* Copyright (c) 2020, Bytedance. All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Muchun Song <songmuchun@bytedance.com>
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_HUGETLB_VMEMMAP_H
|
|
|
|
#define _LINUX_HUGETLB_VMEMMAP_H
|
|
|
|
#include <linux/hugetlb.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
|
2022-04-29 14:16:14 +08:00
|
|
|
int hugetlb_vmemmap_alloc(struct hstate *h, struct page *head);
|
|
|
|
void hugetlb_vmemmap_free(struct hstate *h, struct page *head);
|
2021-07-01 09:47:33 +08:00
|
|
|
void hugetlb_vmemmap_init(struct hstate *h);
|
2021-07-01 09:47:17 +08:00
|
|
|
|
|
|
|
/*
|
2022-04-29 14:16:14 +08:00
|
|
|
* How many vmemmap pages associated with a HugeTLB page that can be
|
|
|
|
* optimized and freed to the buddy allocator.
|
2021-07-01 09:47:17 +08:00
|
|
|
*/
|
2022-04-29 14:16:14 +08:00
|
|
|
static inline unsigned int hugetlb_optimize_vmemmap_pages(struct hstate *h)
|
2021-07-01 09:47:17 +08:00
|
|
|
{
|
2022-04-29 14:16:14 +08:00
|
|
|
return h->optimize_vmemmap_pages;
|
2021-07-01 09:47:17 +08:00
|
|
|
}
|
2021-07-01 09:47:13 +08:00
|
|
|
#else
|
2022-04-29 14:16:14 +08:00
|
|
|
static inline int hugetlb_vmemmap_alloc(struct hstate *h, struct page *head)
|
2021-07-01 09:47:21 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-29 14:16:14 +08:00
|
|
|
static inline void hugetlb_vmemmap_free(struct hstate *h, struct page *head)
|
2021-07-01 09:47:13 +08:00
|
|
|
{
|
|
|
|
}
|
2021-07-01 09:47:17 +08:00
|
|
|
|
2021-07-01 09:47:33 +08:00
|
|
|
static inline void hugetlb_vmemmap_init(struct hstate *h)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-04-29 14:16:14 +08:00
|
|
|
static inline unsigned int hugetlb_optimize_vmemmap_pages(struct hstate *h)
|
2021-07-01 09:47:17 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-07-01 09:47:13 +08:00
|
|
|
#endif /* CONFIG_HUGETLB_PAGE_FREE_VMEMMAP */
|
|
|
|
#endif /* _LINUX_HUGETLB_VMEMMAP_H */
|