Changes to series and rx51_defconfig file for BFQ
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / mm-kswapd_inherit_prio-1.patch
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.
4
5 Signed-off-by: Con Kolivas <kernel@kolivas.org>
6
7  mm/vmscan.c |   33 ++++++++++++++++++++++++++++++++-
8  1 file changed, 32 insertions(+), 1 deletion(-)
9
10 Index: linux-2.6.34-ck1/mm/vmscan.c
11 ===================================================================
12 --- linux-2.6.34-ck1.orig/mm/vmscan.c   2010-05-18 12:26:16.647319427 +1000
13 +++ linux-2.6.34-ck1/mm/vmscan.c        2010-05-18 12:26:16.805569620 +1000
14 @@ -1697,6 +1697,33 @@ static void shrink_zone(int priority, st
15  }
16  
17  /*
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)
27 +{
28 +       if (likely(p->mm)) {
29 +               if (rt_task(p))
30 +                       return -20;
31 +               return task_nice(p);
32 +       }
33 +       return 0;
34 +}
35 +
36 +static void set_kswapd_nice(struct task_struct *kswapd, int active)
37 +{
38 +       long nice = effective_sc_prio(current);
39 +
40 +       if (task_nice(kswapd) > nice || !active)
41 +               set_user_nice(kswapd, nice);
42 +}
43 +
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 @@ -2294,6 +2321,7 @@ static int kswapd(void *p)
49                                 }
50                         }
51  
52 +                       set_user_nice(tsk, 0);
53                         order = pgdat->kswapd_max_order;
54                 }
55                 finish_wait(&pgdat->kswapd_wait, &wait);
56 @@ -2318,6 +2346,7 @@ static int kswapd(void *p)
57  void wakeup_kswapd(struct zone *zone, int order)
58  {
59         pg_data_t *pgdat;
60 +       int active;
61  
62         if (!populated_zone(zone))
63                 return;
64 @@ -2329,7 +2358,9 @@ void wakeup_kswapd(struct zone *zone, in
65                 pgdat->kswapd_max_order = order;
66         if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
67                 return;
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         wake_up_interruptible(&pgdat->kswapd_wait);
74  }
75