aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8d4335779633..eaaef2a09424 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4035,12 +4035,37 @@ static int __meminit zone_batchsize(struct zone *zone)
4035#endif 4035#endif
4036} 4036}
4037 4037
4038/*
4039 * pcp->high and pcp->batch values are related and dependent on one another:
4040 * ->batch must never be higher then ->high.
4041 * The following function updates them in a safe manner without read side
4042 * locking.
4043 *
4044 * Any new users of pcp->batch and pcp->high should ensure they can cope with
4045 * those fields changing asynchronously (acording the the above rule).
4046 *
4047 * mutex_is_locked(&pcp_batch_high_lock) required when calling this function
4048 * outside of boot time (or some other assurance that no concurrent updaters
4049 * exist).
4050 */
4051static void pageset_update(struct per_cpu_pages *pcp, unsigned long high,
4052 unsigned long batch)
4053{
4054 /* start with a fail safe value for batch */
4055 pcp->batch = 1;
4056 smp_wmb();
4057
4058 /* Update high, then batch, in order */
4059 pcp->high = high;
4060 smp_wmb();
4061
4062 pcp->batch = batch;
4063}
4064
4038/* a companion to setup_pagelist_highmark() */ 4065/* a companion to setup_pagelist_highmark() */
4039static void pageset_set_batch(struct per_cpu_pageset *p, unsigned long batch) 4066static void pageset_set_batch(struct per_cpu_pageset *p, unsigned long batch)
4040{ 4067{
4041 struct per_cpu_pages *pcp = &p->pcp; 4068 pageset_update(&p->pcp, 6 * batch, max(1UL, 1 * batch));
4042 pcp->high = 6 * batch;
4043 pcp->batch = max(1UL, 1 * batch);
4044} 4069}
4045 4070
4046static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) 4071static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
@@ -4064,13 +4089,11 @@ static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
4064static void setup_pagelist_highmark(struct per_cpu_pageset *p, 4089static void setup_pagelist_highmark(struct per_cpu_pageset *p,
4065 unsigned long high) 4090 unsigned long high)
4066{ 4091{
4067 struct per_cpu_pages *pcp; 4092 unsigned long batch = max(1UL, high / 4);
4093 if ((high / 4) > (PAGE_SHIFT * 8))
4094 batch = PAGE_SHIFT * 8;
4068 4095
4069 pcp = &p->pcp; 4096 pageset_update(&p->pcp, high, batch);
4070 pcp->high = high;
4071 pcp->batch = max(1UL, high/4);
4072 if ((high/4) > (PAGE_SHIFT * 8))
4073 pcp->batch = PAGE_SHIFT * 8;
4074} 4097}
4075 4098
4076static void __meminit setup_zone_pageset(struct zone *zone) 4099static void __meminit setup_zone_pageset(struct zone *zone)