Skip to content

Commit 3f982b9

Browse files
davidhildenbrandakpm00
authored andcommitted
mm/hugetlb-cgroup: convert hugetlb_cgroup_css_offline() to work on folios
Let's convert hugetlb_cgroup_css_offline() and hugetlb_cgroup_move_parent() to work on folios. hugepage_activelist contains folios, not pages. While at it, rename page_hcg simply to hcg, removing most of the "page" terminology. This removes an unnecessary call to compound_head(). Link: https://lkml.kernel.org/r/20250113131611.2554758-6-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent b235448 commit 3f982b9

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

mm/hugetlb_cgroup.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,23 @@ static void hugetlb_cgroup_css_free(struct cgroup_subsys_state *css)
195195
* cannot fail.
196196
*/
197197
static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,
198-
struct page *page)
198+
struct folio *folio)
199199
{
200200
unsigned int nr_pages;
201201
struct page_counter *counter;
202-
struct hugetlb_cgroup *page_hcg;
202+
struct hugetlb_cgroup *hcg;
203203
struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg);
204-
struct folio *folio = page_folio(page);
205204

206-
page_hcg = hugetlb_cgroup_from_folio(folio);
205+
hcg = hugetlb_cgroup_from_folio(folio);
207206
/*
208207
* We can have pages in active list without any cgroup
209208
* ie, hugepage with less than 3 pages. We can safely
210209
* ignore those pages.
211210
*/
212-
if (!page_hcg || page_hcg != h_cg)
211+
if (!hcg || hcg != h_cg)
213212
goto out;
214213

215-
nr_pages = compound_nr(page);
214+
nr_pages = folio_nr_pages(folio);
216215
if (!parent) {
217216
parent = root_h_cgroup;
218217
/* root has no limit */
@@ -235,13 +234,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup_subsys_state *css)
235234
{
236235
struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css);
237236
struct hstate *h;
238-
struct page *page;
237+
struct folio *folio;
239238

240239
do {
241240
for_each_hstate(h) {
242241
spin_lock_irq(&hugetlb_lock);
243-
list_for_each_entry(page, &h->hugepage_activelist, lru)
244-
hugetlb_cgroup_move_parent(hstate_index(h), h_cg, page);
242+
list_for_each_entry(folio, &h->hugepage_activelist, lru)
243+
hugetlb_cgroup_move_parent(hstate_index(h), h_cg, folio);
245244

246245
spin_unlock_irq(&hugetlb_lock);
247246
}

0 commit comments

Comments
 (0)