Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm, hugetlb: remove HUGETLB_CGROUP_MIN_ORDER

Originally, hugetlb_cgroup was the only hugetlb user of tail page
structure fields. So, the code defined and checked against
HUGETLB_CGROUP_MIN_ORDER to make sure pages weren't too small to use.

However, by now, tail page #2 is used to store hugetlb hwpoison and
subpool information as well. In other words, without that tail page
hugetlb doesn't work.

Acknowledge this fact by getting rid of HUGETLB_CGROUP_MIN_ORDER and
checks against it. Instead, just check for the minimum viable page order
at hstate creation time.

Link: https://lkml.kernel.org/r/20231004153248.3842997-1-fvdl@google.com
Signed-off-by: Frank van der Linden <fvdl@google.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Frank van der Linden and committed by
Andrew Morton
59838b25 2580d554

+3 -30
-11
include/linux/hugetlb_cgroup.h
··· 22 22 struct file_region; 23 23 24 24 #ifdef CONFIG_CGROUP_HUGETLB 25 - /* 26 - * Minimum page order trackable by hugetlb cgroup. 27 - * At least 3 pages are necessary for all the tracking information. 28 - * The second tail page contains all of the hugetlb-specific fields. 29 - */ 30 - #define HUGETLB_CGROUP_MIN_ORDER order_base_2(__NR_USED_SUBPAGE) 31 - 32 25 enum hugetlb_memory_event { 33 26 HUGETLB_MAX, 34 27 HUGETLB_NR_MEMORY_EVENTS, ··· 61 68 __hugetlb_cgroup_from_folio(struct folio *folio, bool rsvd) 62 69 { 63 70 VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); 64 - if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER) 65 - return NULL; 66 71 if (rsvd) 67 72 return folio->_hugetlb_cgroup_rsvd; 68 73 else ··· 82 91 struct hugetlb_cgroup *h_cg, bool rsvd) 83 92 { 84 93 VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); 85 - if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER) 86 - return; 87 94 if (rsvd) 88 95 folio->_hugetlb_cgroup_rsvd = h_cg; 89 96 else
+1 -1
mm/hugetlb.c
··· 4361 4361 return; 4362 4362 } 4363 4363 BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE); 4364 - BUG_ON(order == 0); 4364 + BUG_ON(order < order_base_2(__NR_USED_SUBPAGE)); 4365 4365 h = &hstates[hugetlb_max_hstate++]; 4366 4366 mutex_init(&h->resize_lock); 4367 4367 h->order = order;
+2 -18
mm/hugetlb_cgroup.c
··· 262 262 263 263 if (hugetlb_cgroup_disabled()) 264 264 goto done; 265 - /* 266 - * We don't charge any cgroup if the compound page have less 267 - * than 3 pages. 268 - */ 269 - if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) 270 - goto done; 271 265 again: 272 266 rcu_read_lock(); 273 267 h_cg = hugetlb_cgroup_from_task(current); ··· 389 395 bool rsvd) 390 396 { 391 397 if (hugetlb_cgroup_disabled() || !h_cg) 392 - return; 393 - 394 - if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) 395 398 return; 396 399 397 400 page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx, ··· 860 869 { 861 870 struct hstate *h; 862 871 863 - for_each_hstate(h) { 864 - /* 865 - * Add cgroup control files only if the huge page consists 866 - * of more than two normal pages. This is because we use 867 - * page[2].private for storing cgroup details. 868 - */ 869 - if (huge_page_order(h) >= HUGETLB_CGROUP_MIN_ORDER) 870 - __hugetlb_cgroup_file_init(hstate_index(h)); 871 - } 872 + for_each_hstate(h) 873 + __hugetlb_cgroup_file_init(hstate_index(h)); 872 874 } 873 875 874 876 /*