Annotation of /trunk/kernel26-magellan/patches-2.6.16-r3/0022-2.6.16-mm-kswapd_inherit_prio-1.patch
Parent Directory | Revision Log
Revision 70 -
(hide annotations)
(download)
Thu May 11 19:09:22 2006 UTC (18 years, 4 months ago) by niro
File size: 3576 byte(s)
Thu May 11 19:09:22 2006 UTC (18 years, 4 months ago) by niro
File size: 3576 byte(s)
import
1 | niro | 70 | include/linux/mmzone.h | 2 +- |
2 | mm/page_alloc.c | 2 +- | ||
3 | mm/vmscan.c | 40 ++++++++++++++++++++++++++++++++++++++-- | ||
4 | 3 files changed, 40 insertions(+), 4 deletions(-) | ||
5 | |||
6 | Index: linux-2.6.16-ck1/include/linux/mmzone.h | ||
7 | =================================================================== | ||
8 | --- linux-2.6.16-ck1.orig/include/linux/mmzone.h 2006-03-20 20:46:57.000000000 +1100 | ||
9 | +++ linux-2.6.16-ck1/include/linux/mmzone.h 2006-03-20 20:46:58.000000000 +1100 | ||
10 | @@ -333,7 +333,7 @@ void __get_zone_counts(unsigned long *ac | ||
11 | void get_zone_counts(unsigned long *active, unsigned long *inactive, | ||
12 | unsigned long *free); | ||
13 | void build_all_zonelists(void); | ||
14 | -void wakeup_kswapd(struct zone *zone, int order); | ||
15 | +void wakeup_kswapd(struct zone *zone, int order, struct task_struct *p); | ||
16 | int zone_watermark_ok(struct zone *z, int order, unsigned long mark, | ||
17 | int classzone_idx, int alloc_flags); | ||
18 | |||
19 | Index: linux-2.6.16-ck1/mm/page_alloc.c | ||
20 | =================================================================== | ||
21 | --- linux-2.6.16-ck1.orig/mm/page_alloc.c 2006-03-20 20:46:57.000000000 +1100 | ||
22 | +++ linux-2.6.16-ck1/mm/page_alloc.c 2006-03-20 20:46:58.000000000 +1100 | ||
23 | @@ -926,7 +926,7 @@ restart: | ||
24 | goto got_pg; | ||
25 | |||
26 | do { | ||
27 | - wakeup_kswapd(*z, order); | ||
28 | + wakeup_kswapd(*z, order, p); | ||
29 | } while (*(++z)); | ||
30 | |||
31 | /* | ||
32 | Index: linux-2.6.16-ck1/mm/vmscan.c | ||
33 | =================================================================== | ||
34 | --- linux-2.6.16-ck1.orig/mm/vmscan.c 2006-03-20 20:46:57.000000000 +1100 | ||
35 | +++ linux-2.6.16-ck1/mm/vmscan.c 2006-03-20 20:46:58.000000000 +1100 | ||
36 | @@ -1383,6 +1383,38 @@ shrink_zone(struct zone *zone, struct sc | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | + * Helper functions to adjust nice level of kswapd, based on the priority of | ||
41 | + * the task (p) that called it. If it is already higher priority we do not | ||
42 | + * demote its nice level since it is still working on behalf of a higher | ||
43 | + * priority task. With kernel threads we leave it at nice 0. | ||
44 | + * | ||
45 | + * We don't ever run kswapd real time, so if a real time task calls kswapd we | ||
46 | + * set it to highest SCHED_NORMAL priority. | ||
47 | + */ | ||
48 | +static int effective_sc_prio(struct task_struct *p) | ||
49 | +{ | ||
50 | + if (likely(p->mm)) { | ||
51 | + if (rt_task(p)) | ||
52 | + return -20; | ||
53 | + return task_nice(p); | ||
54 | + } | ||
55 | + return 0; | ||
56 | +} | ||
57 | + | ||
58 | +static void set_kswapd_nice(task_t *kswapd, task_t *p, int active) | ||
59 | +{ | ||
60 | + long nice = effective_sc_prio(p); | ||
61 | + | ||
62 | + if (task_nice(kswapd) > nice || !active) | ||
63 | + set_user_nice(kswapd, nice); | ||
64 | +} | ||
65 | + | ||
66 | +static int sc_priority(struct task_struct *p) | ||
67 | +{ | ||
68 | + return (DEF_PRIORITY + (DEF_PRIORITY * effective_sc_prio(p) / 40)); | ||
69 | +} | ||
70 | + | ||
71 | +/* | ||
72 | * This is the direct reclaim path, for page-allocating processes. We only | ||
73 | * try to reclaim pages from zones which will satisfy the caller's allocation | ||
74 | * request. | ||
75 | @@ -1769,6 +1801,7 @@ static int kswapd(void *p) | ||
76 | */ | ||
77 | order = new_order; | ||
78 | } else { | ||
79 | + set_user_nice(tsk, 0); | ||
80 | schedule(); | ||
81 | order = pgdat->kswapd_max_order; | ||
82 | } | ||
83 | @@ -1782,9 +1815,10 @@ static int kswapd(void *p) | ||
84 | /* | ||
85 | * A zone is low on free memory, so wake its kswapd task to service it. | ||
86 | */ | ||
87 | -void wakeup_kswapd(struct zone *zone, int order) | ||
88 | +void wakeup_kswapd(struct zone *zone, int order, struct task_struct *p) | ||
89 | { | ||
90 | pg_data_t *pgdat; | ||
91 | + int active; | ||
92 | |||
93 | if (!populated_zone(zone)) | ||
94 | return; | ||
95 | @@ -1796,7 +1830,9 @@ void wakeup_kswapd(struct zone *zone, in | ||
96 | pgdat->kswapd_max_order = order; | ||
97 | if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) | ||
98 | return; | ||
99 | - if (!waitqueue_active(&pgdat->kswapd_wait)) | ||
100 | + active = waitqueue_active(&pgdat->kswapd_wait); | ||
101 | + set_kswapd_nice(pgdat->kswapd, p, active); | ||
102 | + if (!active) | ||
103 | return; | ||
104 | wake_up_interruptible(&pgdat->kswapd_wait); | ||
105 | } |