Re: [patch] my latest oom stuff

Andrea Arcangeli (andrea@e-mind.com)
Tue, 27 Oct 1998 18:33:08 +0100 (CET)


On Tue, 27 Oct 1998, Andrea Arcangeli wrote:

>This patch is against clean pre-2.1.127-2 and includes also the new
>kswapd.

If I change __get_free_pages this way (incremental patch against the last
one) I can stress very better the memory. At the time one of the process
get a segfault the free memory is down to 20kbyte against the ~1mbyte of
the other (more similar to the stock kernel) __get_free_pages()
implementation.

Index: mm/page_alloc.c
===================================================================
RCS file: /var/cvs/linux/mm/page_alloc.c,v
retrieving revision 1.1.1.1.18.10
diff -u -r1.1.1.1.18.10 page_alloc.c
--- page_alloc.c 1998/10/27 15:53:45 1.1.1.1.18.10
+++ page_alloc.c 1998/10/27 17:25:53
@@ -239,37 +239,32 @@
unsigned long __get_free_pages(int gfp_mask, unsigned long order)
{
unsigned long flags;
+ int again = 0, wait = gfp_mask & __GFP_WAIT;

if (order >= NR_MEM_LISTS)
goto nopage;

- if (gfp_mask & __GFP_WAIT) {
- if (in_interrupt()) {
- static int count = 0;
- if (++count < 5) {
- printk("gfp called nonatomically from interrupt %p\n",
- __builtin_return_address(0));
- }
- goto nopage;
+ if (wait && in_interrupt()) {
+ static int count = 0;
+ if (++count < 5) {
+ printk("gfp called nonatomically from interrupt %p\n",
+ __builtin_return_address(0));
}
-
- if (freepages.min > nr_free_pages) {
- int freed;
- freed = try_to_free_pages(gfp_mask, SWAP_CLUSTER_MAX);
- /*
- * Low priority (user) allocations must not
- * succeed if we didn't have enough memory
- * and we couldn't get more..
- */
- if (!freed && !(gfp_mask & (__GFP_MED | __GFP_HIGH)
- && nr_swap_pages))
- goto nopage;
- }
+ goto nopage;
}
+
+ again:
spin_lock_irqsave(&page_alloc_lock, flags);
RMQUEUE(order, (gfp_mask & GFP_DMA));
spin_unlock_irqrestore(&page_alloc_lock, flags);

+ if (wait && !again)
+ {
+ again = 1;
+ if (try_to_free_pages(gfp_mask, SWAP_CLUSTER_MAX) ||
+ (gfp_mask & (__GFP_MED | __GFP_HIGH) && nr_swap_pages))
+ goto again;
+ }
#if 0
/*
* If we failed to find anything, we'll return NULL, but we'll

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/