mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Kegel <dank@kegel.com>
To: linux-kernel@vger.kernel.org
Cc: dank@alumni.caltech.edu
Subject: Minipatch to free SKBs on OOM
Date: Fri, 31 May 2002 17:13:43 -0700	[thread overview]
Message-ID: <200206010013.g510Dhi20565@kegel.com> (raw)

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 *);

                 reply	other threads:[~2002-06-01  0:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200206010013.g510Dhi20565@kegel.com \
    --to=dank@kegel.com \
    --cc=dank@alumni.caltech.edu \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®