mm/page_alloc: Consolidate unlikely handling in page_expected_state
Subsystems (2)
PATCH v2 1/1 mm/page_alloc: Consolidate unlikely handling in page_expected_state
From: Ye Liu <[email protected]>
This patch consolidates the handling of unlikely conditions in the page_expected_state function, reducing code duplication and improving readability.
Previously, the check_new_page_bad function contained logic to handle __PG_HWPOISON flags, which was called from check_new_page. This patch moves the handling of __PG_HWPOISON flags into the page_expected_state function and removes the check_new_page_bad function. The check_new_page function now directly calls bad_page if the page has unexpected flags.
This change simplifies the code by reducing the number of functions and centralizing the unlikely condition handling in one place.
---
V2: return true instead of false in the PageHWPoison branch.
---
--- mm/page_alloc.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
mm/page_alloc.c +8 -16
@@ -903,6 +903,12 @@ static inline bool page_expected_state(struct page *page, (page->flags & check_flags)))return false; +if (unlikely (PageHWPoison (page))) { +/* Don't complain about hwpoisoned pages */ +if (PageBuddy (page)) +__ClearPageBuddy (page); + } +return true; }
@@ -1586,29 +1592,15 @@ static __always_inline void page_del_and_expand(struct zone *zone,account_freepages (zone, -nr_pages, migratetype); } -static void check_new_page_bad (struct page *page) -{ -if (unlikely (PageHWPoison (page))) { -/* Don't complain about hwpoisoned pages */ -if (PageBuddy (page)) -__ClearPageBuddy (page); -return ; - } - -bad_page (page, -page_bad_reason (page,PAGE_FLAGS_CHECK_AT_PREP )); -} -/* * This page is about to be returned from the page allocator */ static bool check_new_page (struct page *page) { -if (likely (page_expected_state (page, -PAGE_FLAGS_CHECK_AT_PREP |__PG_HWPOISON))) +if (likely (page_expected_state (page,PAGE_FLAGS_CHECK_AT_PREP )))return false; -check_new_page_bad (page); +bad_page (page,page_bad_reason (page,PAGE_FLAGS_CHECK_AT_PREP ));return true; }
Signature · 1 line
2.25.1
Quoted 63 lines · Ye Liu
From: Ye Liu <[email protected]>
This patch consolidates the handling of unlikely conditions in the
page_expected_statefunction, reducing code duplication and improving readability.Previously, the
check_new_page_badfunction contained logic to handle__PG_HWPOISONflags, which was called fromcheck_new_page. This patch moves the handling of__PG_HWPOISONflags into thepage_expected_statefunction and removes thecheck_new_page_badfunction. Thecheck_new_pagefunction now directly callsbad_pageif the page has unexpected flags.This change simplifies the code by reducing the number of functions and centralizing the unlikely condition handling in one place.
Signed-off-by Ye Liu <[email protected]>---
V2: return true instead of false in the PageHWPoison branch.
------ mm/page_alloc.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)mm/page_alloc.c +6
-13@@ -903,6 +903,12 @@ static inline bool page_expected_state(struct page *page, (page->flags & check_flags)))return false; +if (unlikely (PageHWPoison (page))) { +/* Don't complain about hwpoisoned pages */ +if (PageBuddy (page)) +__ClearPageBuddy (page); + } +return true; }@@ -1586,29 +1592,15 @@ static __always_inline void page_del_and_expand(struct zone *zone,account_freepages (zone, -nr_pages, migratetype); } -static void check_new_page_bad (struct page *page) -{ -if (unlikely (PageHWPoison (page))) { -/* Don't complain about hwpoisoned pages */ -if (PageBuddy (page)) -__ClearPageBuddy (page); -return ; - } - -bad_page (page, -page_bad_reason (page,PAGE_FLAGS_CHECK_AT_PREP )); -} -/* * This page is about to be returned from the page allocator */ static bool check_new_page (struct page *page) {
mm/page_alloc.c static __always_inline void page_del_and_expand(struct zone *zone, · line 1606
Quoted 10 lines
mm/page_alloc.c +2
-3-if (likely (page_expected_state (page, -PAGE_FLAGS_CHECK_AT_PREP |__PG_HWPOISON))) +if (likely (page_expected_state (page,PAGE_FLAGS_CHECK_AT_PREP )))return false; -check_new_page_bad (page); +bad_page (page,page_bad_reason (page,PAGE_FLAGS_CHECK_AT_PREP ));return true; }
Quoted 63 lines · Ye Liu
From: Ye Liu <[email protected]>
This patch consolidates the handling of unlikely conditions in the
page_expected_statefunction, reducing code duplication and improving readability.Previously, the
check_new_page_badfunction contained logic to handle__PG_HWPOISONflags, which was called fromcheck_new_page. This patch moves the handling of__PG_HWPOISONflags into thepage_expected_statefunction and removes thecheck_new_page_badfunction. Thecheck_new_pagefunction now directly callsbad_pageif the page has unexpected flags.This change simplifies the code by reducing the number of functions and centralizing the unlikely condition handling in one place.
Signed-off-by Ye Liu <[email protected]>---
V2: return true instead of false in the PageHWPoison branch.
------ mm/page_alloc.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)mm/page_alloc.c +6
-13@@ -903,6 +903,12 @@ static inline bool page_expected_state(struct page *page, (page->flags & check_flags)))return false; +if (unlikely (PageHWPoison (page))) { +/* Don't complain about hwpoisoned pages */ +if (PageBuddy (page)) +__ClearPageBuddy (page); + } +return true; }@@ -1586,29 +1592,15 @@ static __always_inline void page_del_and_expand(struct zone *zone,account_freepages (zone, -nr_pages, migratetype); } -static void check_new_page_bad (struct page *page) -{ -if (unlikely (PageHWPoison (page))) { -/* Don't complain about hwpoisoned pages */ -if (PageBuddy (page)) -__ClearPageBuddy (page); -return ; - } - -bad_page (page, -page_bad_reason (page,PAGE_FLAGS_CHECK_AT_PREP )); -} -/* * This page is about to be returned from the page allocator */ static bool check_new_page (struct page *page) {
mm/page_alloc.c static __always_inline void page_del_and_expand(struct zone *zone, · line 1606
Quoted 10 lines
mm/page_alloc.c +2
-3-if (likely (page_expected_state (page, -PAGE_FLAGS_CHECK_AT_PREP |__PG_HWPOISON))) +if (likely (page_expected_state (page,PAGE_FLAGS_CHECK_AT_PREP )))return false; -check_new_page_bad (page); +bad_page (page,page_bad_reason (page,PAGE_FLAGS_CHECK_AT_PREP ));return true; }
Quoted 1 line
This patch consolidates the handling of …
Regards,
Markus