Minipatch to free SKBs on OOM
Subsystems (5)
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
mm/page_alloc.c renamed from mm/page_alloc.c.orig +7 -2
@@ -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); }
mm/vmscan.c renamed from mm/vmscan.c.orig +5 -1
@@ -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.
include/linux/swap.h renamed from include/linux/swap.h.orig +1 -0
@@ -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 *);