Skip to contentSkip to conversation

trace: don't call page_to_pfn() if page is NULL

PATCH In review Wen Congyang 4 participants 6 messages Sep 20, 2012 – Sep 21, 2012 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: don't call page_to_pfn() if page is NULL

When allocating memory fails, page is NULL. page_to_pfn() will cause the kernel panicked if we don't use sparsemem vmemmap.

---
 include/trace/events/kmem.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/trace/events/kmem.h +2 -2
index 5f889f1..08fa272 100644
@@ -214,7 +214,7 @@ TRACE_EVENT(mm_page_alloc,
 
 	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
 		__entry->page,
-		page_to_pfn(__entry->page),
+		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
 		show_gfp_flags(__entry->gfp_flags))
@@ -240,7 +240,7 @@ DECLARE_EVENT_CLASS(mm_page,
 
 	TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
 		__entry->page,
-		page_to_pfn(__entry->page),
+		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
 		__entry->order == 0)
Signature · 1 line
1.7.1
maintainer
#2 lore raw
Quoted 8 lines · Minchan Kim
Quoted 4 lines · Wen Congyang

When allocating memory fails, page is NULL. page_to_pfn() will cause the kernel panicked if we don't use sparsemem vmemmap.

Nice catch.
I think it's a candidate of stable.

Yeah, and it looks like it can go against all stable kernels as it was introduced back in 2.6.32. I'll apply and start testing it.

Thanks,

-- Steve

Quoted 3 lines
maintainer
#3 lore raw
In reply to Wen Congyang

Mel,

As you were the original author of this code, can I get your Acked-by?

Thanks,

-- Steve

Quoted 31 lines · Wen Congyang

When allocating memory fails, page is NULL. page_to_pfn() will cause the kernel panicked if we don't use sparsemem vmemmap.

---
 include/trace/events/kmem.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/trace/events/kmem.h +2 -2
index 5f889f1..08fa272 100644
@@ -214,7 +214,7 @@ TRACE_EVENT(mm_page_alloc,
 
 	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
 		__entry->page,
-		page_to_pfn(__entry->page),
+		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
 		show_gfp_flags(__entry->gfp_flags))
@@ -240,7 +240,7 @@ DECLARE_EVENT_CLASS(mm_page,
 
 	TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
 		__entry->page,
-		page_to_pfn(__entry->page),
+		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
 		__entry->order == 0)
Acked-by
#4 lore raw
Quoted 4 lines · Steven Rostedt

Mel,

As you were the original author of this code, can I get your Acked-by?

Sure. Problem as described is valid and the patch looks ok

Signature · 2 lines
Mel Gorman
SUSE Labs
#5 lore raw

[tip:perf/urgent] tracing: Don't call page_to_pfn() if page is NULL

In reply to Wen Congyang
Commit-ID:  85f2a2ef1d0ab99523e0b947a2b723f5650ed6aa
Gitweb:     http://git.kernel.org/tip/85f2a2ef1d0ab99523e0b947a2b723f5650ed6aa
Author:     Wen Congyang <[email protected]>
AuthorDate: Thu, 20 Sep 2012 14:04:47 +0800
Committer:  Steven Rostedt <[email protected]>
CommitDate: Thu, 20 Sep 2012 15:51:16 -0400

tracing: Don't call page_to_pfn() if page is NULL

When allocating memory fails, page is NULL. page_to_pfn() will cause the kernel panicked if we don't use sparsemem vmemmap.

---
 include/trace/events/kmem.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/trace/events/kmem.h +2 -2
index 5f889f1..08fa272 100644
@@ -214,7 +214,7 @@ TRACE_EVENT(mm_page_alloc,
 
 	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
 		__entry->page,
-		page_to_pfn(__entry->page),
+		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
 		show_gfp_flags(__entry->gfp_flags))
@@ -240,7 +240,7 @@ DECLARE_EVENT_CLASS(mm_page,
 
 	TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
 		__entry->page,
-		page_to_pfn(__entry->page),
+		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
 		__entry->order == 0)