patch-2.2.15 linux/mm/page_alloc.c
Next file: linux/mm/vmscan.c
Previous file: linux/mm/filemap.c
Back to the patch index
Back to the overall index
- Lines: 79
- Date:
Fri Apr 21 12:47:02 2000
- Orig file:
v2.2.14/mm/page_alloc.c
- Orig date:
Tue Jan 4 21:19:03 2000
diff -u --new-file --recursive --exclude-from ../../exclude v2.2.14/mm/page_alloc.c linux/mm/page_alloc.c
@@ -123,7 +123,7 @@
spin_unlock_irqrestore(&page_alloc_lock, flags);
}
-static inline void __free_pages(struct page *page, unsigned long order)
+void __free_pages(struct page *page, unsigned long order)
{
if (!PageReserved(page) && atomic_dec_and_test(&page->count)) {
if (PageSwapCache(page))
@@ -134,11 +134,6 @@
}
}
-void __free_page(struct page *page)
-{
- __free_pages(page, 0);
-}
-
void free_pages(unsigned long addr, unsigned long order)
{
unsigned long map_nr = MAP_NR(addr);
@@ -184,8 +179,6 @@
atomic_set(&map->count, 1); \
} while (0)
-int low_on_memory = 0;
-
unsigned long __get_free_pages(int gfp_mask, unsigned long order)
{
unsigned long flags;
@@ -211,17 +204,24 @@
*/
if (!(current->flags & PF_MEMALLOC)) {
int freed;
+ extern struct wait_queue * kswapd_wait;
- if (nr_free_pages > freepages.min) {
- if (!low_on_memory)
- goto ok_to_allocate;
- if (nr_free_pages >= freepages.high) {
- low_on_memory = 0;
+ if (nr_free_pages >= freepages.high)
+ {
+ /* share RO cachelines in fast path */
+ if (current->trashing_mem)
+ current->trashing_mem = 0;
+ goto ok_to_allocate;
+ }
+ else
+ {
+ if (nr_free_pages < freepages.low)
+ wake_up_interruptible(&kswapd_wait);
+ if (nr_free_pages > freepages.min && !current->trashing_mem)
goto ok_to_allocate;
- }
}
- low_on_memory = 1;
+ current->trashing_mem = 1;
current->flags |= PF_MEMALLOC;
freed = try_to_free_pages(gfp_mask);
current->flags &= ~PF_MEMALLOC;
@@ -236,16 +236,6 @@
RMQUEUE_TYPE(order, 0);
RMQUEUE_TYPE(order, 1);
spin_unlock_irqrestore(&page_alloc_lock, flags);
-
- /*
- * If we can schedule, do so, and make sure to yield.
- * We may be a real-time process, and if kswapd is
- * waiting for us we need to allow it to run a bit.
- */
- if (gfp_mask & __GFP_WAIT) {
- current->policy |= SCHED_YIELD;
- schedule();
- }
nopage:
return 0;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)