Magellan Linux

Contents of /trunk/kernel26-magellan/patches-2.6.17-r6/0021-2.6.17-mm-kswapd_inherit_prio-1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 105 - (show annotations) (download)
Sun Mar 11 16:17:56 2007 UTC (17 years, 7 months ago) by niro
File size: 3806 byte(s)
2.6.17-magellan-r6

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 include/linux/mmzone.h | 2 +-
8 mm/page_alloc.c | 2 +-
9 mm/vmscan.c | 40 ++++++++++++++++++++++++++++++++++++++--
10 3 files changed, 40 insertions(+), 4 deletions(-)
11
12 Index: linux-ck-dev/include/linux/mmzone.h
13 ===================================================================
14 --- linux-ck-dev.orig/include/linux/mmzone.h 2006-06-18 15:25:00.000000000 +1000
15 +++ linux-ck-dev/include/linux/mmzone.h 2006-06-18 15:25:02.000000000 +1000
16 @@ -330,7 +330,7 @@ void __get_zone_counts(unsigned long *ac
17 void get_zone_counts(unsigned long *active, unsigned long *inactive,
18 unsigned long *free);
19 void build_all_zonelists(void);
20 -void wakeup_kswapd(struct zone *zone, int order);
21 +void wakeup_kswapd(struct zone *zone, int order, struct task_struct *p);
22 int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
23 int classzone_idx, int alloc_flags);
24
25 Index: linux-ck-dev/mm/page_alloc.c
26 ===================================================================
27 --- linux-ck-dev.orig/mm/page_alloc.c 2006-06-18 15:25:00.000000000 +1000
28 +++ linux-ck-dev/mm/page_alloc.c 2006-06-18 15:25:02.000000000 +1000
29 @@ -952,7 +952,7 @@ restart:
30
31 do {
32 if (cpuset_zone_allowed(*z, gfp_mask|__GFP_HARDWALL))
33 - wakeup_kswapd(*z, order);
34 + wakeup_kswapd(*z, order, p);
35 } while (*(++z));
36
37 /*
38 Index: linux-ck-dev/mm/vmscan.c
39 ===================================================================
40 --- linux-ck-dev.orig/mm/vmscan.c 2006-06-18 15:25:00.000000000 +1000
41 +++ linux-ck-dev/mm/vmscan.c 2006-06-18 15:25:02.000000000 +1000
42 @@ -897,6 +897,38 @@ static unsigned long shrink_zone(int pri
43 }
44
45 /*
46 + * Helper functions to adjust nice level of kswapd, based on the priority of
47 + * the task (p) that called it. If it is already higher priority we do not
48 + * demote its nice level since it is still working on behalf of a higher
49 + * priority task. With kernel threads we leave it at nice 0.
50 + *
51 + * We don't ever run kswapd real time, so if a real time task calls kswapd we
52 + * set it to highest SCHED_NORMAL priority.
53 + */
54 +static int effective_sc_prio(struct task_struct *p)
55 +{
56 + if (likely(p->mm)) {
57 + if (rt_task(p))
58 + return -20;
59 + return task_nice(p);
60 + }
61 + return 0;
62 +}
63 +
64 +static void set_kswapd_nice(task_t *kswapd, task_t *p, int active)
65 +{
66 + long nice = effective_sc_prio(p);
67 +
68 + if (task_nice(kswapd) > nice || !active)
69 + set_user_nice(kswapd, nice);
70 +}
71 +
72 +static int sc_priority(struct task_struct *p)
73 +{
74 + return (DEF_PRIORITY + (DEF_PRIORITY * effective_sc_prio(p) / 40));
75 +}
76 +
77 +/*
78 * This is the direct reclaim path, for page-allocating processes. We only
79 * try to reclaim pages from zones which will satisfy the caller's allocation
80 * request.
81 @@ -1266,6 +1298,7 @@ static int kswapd(void *p)
82 */
83 order = new_order;
84 } else {
85 + set_user_nice(tsk, 0);
86 schedule();
87 order = pgdat->kswapd_max_order;
88 }
89 @@ -1279,9 +1312,10 @@ static int kswapd(void *p)
90 /*
91 * A zone is low on free memory, so wake its kswapd task to service it.
92 */
93 -void wakeup_kswapd(struct zone *zone, int order)
94 +void wakeup_kswapd(struct zone *zone, int order, struct task_struct *p)
95 {
96 pg_data_t *pgdat;
97 + int active;
98
99 if (!populated_zone(zone))
100 return;
101 @@ -1293,7 +1327,9 @@ void wakeup_kswapd(struct zone *zone, in
102 pgdat->kswapd_max_order = order;
103 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
104 return;
105 - if (!waitqueue_active(&pgdat->kswapd_wait))
106 + active = waitqueue_active(&pgdat->kswapd_wait);
107 + set_kswapd_nice(pgdat->kswapd, p, active);
108 + if (!active)
109 return;
110 wake_up_interruptible(&pgdat->kswapd_wait);
111 }