Skip to contentSkip to conversation

mm/page_alloc: Simplify free_page_is_bad by removing free_page_is_bad_report

PATCH Superseded Ye Liu 2 participants 3 messages Mar 21, 2025

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Ye Liu

author
#0 lore raw

PATCH 1/1 mm/page_alloc: Simplify free_page_is_bad by removing free_page_is_bad_report

From: Ye Liu <[email protected]>

This patch refactors the free_page_is_bad function by directly calling bad_page() instead of using the intermediary function free_page_is_bad_report(). The removal of free_page_is_bad_report() reduces unnecessary indirection, making the code cleaner and easier to read.

The functionality remains the same, as free_page_is_bad_report() was merely a wrapper for the bad_page() call. The patch also improves maintainability by reducing the function call depth.

---
 mm/page_alloc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
mm/page_alloc.c +2 -7
index 61d6a3b1b286..2842da893eea 100644
@@ -933,19 +933,14 @@ static const char *page_bad_reason(struct page *page, unsigned long flags)
 	return bad_reason;
 }
 
-static void free_page_is_bad_report(struct page *page)
-{
-	bad_page(page,
-		 page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));
-}
-
 static inline bool free_page_is_bad(struct page *page)
 {
 	if (likely(page_expected_state(page, PAGE_FLAGS_CHECK_AT_FREE)))
 		return false;
 
 	/* Something has gone sideways, find it */
-	free_page_is_bad_report(page);
+	bad_page(page,
+		 page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));
 	return true;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ye Liu

From: Ye Liu <[email protected]>

This patch refactors the free_page_is_bad function by directly calling bad_page() instead of using the intermediary function free_page_is_bad_report(). The removal of free_page_is_bad_report() reduces unnecessary indirection, making the code cleaner and easier to read.

The functionality remains the same, as free_page_is_bad_report() was merely a wrapper for the bad_page() call. The patch also improves maintainability by reducing the function call depth.

Seems to be a sensible clean up indeed.

Quoted 19 lines
---
 mm/page_alloc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
mm/page_alloc.c +0 -5
index 61d6a3b1b286..2842da893eea 100644
@@ -933,19 +933,14 @@ static const char *page_bad_reason(struct page *page, unsigned long flags)
 	return bad_reason;
 }
 
-static void free_page_is_bad_report(struct page *page)
-{
-	bad_page(page,
-		 page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));
-}

mm/page_alloc.c static const char *page_bad_reason(struct page *page, unsigned long flags) · line 943

Quoted 10 lines
mm/page_alloc.c +2 -2
-
 static inline bool free_page_is_bad(struct page *page)
 {
 	if (likely(page_expected_state(page, PAGE_FLAGS_CHECK_AT_FREE)))
 		return false;
 
 	/* Something has gone sideways, find it */
-	free_page_is_bad_report(page);
+	bad_page(page,
+		 page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));

Please fold these above two lines into a single line instead.

bad_page(page, page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));

mm/page_alloc.c static const char *page_bad_reason(struct page *page, unsigned long flags) · line 946

Quoted 3 lines
mm/page_alloc.c +0 -0
 	return true;
 }
 

With the above suggested change in place.

author
#2 lore raw
Quoted 45 lines · Anshuman Khandual
Quoted 11 lines · Ye Liu

From: Ye Liu <[email protected]>

This patch refactors the free_page_is_bad function by directly calling bad_page() instead of using the intermediary function free_page_is_bad_report(). The removal of free_page_is_bad_report() reduces unnecessary indirection, making the code cleaner and easier to read.

The functionality remains the same, as free_page_is_bad_report() was merely a wrapper for the bad_page() call. The patch also improves maintainability by reducing the function call depth.

Seems to be a sensible clean up indeed.

Quoted 18 lines
---
 mm/page_alloc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
mm/page_alloc.c +0 -5
index 61d6a3b1b286..2842da893eea 100644
@@ -933,19 +933,14 @@ static const char *page_bad_reason(struct page *page, unsigned long flags)
 	return bad_reason;
 }
 
-static void free_page_is_bad_report(struct page *page)
-{
-	bad_page(page,
-		 page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));
-}

mm/page_alloc.c static const char *page_bad_reason(struct page *page, unsigned long flags) · line 943

Quoted 10 lines
mm/page_alloc.c +2 -2
-
 static inline bool free_page_is_bad(struct page *page)
 {
 	if (likely(page_expected_state(page, PAGE_FLAGS_CHECK_AT_FREE)))
 		return false;
 
 	/* Something has gone sideways, find it */
-	free_page_is_bad_report(page);
+	bad_page(page,
+		 page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));

Please fold these above two lines into a single line instead.

Quoted 8 lines

bad_page(page, page_bad_reason(page, PAGE_FLAGS_CHECK_AT_FREE));

mm/page_alloc.c static const char *page_bad_reason(struct page *page, unsigned long flags) · line 946

Quoted 3 lines
mm/page_alloc.c +0 -0
 	return true;
 }
 

With the above suggested change in place.

Thank you for the suggestion. I'll make the adjustment and submit a new patch. Appreciate your time and the review!

Thanks,
Ye Liu