hugetlb_vmemmap.c (f10f1442c309ccef7a80ba3dc4abde0978e86fb4) | hugetlb_vmemmap.c (47010c040dec8af6347ec6259104fc13f7e7e30a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Optimize vmemmap pages associated with HugeTLB 4 * 5 * Copyright (c) 2020, Bytedance. All rights reserved. 6 * 7 * Author: Muchun Song <songmuchun@bytedance.com> 8 * --- 174 unchanged lines hidden (view full) --- 183 * For tail pages, the value of compound_head is the same. So we can reuse first 184 * page of head page structures. We map the virtual addresses of all the pages 185 * of tail page structures to the head page struct, and then free these page 186 * frames. Therefore, we need to reserve one pages as vmemmap areas. 187 */ 188#define RESERVE_VMEMMAP_NR 1U 189#define RESERVE_VMEMMAP_SIZE (RESERVE_VMEMMAP_NR << PAGE_SHIFT) 190 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Optimize vmemmap pages associated with HugeTLB 4 * 5 * Copyright (c) 2020, Bytedance. All rights reserved. 6 * 7 * Author: Muchun Song <songmuchun@bytedance.com> 8 * --- 174 unchanged lines hidden (view full) --- 183 * For tail pages, the value of compound_head is the same. So we can reuse first 184 * page of head page structures. We map the virtual addresses of all the pages 185 * of tail page structures to the head page struct, and then free these page 186 * frames. Therefore, we need to reserve one pages as vmemmap areas. 187 */ 188#define RESERVE_VMEMMAP_NR 1U 189#define RESERVE_VMEMMAP_SIZE (RESERVE_VMEMMAP_NR << PAGE_SHIFT) 190 |
191DEFINE_STATIC_KEY_MAYBE(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON, | 191DEFINE_STATIC_KEY_MAYBE(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON, |
192 hugetlb_optimize_vmemmap_key); 193EXPORT_SYMBOL(hugetlb_optimize_vmemmap_key); 194 195static int __init hugetlb_vmemmap_early_param(char *buf) 196{ 197 /* We cannot optimize if a "struct page" crosses page boundaries. */ 198 if (!is_power_of_2(sizeof(struct page))) { 199 pr_warn("cannot free vmemmap pages because \"struct page\" crosses page boundaries\n"); --- 71 unchanged lines hidden (view full) --- 271 272void __init hugetlb_vmemmap_init(struct hstate *h) 273{ 274 unsigned int nr_pages = pages_per_huge_page(h); 275 unsigned int vmemmap_pages; 276 277 /* 278 * There are only (RESERVE_VMEMMAP_SIZE / sizeof(struct page)) struct | 192 hugetlb_optimize_vmemmap_key); 193EXPORT_SYMBOL(hugetlb_optimize_vmemmap_key); 194 195static int __init hugetlb_vmemmap_early_param(char *buf) 196{ 197 /* We cannot optimize if a "struct page" crosses page boundaries. */ 198 if (!is_power_of_2(sizeof(struct page))) { 199 pr_warn("cannot free vmemmap pages because \"struct page\" crosses page boundaries\n"); --- 71 unchanged lines hidden (view full) --- 271 272void __init hugetlb_vmemmap_init(struct hstate *h) 273{ 274 unsigned int nr_pages = pages_per_huge_page(h); 275 unsigned int vmemmap_pages; 276 277 /* 278 * There are only (RESERVE_VMEMMAP_SIZE / sizeof(struct page)) struct |
279 * page structs that can be used when CONFIG_HUGETLB_PAGE_FREE_VMEMMAP, | 279 * page structs that can be used when CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP, |
280 * so add a BUILD_BUG_ON to catch invalid usage of the tail struct page. 281 */ 282 BUILD_BUG_ON(__NR_USED_SUBPAGE >= 283 RESERVE_VMEMMAP_SIZE / sizeof(struct page)); 284 285 if (!hugetlb_optimize_vmemmap_enabled()) 286 return; 287 --- 15 unchanged lines hidden --- | 280 * so add a BUILD_BUG_ON to catch invalid usage of the tail struct page. 281 */ 282 BUILD_BUG_ON(__NR_USED_SUBPAGE >= 283 RESERVE_VMEMMAP_SIZE / sizeof(struct page)); 284 285 if (!hugetlb_optimize_vmemmap_enabled()) 286 return; 287 --- 15 unchanged lines hidden --- |