Magellan Linux

Annotation of /trunk/kernel26-magellan/patches-2.6.16-r10/0022-2.6.16-mm-background_scan.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (hide annotations) (download)
Thu May 11 19:09:22 2006 UTC (18 years ago) by niro
File size: 3581 byte(s)
import

1 niro 70 Add a background scanning timer to restore the watermarks to the pages_lots
2     level and only call on it if kswapd has not been called upon for the last 5
3     seconds. This allows us to balance all zones to the more generous pages_lots
4     watermark at a time unrelated to page allocation thus leading to lighter
5     levels of vm load when called upon under page allocation.
6    
7     Signed-off-by: Con Kolivas <kernel@kolivas.org>
8    
9     include/linux/mmzone.h | 2 ++
10     mm/vmscan.c | 42 +++++++++++++++++++++++++++++++++++++++++-
11     2 files changed, 43 insertions(+), 1 deletion(-)
12    
13     Index: linux-2.6.16-ck1/include/linux/mmzone.h
14     ===================================================================
15     --- linux-2.6.16-ck1.orig/include/linux/mmzone.h 2006-03-20 20:46:57.000000000 +1100
16     +++ linux-2.6.16-ck1/include/linux/mmzone.h 2006-03-20 20:46:57.000000000 +1100
17     @@ -13,6 +13,7 @@
18     #include <linux/numa.h>
19     #include <linux/init.h>
20     #include <linux/seqlock.h>
21     +#include <linux/timer.h>
22     #include <asm/atomic.h>
23    
24     /* Free memory management - zoned buddy allocator. */
25     @@ -311,6 +312,7 @@ typedef struct pglist_data {
26     wait_queue_head_t kswapd_wait;
27     struct task_struct *kswapd;
28     int kswapd_max_order;
29     + struct timer_list watermark_timer;
30     } pg_data_t;
31    
32     #define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
33     Index: linux-2.6.16-ck1/mm/vmscan.c
34     ===================================================================
35     --- linux-2.6.16-ck1.orig/mm/vmscan.c 2006-03-20 20:46:57.000000000 +1100
36     +++ linux-2.6.16-ck1/mm/vmscan.c 2006-03-20 20:46:57.000000000 +1100
37     @@ -34,6 +34,7 @@
38     #include <linux/cpuset.h>
39     #include <linux/notifier.h>
40     #include <linux/rwsem.h>
41     +#include <linux/timer.h>
42    
43     #include <asm/tlbflush.h>
44     #include <asm/div64.h>
45     @@ -1704,6 +1705,8 @@ out:
46     return total_reclaimed;
47     }
48    
49     +#define WT_EXPIRY (HZ * 5) /* Time to wakeup watermark_timer */
50     +
51     /*
52     * The background pageout daemon, started as a kernel thread
53     * from the init process.
54     @@ -1754,6 +1757,8 @@ static int kswapd(void *p)
55    
56     try_to_freeze();
57    
58     + /* kswapd has been busy so delay watermark_timer */
59     + mod_timer(&pgdat->watermark_timer, jiffies + WT_EXPIRY);
60     prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
61     new_order = pgdat->kswapd_max_order;
62     pgdat->kswapd_max_order = 0;
63     @@ -1850,13 +1855,48 @@ static int __devinit cpu_callback(struct
64     }
65     #endif /* CONFIG_HOTPLUG_CPU */
66    
67     +/*
68     + * We wake up kswapd every WT_EXPIRY till free ram is above pages_lots
69     + */
70     +static void watermark_wakeup(unsigned long data)
71     +{
72     + pg_data_t *pgdat = (pg_data_t *)data;
73     + struct timer_list *wt = &pgdat->watermark_timer;
74     + int i;
75     +
76     + if (!waitqueue_active(&pgdat->kswapd_wait))
77     + goto out;
78     + for (i = pgdat->nr_zones - 1; i >= 0; i--) {
79     + struct zone *z = pgdat->node_zones + i;
80     +
81     + if (!populated_zone(z) || is_highmem(z)) {
82     + /* We are better off leaving highmem full */
83     + continue;
84     + }
85     + if (!zone_watermark_ok(z, 0, z->pages_lots, 0, 0)) {
86     + wake_up_interruptible(&pgdat->kswapd_wait);
87     + goto out;
88     + }
89     + }
90     +out:
91     + mod_timer(wt, jiffies + WT_EXPIRY);
92     + return;
93     +}
94     +
95     static int __init kswapd_init(void)
96     {
97     pg_data_t *pgdat;
98     swap_setup();
99     - for_each_pgdat(pgdat)
100     + for_each_pgdat(pgdat) {
101     + struct timer_list *wt = &pgdat->watermark_timer;
102     pgdat->kswapd
103     = find_task_by_pid(kernel_thread(kswapd, pgdat, CLONE_KERNEL));
104     + init_timer(wt);
105     + wt->data = (unsigned long)pgdat;
106     + wt->function = watermark_wakeup;
107     + wt->expires = jiffies + WT_EXPIRY;
108     + add_timer(wt);
109     + }
110     total_memory = nr_free_pagecache_pages();
111     hotcpu_notifier(cpu_callback, 0);
112     return 0;