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

From: Kefeng Wang
Date: Sat Nov 11 2023 - 05:57:51 EST




On 2023/11/11 2:29, Matthew Wilcox wrote:
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.

Yes,this will save extra 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.

Thanks for you advise,will try this firstly.