* Minipatch to free SKBs on OOM
@ 2002-06-01 0:13 Dan Kegel
0 siblings, 0 replies; only message in thread
From: Dan Kegel @ 2002-06-01 0:13 UTC (permalink / raw)
To: linux-kernel; +Cc: dank
A coworker was running into OOM problems when doing heavy
networking, and came up with the following patch. He says
it's the smallest subset of the existing mm patches that
solves his problem.
Can someone who knows the mm code comment on the quality
and safety of this patch?
This is against vanilla 2.4.19-pre9.
Thanks,
Dan
--- linux/mm/page_alloc.c.orig Fri May 31 16:04:21 2002
+++ linux/mm/page_alloc.c Fri May 31 16:38:28 2002
@@ -414,8 +414,13 @@
struct page * page;
page = alloc_pages(gfp_mask, order);
- if (!page)
- return 0;
+ if (!page) {
+ refill_inactive(1 << order);
+ (void) kmem_cache_reap(gfp_mask);
+ page = alloc_pages(gfp_mask, order);
+ if (!page)
+ return 0;
+ }
return (unsigned long) page_address(page);
}
--- linux/mm/vmscan.c.orig Fri May 31 16:04:21 2002
+++ linux/mm/vmscan.c Fri May 31 16:41:11 2002
@@ -531,7 +531,7 @@
* We move them the other way when we see the
* reference bit on the page.
*/
-static void refill_inactive(int nr_pages)
+void refill_inactive(int nr_pages)
{
struct list_head * entry;
@@ -597,6 +597,10 @@
return 1;
} while (--priority);
+ refill_inactive(nr_pages);
+ if (kmem_cache_reap(gfp_mask))
+ return 1;
+
/*
* Hmm.. Cache shrink failed - time to kill something?
* Mhwahahhaha! This is the part I really like. Giggle.
--- linux/include/linux/swap.h.orig Fri May 31 16:22:01 2002
+++ linux/include/linux/swap.h Fri May 31 16:32:57 2002
@@ -112,6 +112,7 @@
/* linux/mm/vmscan.c */
extern wait_queue_head_t kswapd_wait;
extern int FASTCALL(try_to_free_pages(zone_t *, unsigned int, unsigned int));
+extern void refill_inactive(int nr_pages);
/* linux/mm/page_io.c */
extern void rw_swap_page(int, struct page *);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-06-01 0:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-01 0:13 Minipatch to free SKBs on OOM Dan Kegel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®