Magellan Linux

Annotation of /trunk/kernel26-magellan/patches-2.6.21-r4/0014-2.6.21-mm-kswapd_inherit_prio-1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 222 - (hide annotations) (download)
Tue Jun 12 08:03:28 2007 UTC (16 years, 11 months ago) by niro
File size: 3797 byte(s)
files for 2.6.21-magellan-r4

1 niro 222 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 | 36 ++++++++++++++++++++++++++++++++++--
10     3 files changed, 36 insertions(+), 4 deletions(-)
11    
12     Index: linux-2.6.21-ck2/include/linux/mmzone.h
13     ===================================================================
14     --- linux-2.6.21-ck2.orig/include/linux/mmzone.h 2007-05-14 19:49:55.000000000 +1000
15     +++ linux-2.6.21-ck2/include/linux/mmzone.h 2007-05-14 19:49:55.000000000 +1000
16     @@ -465,7 +465,7 @@ typedef struct pglist_data {
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     enum memmap_context {
25     Index: linux-2.6.21-ck2/mm/page_alloc.c
26     ===================================================================
27     --- linux-2.6.21-ck2.orig/mm/page_alloc.c 2007-05-14 19:49:55.000000000 +1000
28     +++ linux-2.6.21-ck2/mm/page_alloc.c 2007-05-14 19:49:55.000000000 +1000
29     @@ -1277,7 +1277,7 @@ restart:
30     goto nopage;
31    
32     for (z = zonelist->zones; *z; z++)
33     - wakeup_kswapd(*z, order);
34     + wakeup_kswapd(*z, order, p);
35    
36     /*
37     * OK, we're below the kswapd watermark and have kicked background
38     Index: linux-2.6.21-ck2/mm/vmscan.c
39     ===================================================================
40     --- linux-2.6.21-ck2.orig/mm/vmscan.c 2007-05-14 19:49:55.000000000 +1000
41     +++ linux-2.6.21-ck2/mm/vmscan.c 2007-05-14 19:49:55.000000000 +1000
42     @@ -966,6 +966,34 @@ 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(struct task_struct *kswapd, struct task_struct *p,
65     + int active)
66     +{
67     + long nice = effective_sc_prio(p);
68     +
69     + if (task_nice(kswapd) > nice || !active)
70     + set_user_nice(kswapd, nice);
71     +}
72     +
73     +/*
74     * This is the direct reclaim path, for page-allocating processes. We only
75     * try to reclaim pages from zones which will satisfy the caller's allocation
76     * request.
77     @@ -1355,6 +1383,7 @@ static int kswapd(void *p)
78     */
79     order = new_order;
80     } else {
81     + set_user_nice(tsk, 0);
82     schedule();
83     order = pgdat->kswapd_max_order;
84     }
85     @@ -1368,9 +1397,10 @@ static int kswapd(void *p)
86     /*
87     * A zone is low on free memory, so wake its kswapd task to service it.
88     */
89     -void wakeup_kswapd(struct zone *zone, int order)
90     +void wakeup_kswapd(struct zone *zone, int order, struct task_struct *p)
91     {
92     pg_data_t *pgdat;
93     + int active;
94    
95     if (!populated_zone(zone))
96     return;
97     @@ -1382,7 +1412,9 @@ void wakeup_kswapd(struct zone *zone, in
98     pgdat->kswapd_max_order = order;
99     if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
100     return;
101     - if (!waitqueue_active(&pgdat->kswapd_wait))
102     + active = waitqueue_active(&pgdat->kswapd_wait);
103     + set_kswapd_nice(pgdat->kswapd, p, active);
104     + if (!active)
105     return;
106     wake_up_interruptible(&pgdat->kswapd_wait);
107     }