mirror of
https://github.com/torvalds/linux.git
synced 2024-11-13 23:51:39 +00:00
774905878f
All the infrastructure is ready, so we introduce nr_free_vmemmap_pages field in the hstate to indicate how many vmemmap pages associated with a HugeTLB page that can be freed to buddy allocator. And initialize it in the hugetlb_vmemmap_init(). This patch is actual enablement of the feature. There are only (RESERVE_VMEMMAP_SIZE / sizeof(struct page)) struct page structs that can be used when CONFIG_HUGETLB_PAGE_FREE_VMEMMAP, so add a BUILD_BUG_ON to catch invalid usage of the tail struct page. Link: https://lkml.kernel.org/r/20210510030027.56044-10-songmuchun@bytedance.com Signed-off-by: Muchun Song <songmuchun@bytedance.com> Acked-by: Mike Kravetz <mike.kravetz@oracle.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> Tested-by: Chen Huang <chenhuang5@huawei.com> Tested-by: Bodeddula Balasubramaniam <bodeddub@amazon.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Andy Lutomirski <luto@kernel.org> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Barry Song <song.bao.hua@hisilicon.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: HORIGUCHI NAOYA <naoya.horiguchi@nec.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Joao Martins <joao.m.martins@oracle.com> Cc: Joerg Roedel <jroedel@suse.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Matthew Wilcox <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mina Almasry <almasrymina@google.com> Cc: Oliver Neukum <oneukum@suse.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Xiongchun Duan <duanxiongchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Free some vmemmap pages of HugeTLB
|
|
*
|
|
* 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
|
|
int alloc_huge_page_vmemmap(struct hstate *h, struct page *head);
|
|
void free_huge_page_vmemmap(struct hstate *h, struct page *head);
|
|
void hugetlb_vmemmap_init(struct hstate *h);
|
|
|
|
/*
|
|
* How many vmemmap pages associated with a HugeTLB page that can be freed
|
|
* to the buddy allocator.
|
|
*/
|
|
static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
|
|
{
|
|
return h->nr_free_vmemmap_pages;
|
|
}
|
|
#else
|
|
static inline int alloc_huge_page_vmemmap(struct hstate *h, struct page *head)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void free_huge_page_vmemmap(struct hstate *h, struct page *head)
|
|
{
|
|
}
|
|
|
|
static inline void hugetlb_vmemmap_init(struct hstate *h)
|
|
{
|
|
}
|
|
|
|
static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif /* CONFIG_HUGETLB_PAGE_FREE_VMEMMAP */
|
|
#endif /* _LINUX_HUGETLB_VMEMMAP_H */
|