linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <rppt@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	David Hildenbrand <david@redhat.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>, <ying.huang@intel.com>,
	Zi Yan <ziy@nvidia.com>, Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH -next 8/9] mm: page_alloc: use a folio in free_pages_prepare()
Date: Tue, 26 Sep 2023 08:52:53 +0800	[thread overview]
Message-ID: <20230926005254.2861577-9-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20230926005254.2861577-1-wangkefeng.wang@huawei.com>

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@huawei.com>
---
 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);
 	bool skip_kasan_poison = should_skip_kasan_poison(page, fpi_flags);
 	bool init = want_init_on_free();
 
@@ -1078,12 +1079,12 @@ static __always_inline bool free_pages_prepare(struct page *page,
 	trace_mm_page_free(page, order);
 	kmsan_free_page(page, order);
 
-	if (unlikely(PageHWPoison(page)) && !order) {
+	if (unlikely(folio_test_hwpoison(folio)) && !order) {
 		/*
 		 * Do not let hwpoison pages hit pcplists/buddy
 		 * Untie memcg state and reset page's owner
 		 */
-		if (memcg_kmem_online() && PageMemcgKmem(page))
+		if (memcg_kmem_online() && folio_memcg_kmem(folio))
 			__memcg_kmem_uncharge_page(page, order);
 		reset_page_owner(page, order);
 		page_table_check_free(page, order);
@@ -1095,10 +1096,10 @@ static __always_inline bool free_pages_prepare(struct page *page,
 	 * avoid checking PageCompound for order-0 pages.
 	 */
 	if (unlikely(order)) {
-		bool compound = PageCompound(page);
+		bool compound = folio_test_large(folio);
 		int i;
 
-		VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
+		VM_BUG_ON_FOLIO(compound && folio_order(folio) != order, folio);
 
 		if (compound)
 			page[1].flags &= ~PAGE_FLAGS_SECOND;
@@ -1114,9 +1115,9 @@ static __always_inline bool free_pages_prepare(struct page *page,
 			(page + i)->flags &= ~PAGE_FLAGS_CHECK_AT_PREP;
 		}
 	}
-	if (PageMappingFlags(page))
+	if (folio_mapping_flags(folio))
 		page->mapping = NULL;
-	if (memcg_kmem_online() && PageMemcgKmem(page))
+	if (memcg_kmem_online() && folio_memcg_kmem(folio))
 		__memcg_kmem_uncharge_page(page, order);
 	if (is_check_pages_enabled()) {
 		if (free_page_is_bad(page))
@@ -1130,7 +1131,7 @@ static __always_inline bool free_pages_prepare(struct page *page,
 	reset_page_owner(page, order);
 	page_table_check_free(page, order);
 
-	if (!PageHighMem(page)) {
+	if (!folio_test_highmem(folio)) {
 		debug_check_no_locks_freed(page_address(page),
 					   PAGE_SIZE << order);
 		debug_check_no_obj_freed(page_address(page),
-- 
2.27.0



  parent reply	other threads:[~2023-09-26  1:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  0:52 [PATCH -next rfc 0/9] mm: convert page cpupid functions to folios Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 1/9] mm_types: add _last_cpupid into folio Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 2/9] mm: mprotect: use a folio in change_pte_range() Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 3/9] mm: huge_memory: use a folio in change_huge_pmd() Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 4/9] mm: convert xchg_page_access_time to xchg_folio_access_time() Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 5/9] mm: convert page_cpupid_last() to folio_cpupid_last() Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 6/9] mm: make wp_page_reuse() and finish_mkwrite_fault() to take a folio Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 7/9] mm: convert page_cpupid_xchg_last() to folio_cpupid_xchg_last() Kefeng Wang
2023-09-26  0:52 ` Kefeng Wang [this message]
2023-09-26  7:49   ` [PATCH -next 8/9] mm: page_alloc: use a folio in free_pages_prepare() David Hildenbrand
2023-09-26  9:39     ` Kefeng Wang
2023-09-27 12:08       ` Kefeng Wang
2023-09-26  0:52 ` [PATCH -next 9/9] mm: convert page_cpupid_reset_last() to folio_cpupid_reset_last() Kefeng Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926005254.2861577-9-wangkefeng.wang@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox