Re: [PATCH v2 5/7] mm: task_mmu: use a folio in smaps_account()

From: Matthew Wilcox
Date: Fri Nov 10 2023 - 14:48:22 EST


On Fri, Nov 10, 2023 at 11:33:22AM +0800, Kefeng Wang wrote:
> Replace seven implicit calls to compound_head() with one page_folio().

You're so focused on trying to accomplish your goal (killing off the
page_idle and page_young functions) that you're doing a poor job thinkig
about the conversions you're doing along the way.

> +++ b/fs/proc/task_mmu.c
> @@ -445,23 +445,25 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page,
> {
> int i, nr = compound ? compound_nr(page) : 1;
> unsigned long size = nr * PAGE_SIZE;
> + struct folio *folio = page_folio(page);

Stop right here. The use of compound_nr() should give you pause.

After looking at how smaps_account() is used, it seems to me that the
two callers should each pass in PAGE_SIZE or PMD_SIZE instead of doing
this calculation.

More generally, step back from this series. Do a good job of
transforming fs/proc/task_mmu.c to use folios. Once you've done
that, you can approach the young/idle work again.