summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-07-21 22:00:56 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-07-21 22:00:56 +0000
commit168660f24dfc46c2702acbe4701a446f42a59578 (patch)
treef431368afbf6b1b71809cf3fd904d800ea126f4d /mm
parent6420f767924fa73b0ea267864d96820815f4ba5a (diff)
Merge with Linux 2.4.0-test5-pre3.
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c32
-rw-r--r--mm/vmscan.c29
2 files changed, 28 insertions, 33 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2567aa2df..ae05cf8f8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -217,7 +217,7 @@ static struct page * rmqueue(zone_t *zone, unsigned long order)
*/
struct page * __alloc_pages(zonelist_t *zonelist, unsigned long order)
{
- zone_t **zone = zonelist->zones;
+ zone_t **zone;
extern wait_queue_head_t kswapd_wait;
/*
@@ -228,21 +228,6 @@ struct page * __alloc_pages(zonelist_t *zonelist, unsigned long order)
* in a higher zone fails.
*/
- for (;;) {
- zone_t *z = *(zone++);
- if (!z)
- break;
- if (!z->size)
- BUG();
-
- /* If there are zones with a lot of free memory allocate from them */
- if (z->free_pages > z->pages_high) {
- struct page *page = rmqueue(z, order);
- if (page)
- return page;
- }
- }
-
zone = zonelist->zones;
for (;;) {
zone_t *z = *(zone++);
@@ -264,6 +249,21 @@ struct page * __alloc_pages(zonelist_t *zonelist, unsigned long order)
}
}
+ /* Three possibilities to get here
+ * - Previous alloc_pages resulted in last zone set to have
+ * zone_wake_kswapd and start it. kswapd has not been able
+ * to release enough pages so that one zone does not have
+ * zone_wake_kswapd set.
+ * - Different sets of zones (zonelist)
+ * previous did not have all zones with zone_wake_kswapd but
+ * this one has... should kswapd be woken up? it will run once.
+ * - SMP race, kswapd went to sleep slightly after it as running
+ * in 'if (waitqueue_active(...))' above.
+ * + anyway the test is very cheap to do...
+ */
+ if (waitqueue_active(&kswapd_wait))
+ wake_up_interruptible(&kswapd_wait);
+
/*
* Ok, we don't have any zones that don't need some
* balancing.. See if we have any that aren't critical..
diff --git a/mm/vmscan.c b/mm/vmscan.c
index c43456da6..cbdd0cb7f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -440,7 +440,7 @@ static inline int memory_pressure(void)
}
/*
- * Check if there recently has been memory pressure (zone_wake_kswapd)
+ * Check if all zones have recently had memory_pressure (zone_wake_kswapd)
*/
static inline int keep_kswapd_awake(void)
{
@@ -451,13 +451,13 @@ static inline int keep_kswapd_awake(void)
for(i = 0; i < MAX_NR_ZONES; i++) {
zone_t *zone = pgdat->node_zones+ i;
if (zone->size &&
- zone->zone_wake_kswapd)
- return 1;
+ !zone->zone_wake_kswapd)
+ return 0;
}
pgdat = pgdat->node_next;
} while (pgdat);
- return 0;
+ return 1;
}
/*
@@ -496,9 +496,7 @@ static int do_try_to_free_pages(unsigned int gfp_mask)
goto done;
}
- /* not (been) low on memory - it is
- * pointless to try to swap out.
- */
+ /* check if mission completed */
if (!keep_kswapd_awake())
goto done;
@@ -596,10 +594,7 @@ int kswapd(void *unused)
for (;;) {
if (!keep_kswapd_awake()) {
- /* wake up regulary to do an early attempt too free
- * pages - pages will not actually be freed.
- */
- interruptible_sleep_on_timeout(&kswapd_wait, HZ);
+ interruptible_sleep_on(&kswapd_wait);
}
do_try_to_free_pages(GFP_KSWAPD);
@@ -631,18 +626,18 @@ int try_to_free_pages(unsigned int gfp_mask)
retval = do_try_to_free_pages(gfp_mask);
current->flags &= ~PF_MEMALLOC;
}
- else {
- /* make sure kswapd runs */
- if (waitqueue_active(&kswapd_wait))
- wake_up_interruptible(&kswapd_wait);
- }
+
+ /* someone needed memory that kswapd had not provided
+ * make sure kswapd runs, should not happen often */
+ if (waitqueue_active(&kswapd_wait))
+ wake_up_interruptible(&kswapd_wait);
return retval;
}
static int __init kswapd_init(void)
{
- printk("Starting kswapd v1.6\n");
+ printk("Starting kswapd v1.7\n");
swap_setup();
kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
return 0;