* [PATCH v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state
@ 2025-03-26 1:17 Ye Liu
2025-03-26 8:48 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Ye Liu @ 2025-03-26 1:17 UTC (permalink / raw)
To: akpm
Cc: linux-mm, linux-kernel, sidhartha.kumar, anshuman.khandual,
Markus.Elfring, Ye Liu
From: Ye Liu <liuye@kylinos.cn>
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.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
V3: Delete 'This patch'.
V2: return true instead of false in the PageHWPoison branch.
---
---
mm/page_alloc.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2842da893eea..e8b95c6a96c2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state
2025-03-26 1:17 [PATCH v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state Ye Liu
@ 2025-03-26 8:48 ` Markus Elfring
2025-03-26 9:34 ` Ye Liu
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-03-26 8:48 UTC (permalink / raw)
To: Ye Liu, linux-mm
Cc: Ye Liu, LKML, Andrew Morton, Anshuman Khandual, Sidhartha Kumar
> Consolidates the handling of
…
> This change simplifies
…
> ---
> V3: Delete 'This patch'.
How good does such information fit to the wording requirement “imperative mood”?
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n94
…
> ---
> ---
> mm/page_alloc.c | 24 ++++++++----------------
How do you think about to omit redundant marker lines?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state
2025-03-26 8:48 ` Markus Elfring
@ 2025-03-26 9:34 ` Ye Liu
2025-03-27 15:05 ` [v3] " Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Ye Liu @ 2025-03-26 9:34 UTC (permalink / raw)
To: Markus Elfring, Ye Liu, linux-mm
Cc: LKML, Andrew Morton, Anshuman Khandual, Sidhartha Kumar
在 2025/3/26 16:48, Markus Elfring 写道:
>> Consolidates the handling of
> …
>> This change simplifies
> …
>> ---
>> V3: Delete 'This patch'.
> How good does such information fit to the wording requirement “imperative mood”?
> https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n94
How about this?
Consolidate the handling of unlikely conditions in the page_expected_state
function to reduce code duplication and improve readability.
Move the logic for handling __PG_HWPOISON flags from the check_new_page_bad
function to the page_expected_state function, and remove check_new_page_bad.
Call bad_page directly from the check_new_page function if the page has
unexpected flags.
Simplify the code by reducing the number of functions and centralizing the
handling of unlikely conditions.
> …
>> ---
>> ---
>> mm/page_alloc.c | 24 ++++++++----------------
> How do you think about to omit redundant marker lines?
--- delete this one?
---
mm/page_alloc.c | 24 ++++++++----------------
like this ?
V2: return true instead of false in the PageHWPoison branch.
---
mm/page_alloc.c | 24 ++++++++----------------
Thanks for pointing out the formatting issue.
I would like to get your approval on the above changes before I send patch v4.
> Regards,
> Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state
2025-03-26 9:34 ` Ye Liu
@ 2025-03-27 15:05 ` Markus Elfring
2025-03-28 1:27 ` Ye Liu
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-03-27 15:05 UTC (permalink / raw)
To: Ye Liu, linux-mm
Cc: Ye Liu, LKML, Andrew Morton, Anshuman Khandual, Sidhartha Kumar
>> https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n94
>
> How about this?
I hope that such review can trigger improvements in change descriptions
for further patch versions.
> Consolidate the handling of unlikely conditions in the page_expected_state
> function to reduce code duplication and improve readability.
…
Would you like to append parentheses to any function names?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state
2025-03-27 15:05 ` [v3] " Markus Elfring
@ 2025-03-28 1:27 ` Ye Liu
0 siblings, 0 replies; 5+ messages in thread
From: Ye Liu @ 2025-03-28 1:27 UTC (permalink / raw)
To: Markus Elfring, Ye Liu, linux-mm
Cc: LKML, Andrew Morton, Anshuman Khandual, Sidhartha Kumar
在 2025/3/27 23:05, Markus Elfring 写道:
>>> https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n94
>> How about this?
> I hope that such review can trigger improvements in change descriptions
> for further patch versions.
>
Thanks for the review and suggestion! I appreciate the feedback and will
improve the change descriptions in future patch versions.
>> Consolidate the handling of unlikely conditions in the page_expected_state
>> function to reduce code duplication and improve readability.
> …
>
> Would you like to append parentheses to any function names?
I'll adjust accordingly.
Best regards,
Ye
> Regards,
> Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-28 1:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-26 1:17 [PATCH v3] mm/page_alloc: Consolidate unlikely handling in page_expected_state Ye Liu
2025-03-26 8:48 ` Markus Elfring
2025-03-26 9:34 ` Ye Liu
2025-03-27 15:05 ` [v3] " Markus Elfring
2025-03-28 1:27 ` Ye Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).