Skip to content

Commit 59838b2

Browse files
Frank van der Lindenakpm00
authored andcommitted
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/[email protected] Signed-off-by: Frank van der Linden <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Cc: Muchun Song <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2580d55 commit 59838b2

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

include/linux/hugetlb_cgroup.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ struct resv_map;
2222
struct file_region;
2323

2424
#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-
3225
enum hugetlb_memory_event {
3326
HUGETLB_MAX,
3427
HUGETLB_NR_MEMORY_EVENTS,
@@ -68,8 +61,6 @@ static inline struct hugetlb_cgroup *
6861
__hugetlb_cgroup_from_folio(struct folio *folio, bool rsvd)
6962
{
7063
VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio);
71-
if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER)
72-
return NULL;
7364
if (rsvd)
7465
return folio->_hugetlb_cgroup_rsvd;
7566
else
@@ -91,8 +82,6 @@ static inline void __set_hugetlb_cgroup(struct folio *folio,
9182
struct hugetlb_cgroup *h_cg, bool rsvd)
9283
{
9384
VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio);
94-
if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER)
95-
return;
9685
if (rsvd)
9786
folio->_hugetlb_cgroup_rsvd = h_cg;
9887
else

mm/hugetlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4361,7 +4361,7 @@ void __init hugetlb_add_hstate(unsigned int order)
43614361
return;
43624362
}
43634363
BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE);
4364-
BUG_ON(order == 0);
4364+
BUG_ON(order < order_base_2(__NR_USED_SUBPAGE));
43654365
h = &hstates[hugetlb_max_hstate++];
43664366
mutex_init(&h->resize_lock);
43674367
h->order = order;

mm/hugetlb_cgroup.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,6 @@ static int __hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
262262

263263
if (hugetlb_cgroup_disabled())
264264
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;
271265
again:
272266
rcu_read_lock();
273267
h_cg = hugetlb_cgroup_from_task(current);
@@ -397,9 +391,6 @@ static void __hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
397391
if (hugetlb_cgroup_disabled() || !h_cg)
398392
return;
399393

400-
if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER)
401-
return;
402-
403394
page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx,
404395
rsvd),
405396
nr_pages);
@@ -869,15 +860,8 @@ void __init hugetlb_cgroup_file_init(void)
869860
{
870861
struct hstate *h;
871862

872-
for_each_hstate(h) {
873-
/*
874-
* Add cgroup control files only if the huge page consists
875-
* of more than two normal pages. This is because we use
876-
* page[2].private for storing cgroup details.
877-
*/
878-
if (huge_page_order(h) >= HUGETLB_CGROUP_MIN_ORDER)
879-
__hugetlb_cgroup_file_init(hstate_index(h));
880-
}
863+
for_each_hstate(h)
864+
__hugetlb_cgroup_file_init(hstate_index(h));
881865
}
882866

883867
/*

0 commit comments

Comments
 (0)