* [PATCH 1/3] mips: zero out pg_data_t when it's allocated
@ 2012-07-24 1:10 Minchan Kim
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 ` [PATCH 3/3] mm: remove redundant initialization Minchan Kim
0 siblings, 2 replies; 3+ 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,
Ralf Baechle, linux-mips
This patch is ready for next patch which try to remove zero-out
of pg_data_t in core MM part. At a glance, all archs except this part
already have done it so this patch makes consistent with other archs.
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
arch/mips/sgi-ip27/ip27-memory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index b105eca..cd8fcab 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -401,6 +401,7 @@ static void __init node_mem_init(cnodeid_t node)
* Allocate the node data structures on the node first.
*/
__node_data[node] = __va(slot_freepfn << PAGE_SHIFT);
+ memset(__node_data[node], 0, PAGE_SIZE);
NODE_DATA(node)->bdata = &bootmem_node_data[node];
NODE_DATA(node)->node_start_pfn = start_pfn;
--
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] 3+ messages in thread
* [PATCH 2/3] mm: Warn if pg_data_t isn't initialized with zero
2012-07-24 1:10 [PATCH 1/3] mips: zero out pg_data_t when it's allocated Minchan Kim
@ 2012-07-24 1:10 ` Minchan Kim
2012-07-24 1:10 ` [PATCH 3/3] mm: remove redundant initialization Minchan Kim
1 sibling, 0 replies; 3+ 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] 3+ messages in thread
* [PATCH 3/3] mm: remove redundant initialization
2012-07-24 1:10 [PATCH 1/3] mips: zero out pg_data_t when it's allocated Minchan Kim
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
1 sibling, 0 replies; 3+ 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
pg_data_t should be zero out before reaching free_area_init_core
so remove unnecessary initialization.
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
include/linux/vmstat.h | 5 -----
mm/page_alloc.c | 9 ++-------
2 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 65efb92..ad2cfd5 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -179,11 +179,6 @@ extern void zone_statistics(struct zone *, struct zone *, gfp_t gfp);
#define add_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, __d)
#define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d))
-static inline void zap_zone_vm_stats(struct zone *zone)
-{
- memset(zone->vm_stat, 0, sizeof(zone->vm_stat));
-}
-
extern void inc_zone_state(struct zone *, enum zone_stat_item);
#ifdef CONFIG_SMP
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2037eeb..7b09ecc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4376,6 +4376,8 @@ void __init set_pageblock_order(void)
* - mark all pages reserved
* - mark all memory queues empty
* - clear the memory bitmaps
+ *
+ * NOTE: pgdat should get zeroed by caller.
*/
static void __paginginit free_area_init_core(struct pglist_data *pgdat,
unsigned long *zones_size, unsigned long *zholes_size)
@@ -4386,10 +4388,8 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
int ret;
pgdat_resize_init(pgdat);
- pgdat->nr_zones = 0;
init_waitqueue_head(&pgdat->kswapd_wait);
init_waitqueue_head(&pgdat->pfmemalloc_wait);
- pgdat->kswapd_max_order = 0;
pgdat_page_cgroup_init(pgdat);
for (j = 0; j < MAX_NR_ZONES; j++) {
@@ -4450,11 +4450,6 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
zone_pcp_init(zone);
lruvec_init(&zone->lruvec, zone);
- zap_zone_vm_stats(zone);
- zone->flags = 0;
-#ifdef CONFIG_MEMORY_ISOLATION
- zone->nr_pageblock_isolate = 0;
-#endif
if (!size)
continue;
--
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] 3+ messages in thread
end of thread, other threads:[~2012-07-24 1:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-24 1:10 [PATCH 1/3] mips: zero out pg_data_t when it's allocated Minchan Kim
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 ` [PATCH 3/3] mm: remove redundant initialization Minchan Kim
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).