All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <20120920051628.GE13234@bbox>

diff --git a/a/1.txt b/N1/1.txt
index d5a1b70..2f0a377 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -73,3 +73,119 @@ Anyway, it's another story with this patch because it's not merged yet.
 
 Good point.
 How about this?
+
+>From e92bf3e96720c89cb18ec32c5db095a27ad4133c Mon Sep 17 00:00:00 2001
+From: Minchan Kim <minchan@kernel.org>
+Date: Thu, 20 Sep 2012 14:11:49 +0900
+Subject: [PATCH v2] memory-hotplug: fix zone stat mismatch
+
+During memory-hotplug, I found NR_ISOLATED_[ANON|FILE]
+are increasing so that kernel are hang out.
+
+The cause is that when we do memory-hotadd after memory-remove,
+__zone_pcp_update clear out zone's ZONE_STAT_ITEMS in setup_pageset
+although vm_stat_diff of all CPU still have value.
+
+In addtion, when we offline all pages of the zone, we reset them
+in zone_pcp_reset without drain so that we lost zone stat item.
+
+This patch fixes it.
+
+* from v1
+  * drain offline patch - KOSAKI, Wen
+
+Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
+Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
+Cc: Wen Congyang <wency@cn.fujitsu.com>
+Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Signed-off-by: Minchan Kim <minchan@kernel.org>
+---
+ include/linux/vmstat.h |    4 ++++
+ mm/page_alloc.c        |    7 +++++++
+ mm/vmstat.c            |   12 ++++++++++++
+ 3 files changed, 23 insertions(+)
+
+diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
+index ad2cfd5..5d31876 100644
+--- a/include/linux/vmstat.h
++++ b/include/linux/vmstat.h
+@@ -198,6 +198,8 @@ extern void __dec_zone_state(struct zone *, enum zone_stat_item);
+ void refresh_cpu_vm_stats(int);
+ void refresh_zone_stat_thresholds(void);
+ 
++void drain_zonestat(struct zone *zone, struct per_cpu_pageset *);
++
+ int calculate_pressure_threshold(struct zone *zone);
+ int calculate_normal_threshold(struct zone *zone);
+ void set_pgdat_percpu_threshold(pg_data_t *pgdat,
+@@ -251,6 +253,8 @@ static inline void __dec_zone_page_state(struct page *page,
+ static inline void refresh_cpu_vm_stats(int cpu) { }
+ static inline void refresh_zone_stat_thresholds(void) { }
+ 
++static inline void drain_zonestat(struct zone *zone,
++			struct per_cpu_pageset *pset) { }
+ #endif		/* CONFIG_SMP */
+ 
+ extern const char * const vmstat_text[];
+diff --git a/mm/page_alloc.c b/mm/page_alloc.c
+index ab58346..980f2e7 100644
+--- a/mm/page_alloc.c
++++ b/mm/page_alloc.c
+@@ -5904,6 +5904,7 @@ static int __meminit __zone_pcp_update(void *data)
+ 		local_irq_save(flags);
+ 		if (pcp->count > 0)
+ 			free_pcppages_bulk(zone, pcp->count, pcp);
++		drain_zonestat(zone, pset);
+ 		setup_pageset(pset, batch);
+ 		local_irq_restore(flags);
+ 	}
+@@ -5920,10 +5921,16 @@ void __meminit zone_pcp_update(struct zone *zone)
+ void zone_pcp_reset(struct zone *zone)
+ {
+ 	unsigned long flags;
++	int cpu;
++	struct per_cpu_pageset *pset;
+ 
+ 	/* avoid races with drain_pages()  */
+ 	local_irq_save(flags);
+ 	if (zone->pageset != &boot_pageset) {
++		for_each_online_cpu(cpu) {
++			pset = per_cpu_ptr(zone->pageset, cpu);
++			drain_zonestat(zone, pset);
++		}
+ 		free_percpu(zone->pageset);
+ 		zone->pageset = &boot_pageset;
+ 	}
+diff --git a/mm/vmstat.c b/mm/vmstat.c
+index b3e3b9d..d4cc1c2 100644
+--- a/mm/vmstat.c
++++ b/mm/vmstat.c
+@@ -495,6 +495,18 @@ void refresh_cpu_vm_stats(int cpu)
+ 			atomic_long_add(global_diff[i], &vm_stat[i]);
+ }
+ 
++void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
++{
++	int i;
++
++	for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
++		if (pset->vm_stat_diff[i]) {
++			int v = pset->vm_stat_diff[i];
++			pset->vm_stat_diff[i] = 0;
++			atomic_long_add(v, &zone->vm_stat[i]);
++			atomic_long_add(v, &vm_stat[i]);
++		}
++}
+ #endif
+ 
+ #ifdef CONFIG_NUMA
+-- 
+1.7.9.5
+
+
+
+
+
+-- 
+Kind regards,
+Minchan Kim
diff --git a/a/content_digest b/N1/content_digest
index 8596595..d09d218 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -91,6 +91,122 @@
  "> zone_pcp_reset().\n"
  "\n"
  "Good point.\n"
- How about this?
+ "How about this?\n"
+ "\n"
+ ">From e92bf3e96720c89cb18ec32c5db095a27ad4133c Mon Sep 17 00:00:00 2001\n"
+ "From: Minchan Kim <minchan@kernel.org>\n"
+ "Date: Thu, 20 Sep 2012 14:11:49 +0900\n"
+ "Subject: [PATCH v2] memory-hotplug: fix zone stat mismatch\n"
+ "\n"
+ "During memory-hotplug, I found NR_ISOLATED_[ANON|FILE]\n"
+ "are increasing so that kernel are hang out.\n"
+ "\n"
+ "The cause is that when we do memory-hotadd after memory-remove,\n"
+ "__zone_pcp_update clear out zone's ZONE_STAT_ITEMS in setup_pageset\n"
+ "although vm_stat_diff of all CPU still have value.\n"
+ "\n"
+ "In addtion, when we offline all pages of the zone, we reset them\n"
+ "in zone_pcp_reset without drain so that we lost zone stat item.\n"
+ "\n"
+ "This patch fixes it.\n"
+ "\n"
+ "* from v1\n"
+ "  * drain offline patch - KOSAKI, Wen\n"
+ "\n"
+ "Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>\n"
+ "Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>\n"
+ "Cc: Wen Congyang <wency@cn.fujitsu.com>\n"
+ "Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>\n"
+ "Signed-off-by: Minchan Kim <minchan@kernel.org>\n"
+ "---\n"
+ " include/linux/vmstat.h |    4 ++++\n"
+ " mm/page_alloc.c        |    7 +++++++\n"
+ " mm/vmstat.c            |   12 ++++++++++++\n"
+ " 3 files changed, 23 insertions(+)\n"
+ "\n"
+ "diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h\n"
+ "index ad2cfd5..5d31876 100644\n"
+ "--- a/include/linux/vmstat.h\n"
+ "+++ b/include/linux/vmstat.h\n"
+ "@@ -198,6 +198,8 @@ extern void __dec_zone_state(struct zone *, enum zone_stat_item);\n"
+ " void refresh_cpu_vm_stats(int);\n"
+ " void refresh_zone_stat_thresholds(void);\n"
+ " \n"
+ "+void drain_zonestat(struct zone *zone, struct per_cpu_pageset *);\n"
+ "+\n"
+ " int calculate_pressure_threshold(struct zone *zone);\n"
+ " int calculate_normal_threshold(struct zone *zone);\n"
+ " void set_pgdat_percpu_threshold(pg_data_t *pgdat,\n"
+ "@@ -251,6 +253,8 @@ static inline void __dec_zone_page_state(struct page *page,\n"
+ " static inline void refresh_cpu_vm_stats(int cpu) { }\n"
+ " static inline void refresh_zone_stat_thresholds(void) { }\n"
+ " \n"
+ "+static inline void drain_zonestat(struct zone *zone,\n"
+ "+\t\t\tstruct per_cpu_pageset *pset) { }\n"
+ " #endif\t\t/* CONFIG_SMP */\n"
+ " \n"
+ " extern const char * const vmstat_text[];\n"
+ "diff --git a/mm/page_alloc.c b/mm/page_alloc.c\n"
+ "index ab58346..980f2e7 100644\n"
+ "--- a/mm/page_alloc.c\n"
+ "+++ b/mm/page_alloc.c\n"
+ "@@ -5904,6 +5904,7 @@ static int __meminit __zone_pcp_update(void *data)\n"
+ " \t\tlocal_irq_save(flags);\n"
+ " \t\tif (pcp->count > 0)\n"
+ " \t\t\tfree_pcppages_bulk(zone, pcp->count, pcp);\n"
+ "+\t\tdrain_zonestat(zone, pset);\n"
+ " \t\tsetup_pageset(pset, batch);\n"
+ " \t\tlocal_irq_restore(flags);\n"
+ " \t}\n"
+ "@@ -5920,10 +5921,16 @@ void __meminit zone_pcp_update(struct zone *zone)\n"
+ " void zone_pcp_reset(struct zone *zone)\n"
+ " {\n"
+ " \tunsigned long flags;\n"
+ "+\tint cpu;\n"
+ "+\tstruct per_cpu_pageset *pset;\n"
+ " \n"
+ " \t/* avoid races with drain_pages()  */\n"
+ " \tlocal_irq_save(flags);\n"
+ " \tif (zone->pageset != &boot_pageset) {\n"
+ "+\t\tfor_each_online_cpu(cpu) {\n"
+ "+\t\t\tpset = per_cpu_ptr(zone->pageset, cpu);\n"
+ "+\t\t\tdrain_zonestat(zone, pset);\n"
+ "+\t\t}\n"
+ " \t\tfree_percpu(zone->pageset);\n"
+ " \t\tzone->pageset = &boot_pageset;\n"
+ " \t}\n"
+ "diff --git a/mm/vmstat.c b/mm/vmstat.c\n"
+ "index b3e3b9d..d4cc1c2 100644\n"
+ "--- a/mm/vmstat.c\n"
+ "+++ b/mm/vmstat.c\n"
+ "@@ -495,6 +495,18 @@ void refresh_cpu_vm_stats(int cpu)\n"
+ " \t\t\tatomic_long_add(global_diff[i], &vm_stat[i]);\n"
+ " }\n"
+ " \n"
+ "+void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)\n"
+ "+{\n"
+ "+\tint i;\n"
+ "+\n"
+ "+\tfor (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)\n"
+ "+\t\tif (pset->vm_stat_diff[i]) {\n"
+ "+\t\t\tint v = pset->vm_stat_diff[i];\n"
+ "+\t\t\tpset->vm_stat_diff[i] = 0;\n"
+ "+\t\t\tatomic_long_add(v, &zone->vm_stat[i]);\n"
+ "+\t\t\tatomic_long_add(v, &vm_stat[i]);\n"
+ "+\t\t}\n"
+ "+}\n"
+ " #endif\n"
+ " \n"
+ " #ifdef CONFIG_NUMA\n"
+ "-- \n"
+ "1.7.9.5\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "-- \n"
+ "Kind regards,\n"
+ Minchan Kim
 
-5a95e1dc878d1c1a733f808d4248af3d3b01ad4125a92fd877f83dcbaa9f3bd4
+18a8b1d09f700571791ee5a3b70f647225a26f3795cee6123b4a4310769efba0

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.