Generic Linux architectural discussions
 help / color / mirror / Atom feed
* [PATCH 2/3] mm: Warn if pg_data_t isn't initialized with zero
       [not found] <1343092235-13399-1-git-send-email-minchan@kernel.org>
@ 2012-07-24  1:10 ` Minchan Kim
  2012-07-24  1:10   ` Minchan Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Minchan Kim @ 2012-07-24  1:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Tejun Heo, Yinghai Lu, linux-mm, linux-kernel, Minchan Kim,
	linux-arch

This patch warns if memory-hotplug/boot code doesn't initialize
pg_data_t with zero when it's allocated. As I looked arch code and
memory hotplug, they already seem to initiailize pg_data_t.
So this warning should be never happen. It needs double check and
let's add checking garbage with warn. I select fields randomly
nearyby begin/middle/end of pg_data_t for checking garbage.
If we are very unlucky, those garbage might be zero but it's very unlikely,
I hope.

This patch isn't for performance but removing initialization code
which is necessary to add whenever we adds new field to pg_data_t or zone.
It's rather bothersome and error-prone about compile at least as I had
experienced.

Firstly, Andrew suggested clearing out of pg_data_t in MM core part but
Tejun doesn't like it because in the future, some archs can initialize
some fields in arch code and pass them into general MM part so blindly clearing
it out in mm core part would be very annoying.

Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-arch <linux-arch@vger.kernel.org>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/page_alloc.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b65c362..2037eeb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4517,6 +4517,9 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
 {
 	pg_data_t *pgdat = NODE_DATA(nid);
 
+	/* pg_data_t should be reset to zero when it's allocated */
+	WARN_ON(pgdat->nr_zones || pgdat->node_start_pfn || pgdat->classzone_idx);
+
 	pgdat->node_id = nid;
 	pgdat->node_start_pfn = node_start_pfn;
 	calculate_node_totalpages(pgdat, zones_size, zholes_size);
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH 2/3] mm: Warn if pg_data_t isn't initialized with zero
  2012-07-24  1:10 ` [PATCH 2/3] mm: Warn if pg_data_t isn't initialized with zero Minchan Kim
@ 2012-07-24  1:10   ` Minchan Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Minchan Kim @ 2012-07-24  1:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Tejun Heo, Yinghai Lu, linux-mm, linux-kernel, Minchan Kim,
	linux-arch

This patch warns if memory-hotplug/boot code doesn't initialize
pg_data_t with zero when it's allocated. As I looked arch code and
memory hotplug, they already seem to initiailize pg_data_t.
So this warning should be never happen. It needs double check and
let's add checking garbage with warn. I select fields randomly
nearyby begin/middle/end of pg_data_t for checking garbage.
If we are very unlucky, those garbage might be zero but it's very unlikely,
I hope.

This patch isn't for performance but removing initialization code
which is necessary to add whenever we adds new field to pg_data_t or zone.
It's rather bothersome and error-prone about compile at least as I had
experienced.

Firstly, Andrew suggested clearing out of pg_data_t in MM core part but
Tejun doesn't like it because in the future, some archs can initialize
some fields in arch code and pass them into general MM part so blindly clearing
it out in mm core part would be very annoying.

Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-arch <linux-arch@vger.kernel.org>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/page_alloc.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b65c362..2037eeb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4517,6 +4517,9 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
 {
 	pg_data_t *pgdat = NODE_DATA(nid);
 
+	/* pg_data_t should be reset to zero when it's allocated */
+	WARN_ON(pgdat->nr_zones || pgdat->node_start_pfn || pgdat->classzone_idx);
+
 	pgdat->node_id = nid;
 	pgdat->node_start_pfn = node_start_pfn;
 	calculate_node_totalpages(pgdat, zones_size, zholes_size);
-- 
1.7.9.5


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

end of thread, other threads:[~2012-07-24  1:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1343092235-13399-1-git-send-email-minchan@kernel.org>
2012-07-24  1:10 ` [PATCH 2/3] mm: Warn if pg_data_t isn't initialized with zero Minchan Kim
2012-07-24  1:10   ` Minchan Kim

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