linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/debug: Fix minor issues in mm
@ 2025-03-12  3:23 Liu Ye
  2025-03-12  8:37 ` Oscar Salvador
  2025-03-12 12:20 ` Matthew Wilcox
  0 siblings, 2 replies; 4+ messages in thread
From: Liu Ye @ 2025-03-12  3:23 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Liu Ye

This patch includes several minor fixes:

- Simplify compound page judgment conditions.
- Missing a newline character at the end of the format string.

Each change is independent.

Signed-off-by: Liu Ye <liuye@kylinos.cn>

---
V2 : drop Fix out-of-bounds access in page_type_name().
---
---
 mm/debug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/debug.c b/mm/debug.c
index 8d2acf432385..544b2b05c567 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -132,15 +132,15 @@ static void __dump_page(const struct page *page)
 again:
 	memcpy(&precise, page, sizeof(*page));
 	head = precise.compound_head;
-	if ((head & 1) == 0) {
+	if (head & 1) {
+		foliop = (struct folio *)(head - 1);
+		idx = folio_page_idx(foliop, page);
+	} else {
 		foliop = (struct folio *)&precise;
 		idx = 0;
 		if (!folio_test_large(foliop))
 			goto dump;
 		foliop = (struct folio *)page;
-	} else {
-		foliop = (struct folio *)(head - 1);
-		idx = folio_page_idx(foliop, page);
 	}
 
 	if (idx < MAX_FOLIO_NR_PAGES) {
@@ -165,7 +165,7 @@ static void __dump_page(const struct page *page)
 void dump_page(const struct page *page, const char *reason)
 {
 	if (PagePoisoned(page))
-		pr_warn("page:%p is uninitialized and poisoned", page);
+		pr_warn("page:%p is uninitialized and poisoned\n", page);
 	else
 		__dump_page(page);
 	if (reason)
-- 
2.25.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/debug: Fix minor issues in mm
  2025-03-12  3:23 [PATCH v2] mm/debug: Fix minor issues in mm Liu Ye
@ 2025-03-12  8:37 ` Oscar Salvador
  2025-03-12 12:20 ` Matthew Wilcox
  1 sibling, 0 replies; 4+ messages in thread
From: Oscar Salvador @ 2025-03-12  8:37 UTC (permalink / raw)
  To: Liu Ye; +Cc: akpm, linux-mm, linux-kernel, willy

On Wed, Mar 12, 2025 at 11:23:44AM +0800, Liu Ye wrote:
> This patch includes several minor fixes:
> 
> - Simplify compound page judgment conditions.
> - Missing a newline character at the end of the format string.
> 
> Each change is independent.

If each change is indepenent, send a patch per change.

Also CC Willy since he has been dealing with __dump_page lately.

 

-- 
Oscar Salvador
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/debug: Fix minor issues in mm
  2025-03-12  3:23 [PATCH v2] mm/debug: Fix minor issues in mm Liu Ye
  2025-03-12  8:37 ` Oscar Salvador
@ 2025-03-12 12:20 ` Matthew Wilcox
  2025-03-13  1:04   ` liuye
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2025-03-12 12:20 UTC (permalink / raw)
  To: Liu Ye; +Cc: akpm, linux-mm, linux-kernel

On Wed, Mar 12, 2025 at 11:23:44AM +0800, Liu Ye wrote:
> - Simplify compound page judgment conditions.

> @@ -132,15 +132,15 @@ static void __dump_page(const struct page *page)
>  again:
>  	memcpy(&precise, page, sizeof(*page));
>  	head = precise.compound_head;
> -	if ((head & 1) == 0) {
> +	if (head & 1) {
> +		foliop = (struct folio *)(head - 1);
> +		idx = folio_page_idx(foliop, page);
> +	} else {
>  		foliop = (struct folio *)&precise;
>  		idx = 0;
>  		if (!folio_test_large(foliop))
>  			goto dump;
>  		foliop = (struct folio *)page;
> -	} else {
> -		foliop = (struct folio *)(head - 1);
> -		idx = folio_page_idx(foliop, page);
>  	}
>  
>  	if (idx < MAX_FOLIO_NR_PAGES) {

How is this "simpler"?  It seems like churn for the sake of churn.
NACK.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/debug: Fix minor issues in mm
  2025-03-12 12:20 ` Matthew Wilcox
@ 2025-03-13  1:04   ` liuye
  0 siblings, 0 replies; 4+ messages in thread
From: liuye @ 2025-03-13  1:04 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: akpm, linux-mm, linux-kernel



在 2025/3/12 20:20, Matthew Wilcox 写道:
>> -	if ((head & 1) == 0) {
>> +	if (head & 1) {
>> +		foliop = (struct folio *)(head - 1);
>> +		idx = folio_page_idx(foliop, page);
>> +	} else {
>>  		foliop = (struct folio *)&precise;
>>  		idx = 0;
>>  		if (!folio_test_large(foliop))
>>  			goto dump;
>>  		foliop = (struct folio *)page;
>> -	} else {
>> -		foliop = (struct folio *)(head - 1);
>> -		idx = folio_page_idx(foliop, page);
>>  	}
>>  
>>  	if (idx < MAX_FOLIO_NR_PAGES) {
> 
> How is this "simpler"?  It seems like churn for the sake of churn.
> NACK.

This modification simplifies the condition check by directly testing 
head & 1 instead of using ((head & 1) == 0). The updated logic first handles
the case where head & 1 is set, assigning foliop and idx accordingly. 
This improves code readability and reduces unnecessary branching, 
making the structure more straightforward and easier to maintain.
I am personally accustomed to this format, but if it is not accepted 
by the majority, then drop it.

Thanks,
Liu Ye                                               




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-13  1:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12  3:23 [PATCH v2] mm/debug: Fix minor issues in mm Liu Ye
2025-03-12  8:37 ` Oscar Salvador
2025-03-12 12:20 ` Matthew Wilcox
2025-03-13  1:04   ` liuye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox