diff options
author | Cody P Schafer <cody@linux.vnet.ibm.com> | 2013-07-03 18:01:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:26 -0400 |
commit | 4008bab7b3969ad9f9dd1d02096a3f0aa5610bd2 (patch) | |
tree | a50e5b26ccc1838fb00f982f3ae9907d978e27fe /mm/page_alloc.c | |
parent | 52c2dad914ca3ac84926106d95ddf47de2f40b45 (diff) |
mm/page_alloc: factor out setting of pcp->high and pcp->batch
"Problems" with the current code:
1: there is a lack of synchronization in setting ->high and ->batch in
percpu_pagelist_fraction_sysctl_handler()
2: stop_machine() in zone_pcp_update() is unnecissary.
3: zone_pcp_update() does not consider the case where
percpu_pagelist_fraction is non-zero
To fix:
1: add memory barriers, a safe ->batch value, an update side mutex when
updating ->high and ->batch, and use ACCESS_ONCE() for ->batch users
that expect a stable value.
2: avoid draining pages in zone_pcp_update(), rely upon the memory
barriers added to fix #1
3: factor out quite a few functions, and then call the appropriate one.
Note that it results in a change to the behavior of zone_pcp_update(),
which is used by memory_hotplug. I'm rather certain that I've diserned
(and preserved) the essential behavior (changing ->high and ->batch), and
only eliminated unneeded actions (draining the per cpu pages), but this
may not be the case.
Further note that the draining of pages that previously took place in
zone_pcp_update() occured after repeated draining when attempting to
offline a page, and after the offline has "succeeded". It appears that
the draining was added to zone_pcp_update() to avoid refactoring
setup_pageset() into 2 funtions.
This patch:
Creates pageset_set_batch() for use in setup_pageset().
pageset_set_batch() imitates the functionality of
setup_pagelist_highmark(), but uses the boot time
(percpu_pagelist_fraction == 0) calculations for determining ->high based
on ->batch.
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Cc: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c3edb624fccf..d4bcc20ab6f0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4032,6 +4032,14 @@ static int __meminit zone_batchsize(struct zone *zone) | |||
4032 | #endif | 4032 | #endif |
4033 | } | 4033 | } |
4034 | 4034 | ||
4035 | /* a companion to setup_pagelist_highmark() */ | ||
4036 | static void pageset_set_batch(struct per_cpu_pageset *p, unsigned long batch) | ||
4037 | { | ||
4038 | struct per_cpu_pages *pcp = &p->pcp; | ||
4039 | pcp->high = 6 * batch; | ||
4040 | pcp->batch = max(1UL, 1 * batch); | ||
4041 | } | ||
4042 | |||
4035 | static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) | 4043 | static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) |
4036 | { | 4044 | { |
4037 | struct per_cpu_pages *pcp; | 4045 | struct per_cpu_pages *pcp; |
@@ -4041,8 +4049,7 @@ static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) | |||
4041 | 4049 | ||
4042 | pcp = &p->pcp; | 4050 | pcp = &p->pcp; |
4043 | pcp->count = 0; | 4051 | pcp->count = 0; |
4044 | pcp->high = 6 * batch; | 4052 | pageset_set_batch(p, batch); |
4045 | pcp->batch = max(1UL, 1 * batch); | ||
4046 | for (migratetype = 0; migratetype < MIGRATE_PCPTYPES; migratetype++) | 4053 | for (migratetype = 0; migratetype < MIGRATE_PCPTYPES; migratetype++) |
4047 | INIT_LIST_HEAD(&pcp->lists[migratetype]); | 4054 | INIT_LIST_HEAD(&pcp->lists[migratetype]); |
4048 | } | 4055 | } |
@@ -4051,7 +4058,6 @@ static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) | |||
4051 | * setup_pagelist_highmark() sets the high water mark for hot per_cpu_pagelist | 4058 | * setup_pagelist_highmark() sets the high water mark for hot per_cpu_pagelist |
4052 | * to the value high for the pageset p. | 4059 | * to the value high for the pageset p. |
4053 | */ | 4060 | */ |
4054 | |||
4055 | static void setup_pagelist_highmark(struct per_cpu_pageset *p, | 4061 | static void setup_pagelist_highmark(struct per_cpu_pageset *p, |
4056 | unsigned long high) | 4062 | unsigned long high) |
4057 | { | 4063 | { |