Re: [PATCH -next 8/9] mm: page_alloc: use a folio in free_pages_prepare()

From: Kefeng Wang
Date: Tue Sep 26 2023 - 05:39:43 EST




On 2023/9/26 15:49, David Hildenbrand wrote:
On 26.09.23 02:52, Kefeng Wang wrote:
The page should not a tail page in free_pages_prepare(), let's use
a folio in free_pages_prepare() to save several compound_head() calls.

Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
---
  mm/page_alloc.c | 15 ++++++++-------
  1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 06be8821d833..a888b9d57751 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1070,6 +1070,7 @@ static __always_inline bool free_pages_prepare(struct page *page,
              unsigned int order, fpi_t fpi_flags)
  {
      int bad = 0;
+    struct folio *folio = page_folio(page);

We might have higher-order pages here that are not folios (not compound pages). It looks a bit like this function really shouldn't be working with folios in the generic way, for that reason.

Wrong level of abstraction in that function.

Thanks for your point this, also the change also looks unnecessary too,
the main purpose to use a folio in this function is prepared for
converting page_cpupid_reset_last() to folio, as the higher-order pages
the next patch is not right, I will reconsider it.


What am I missing?