patch-2.4.1 linux/mm/page_alloc.c
Next file: linux/mm/shmem.c
Previous file: linux/mm/mmap.c
Back to the patch index
Back to the overall index
- Lines: 97
- Date:
Mon Jan 15 12:35:12 2001
- Orig file:
v2.4.0/linux/mm/page_alloc.c
- Orig date:
Wed Jan 3 09:59:06 2001
diff -u --recursive --new-file v2.4.0/linux/mm/page_alloc.c linux/mm/page_alloc.c
@@ -16,6 +16,7 @@
#include <linux/interrupt.h>
#include <linux/pagemap.h>
#include <linux/bootmem.h>
+#include <linux/slab.h>
int nr_swap_pages;
int nr_active_pages;
@@ -303,7 +304,7 @@
* an inactive page shortage, wake up kswapd.
*/
if (inactive_shortage() > inactive_target / 2 && free_shortage())
- wakeup_kswapd(0);
+ wakeup_kswapd();
/*
* If we are about to get low on free pages and cleaning
* the inactive_dirty pages would fix the situation,
@@ -379,7 +380,7 @@
* - if we don't have __GFP_IO set, kswapd may be
* able to free some memory we can't free ourselves
*/
- wakeup_kswapd(0);
+ wakeup_kswapd();
if (gfp_mask & __GFP_WAIT) {
__set_current_state(TASK_RUNNING);
current->policy |= SCHED_YIELD;
@@ -404,7 +405,7 @@
* - we're doing a higher-order allocation
* --> move pages to the free list until we succeed
* - we're /really/ tight on memory
- * --> wait on the kswapd waitqueue until memory is freed
+ * --> try to free pages ourselves with page_launder
*/
if (!(current->flags & PF_MEMALLOC)) {
/*
@@ -443,36 +444,20 @@
/*
* When we arrive here, we are really tight on memory.
*
- * We wake up kswapd and sleep until kswapd wakes us
- * up again. After that we loop back to the start.
- *
- * We have to do this because something else might eat
- * the memory kswapd frees for us and we need to be
- * reliable. Note that we don't loop back for higher
- * order allocations since it is possible that kswapd
- * simply cannot free a large enough contiguous area
- * of memory *ever*.
+ * We try to free pages ourselves by:
+ * - shrinking the i/d caches.
+ * - reclaiming unused memory from the slab caches.
+ * - swapping/syncing pages to disk (done by page_launder)
+ * - moving clean pages from the inactive dirty list to
+ * the inactive clean list. (done by page_launder)
*/
- if ((gfp_mask & (__GFP_WAIT|__GFP_IO)) == (__GFP_WAIT|__GFP_IO)) {
- wakeup_kswapd(1);
+ if (gfp_mask & __GFP_WAIT) {
memory_pressure++;
- if (!order)
- goto try_again;
- /*
- * If __GFP_IO isn't set, we can't wait on kswapd because
- * kswapd just might need some IO locks /we/ are holding ...
- *
- * SUBTLE: The scheduling point above makes sure that
- * kswapd does get the chance to free memory we can't
- * free ourselves...
- */
- } else if (gfp_mask & __GFP_WAIT) {
try_to_free_pages(gfp_mask);
- memory_pressure++;
+ wakeup_bdflush(0);
if (!order)
goto try_again;
}
-
}
/*
@@ -554,14 +539,8 @@
void free_pages(unsigned long addr, unsigned long order)
{
- struct page *fpage;
-
-#ifdef CONFIG_DISCONTIGMEM
- if (addr == 0) return;
-#endif
- fpage = virt_to_page(addr);
- if (VALID_PAGE(fpage))
- __free_pages(fpage, order);
+ if (addr != 0)
+ __free_pages(virt_to_page(addr), order);
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)