Re: [PATCH 2/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_from_page() to folios

From: Mike Kravetz
Date: Mon Oct 31 2022 - 12:13:58 EST


On 10/13/22 20:12, Sidhartha Kumar wrote:
> Introduce folios in __remove_hugetlb_page() by converting
> hugetlb_cgroup_from_page() to use folios.
>
> Also gets rid of unsed hugetlb_cgroup_from_page_resv() function.
>
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx>
> ---
> include/linux/hugetlb_cgroup.h | 39 +++++++++++++++++-----------------
> mm/hugetlb.c | 5 +++--
> mm/hugetlb_cgroup.c | 13 +++++++-----
> 3 files changed, 31 insertions(+), 26 deletions(-)

Changes look fine. However ...

> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 4133ffbbeb50..bcb9bfce32ee 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1434,9 +1434,10 @@ static void __remove_hugetlb_page(struct hstate *h, struct page *page,
> bool demote)
> {
> int nid = page_to_nid(page);
> + struct folio *folio = page_folio(page);
>
> - VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page);
> - VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page);
> + VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio(folio), folio);
> + VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio_rsvd(folio), folio);
>
> lockdep_assert_held(&hugetlb_lock);
> if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())

... there is also this a little further in the routine.

if (HPageFreed(page)) {

Should probably change this to?

if (folio_test_hugetlb_freed(folio)) {

Or, is that part of a planned subsequent change?
--
Mike Kravetz