mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Phillips <phillips@bonn-fries.net>
To: Alex Bligh - linux-kernel <linux-kernel@alex.org.uk>,
	Roger Larsson <roger.larsson@skelleftea.mail.telia.com>,
	Stephan von Krawczynski <skraw@ithnet.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: Rik van Riel <riel@conectiva.com.br>,
	Marcelo Tosatti <marcelo@conectiva.com.br>,
	Alex Bligh - linux-kernel <linux-kernel@alex.org.uk>
Subject: Re: Memory Problem in 2.4.10-pre2 / __alloc_pages failed
Date: Sun, 2 Sep 2001 22:24:42 +0200	[thread overview]
Message-ID: <20010902201748Z16294-32383+3038@humbolt.nl.linux.org> (raw)
In-Reply-To: <20010902181905Z16091-32383+3020@humbolt.nl.linux.org> <1034195335.999462755@[169.254.198.40]>
In-Reply-To: <1034195335.999462755@[169.254.198.40]>

On September 2, 2001 09:32 pm, Alex Bligh - linux-kernel wrote:
> IDEA: Attempt not to allocate sets of pages buddied with 'nearly
> free' sets of pages.
> 
> When freeing pages, we work our way up the orders until
> we find a buddy which is non-empty. Let's assume that
> the free area, and our (non-empty) buddy, are of order N.
> Let's look at whether at order N-1, it's merely half full,
> or completely full. If completely full, we guess that
> the buddy is unlikely to become free soon, and thus
> add our area to the front of the memory queue (mem_add_head)
> else we guess it's more likely to have its buddy freed
> and add it to the back of the memory queue (mem_add_tail).
> 
> /Completely/ untested (i.e. uncompiled) patch attached

Rediffed to 2.4.9, whitespace and wrapping problems fixed, and compiled
but not tested.  Now we just need a victi^H^H^H^H^H volunteer to try it...
(Stephan?)

--- ../2.4.9.clean/mm/page_alloc.c	Thu Aug 16 12:43:02 2001
+++ ./mm/page_alloc.c	Sun Sep  2 21:09:05 2001
@@ -69,6 +69,8 @@
 	struct page *base;
 	zone_t *zone;
 
+       int addfront=1;
+
 	if (page->buffers)
 		BUG();
 	if (page->mapping)
@@ -112,10 +114,22 @@
 		if (area >= zone->free_area + MAX_ORDER)
 			BUG();
 		if (!__test_and_change_bit(index, area->map))
-			/*
-			 * the buddy page is still allocated.
-			 */
-			break;
+                 {
+                   /*
+                    * the buddy page is still allocated.
+                    *
+                    * see how many bits are set in its bitmap;
+                    * if 50% or more, we conclude the buddy is
+                    * unlikely to be freed soon, and add the
+                    * area to the head of the queue; else we
+                    * conclude the buddy may be free soon and
+                    * add it to the head.
+                    */
+                   if (mask & 1) /* not order 0 merge */
+                     addfront = ( !test_bit((index^1)<<1, (area-1)->map)
+                                  && !test_bit((index^1)<<1, (area-1)->map) );
+                   break;
+                 }
 		/*
 		 * Move the buddy up one level.
 		 */
@@ -132,7 +146,11 @@
 		index >>= 1;
 		page_idx &= mask;
 	}
-	memlist_add_head(&(base + page_idx)->list, &area->free_list);
+
+       if (addfront)
+         memlist_add_head(&(base + page_idx)->list, &area->free_list);
+       else
+         memlist_add_tail(&(base + page_idx)->list, &area->free_list);
 
 	spin_unlock_irqrestore(&zone->lock, flags);
 

  reply	other threads:[~2001-09-02 20:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-01 18:28 Stephan von Krawczynski
2001-09-02  1:57 ` Daniel Phillips
2001-09-02  2:21   ` Roger Larsson
2001-09-02  4:16     ` Daniel Phillips
2001-09-02 13:48     ` Alex Bligh - linux-kernel
2001-09-02 18:26       ` Daniel Phillips
2001-09-02 19:32         ` Alex Bligh - linux-kernel
2001-09-02 20:24           ` Daniel Phillips [this message]
2001-09-02 21:03             ` Alex Bligh - linux-kernel
2001-09-02 20:33           ` Daniel Phillips
2001-09-02 21:14             ` Alex Bligh - linux-kernel
2001-09-02 21:23           ` Daniel Phillips
2001-09-02 21:28             ` Alex Bligh - linux-kernel
2001-09-02 22:36               ` High order memory allocations (was Re: Memory Problem in 2.4.10-pre2 / __alloc_pages failed) Alex Bligh - linux-kernel
     [not found] <689208719.999883299@[10.132.112.53]>
     [not found] ` <20010907154801.028a48e8.skraw@ithnet.com>
2001-09-07 21:13   ` Memory Problem in 2.4.10-pre2 / __alloc_pages failed Stephan von Krawczynski
     [not found] <Pine.LNX.4.33.0109011021570.280-100000@mikeg.weiden.de>
     [not found] ` <20010901055634Z16057-32383+2785@humbolt.nl.linux.org>
2001-09-01 18:54   ` Stephan von Krawczynski
2001-09-02  3:21     ` Mike Galbraith
  -- strict thread matches above, loose matches on Subject: below --
2001-08-29 12:07 Stephan von Krawczynski
2001-08-29 16:47 ` Roger Larsson
2001-08-29 19:18 ` Stephan von Krawczynski
2001-08-30 14:16   ` Stephan von Krawczynski
2001-08-29 23:36 ` Daniel Phillips
2001-08-30 16:49   ` Roger Larsson
2001-08-30 14:46 ` Stephan von Krawczynski
2001-08-30 18:02   ` Daniel Phillips
2001-08-31 10:32   ` Stephan von Krawczynski
2001-08-31 11:06 ` Stephan von Krawczynski
2001-08-31 19:03   ` Daniel Phillips

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=20010902201748Z16294-32383+3038@humbolt.nl.linux.org \
    --to=phillips@bonn-fries.net \
    --cc=linux-kernel@alex.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=riel@conectiva.com.br \
    --cc=roger.larsson@skelleftea.mail.telia.com \
    --cc=skraw@ithnet.com \
    /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®