updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / kernel26-lts-ck / mm-kswapd_inherit_prio-1.patch
blobacd13929fb595dbecaecd55dff647df2c4257d9b
1 When kswapd is awoken due to reclaim by a running task, set the priority of
2 kswapd to that of the calling task thus making memory reclaim cpu activity
3 affected by nice level.
5 Signed-off-by: Con Kolivas <kernel@kolivas.org>
7 mm/vmscan.c | 33 ++++++++++++++++++++++++++++++++-
8 1 file changed, 32 insertions(+), 1 deletion(-)
10 Index: linux-2.6.35.11-ck1/mm/vmscan.c
11 ===================================================================
12 --- linux-2.6.35.11-ck1.orig/mm/vmscan.c 2011-03-29 22:12:01.124555385 +1100
13 +++ linux-2.6.35.11-ck1/mm/vmscan.c 2011-03-29 22:12:01.298555385 +1100
14 @@ -1711,6 +1711,33 @@ static void shrink_zone(int priority, st
18 + * Helper functions to adjust nice level of kswapd, based on the priority of
19 + * the task (p) that called it. If it is already higher priority we do not
20 + * demote its nice level since it is still working on behalf of a higher
21 + * priority task. With kernel threads we leave it at nice 0.
22 + *
23 + * We don't ever run kswapd real time, so if a real time task calls kswapd we
24 + * set it to highest SCHED_NORMAL priority.
25 + */
26 +static inline int effective_sc_prio(struct task_struct *p)
28 + if (likely(p->mm)) {
29 + if (rt_task(p))
30 + return -20;
31 + return task_nice(p);
32 + }
33 + return 0;
36 +static void set_kswapd_nice(struct task_struct *kswapd, int active)
38 + long nice = effective_sc_prio(current);
40 + if (task_nice(kswapd) > nice || !active)
41 + set_user_nice(kswapd, nice);
44 +/*
45 * This is the direct reclaim path, for page-allocating processes. We only
46 * try to reclaim pages from zones which will satisfy the caller's allocation
47 * request.
48 @@ -2336,6 +2363,7 @@ static int kswapd(void *p)
52 + set_user_nice(tsk, 0);
53 order = pgdat->kswapd_max_order;
55 finish_wait(&pgdat->kswapd_wait, &wait);
56 @@ -2360,6 +2388,7 @@ static int kswapd(void *p)
57 void wakeup_kswapd(struct zone *zone, int order)
59 pg_data_t *pgdat;
60 + int active;
62 if (!populated_zone(zone))
63 return;
64 @@ -2407,7 +2407,9 @@ void wakeup_kswapd(struct zone *zone, in
65 pgdat = zone->zone_pgdat;
66 if (pgdat->kswapd_max_order < order)
67 pgdat->kswapd_max_order = order;
68 - if (!waitqueue_active(&pgdat->kswapd_wait))
69 + active = waitqueue_active(&pgdat->kswapd_wait);
70 + set_kswapd_nice(pgdat->kswapd, active);
71 + if (!active)
72 return;
73 if (zone_watermark_ok_safe(zone, order, low_wmark_pages(zone), 0, 0))
74 return;