All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [RFC] tree-based bootmem
Date: Wed, 21 Nov 2001 08:20:45 -0800	[thread overview]
Message-ID: <20011121082045.A17332@holomorphy.com> (raw)
In-Reply-To: <20011117011415.B1180@holomorphy.com>
In-Reply-To: <20011117011415.B1180@holomorphy.com>; from wli@holomorphy.com on Sat, Nov 17, 2001 at 01:14:15AM -0800

On Sat, Nov 17, 2001 at 01:14:15AM -0800, William Lee Irwin III wrote:
> This is a repost including some corrections of a bootmem allocator that
> tracks ranges explicitly, and uses segment trees to assist in searching
> for available memory. Perhaps it is even a new version. Some prior
> reports indicated mail headers were munged, preventing replies and some
> people from seeing it at all.

Some more corrections are needed, and many thanks to Russell King for
assisting me in finding them, and for providing access to a system in
order to debug these issues.

(1) prevent integer overflow in FEASIBLE()
(2) prevent integer overflow in ENDS_ABOVE()
(3) test for !segment_contains_point(optimum, goal)
	in __alloc_bootmem_core() as an additional condition under
	which the the goal should be discounted as a possible starting
	address for the returned interval. The symptom seen without
	the test is an interval that wraps around ULONG_MAX


This patch tested on ARM.


Cheers,
Bill


--- linux/mm/bootmem.c	Sun Nov 18 23:42:26 2001
+++ linux-arm/mm/bootmem.c	Wed Nov 21 07:58:25 2001
@@ -462,14 +440,18 @@
  * that is not sufficient because of alignment constraints.
  */
 
-#define FEASIBLE(seg, len, align) \
-	((RND_UP(segment_start(seg), align) + (len) - 1) <= segment_end(seg))
+#define FEASIBLE(seg, len, align)					\
+(									\
+	(segment_end(seg) >= RND_UP(segment_start(seg), align))		\
+		&&							\
+	((segment_end(seg) - RND_UP(segment_start(seg), align)) > (len))\
+)
 
 #define STARTS_BELOW(seg,goal,align,len) \
 	(RND_UP(segment_start(seg), align) <= (goal))
 
 #define ENDS_ABOVE(seg, goal, align, len) \
-	(segment_end(seg) > ((goal) + (len)))
+	((segment_end(seg) > (goal)) && ((segment_end(seg) - (goal)) > (len)))
 
 #define GOAL_WITHIN(seg,goal,align,len) \
 	(STARTS_BELOW(seg,goal,align,len) && ENDS_ABOVE(seg,goal,align,len))
@@ -635,7 +608,9 @@
 
 	segment_set_endpoints(&reserved, goal, goal + length - 1);
 
-	if(!segment_contains(optimum, &reserved))
+	if(!segment_contains_point(optimum, goal)
+		|| !segment_contains(optimum, &reserved))
+
 		segment_set_endpoints(&reserved,
 				RND_UP(segment_start(optimum), align),
 				RND_UP(segment_start(optimum),align)+length-1);

  parent reply	other threads:[~2001-11-21 16:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-17  9:14 [RFC] tree-based bootmem William Lee Irwin III
     [not found] ` <20011118001657.A467@ucw.cz>
2001-11-18  0:01   ` William Lee Irwin III
2001-11-19  8:08     ` Robert Love
2001-11-26 21:02       ` Martin Mares
2001-11-21 16:20 ` William Lee Irwin III [this message]
2001-11-23  9:30 ` William Lee Irwin III
2001-11-28  9:04 ` Chris Wright
2001-11-28 12:40   ` William Lee Irwin III
2001-11-29  0:33     ` Chris Wright
2001-11-29  1:23   ` William Lee Irwin III
2001-11-30  2:29     ` Robert Love
2001-12-02  6:59       ` William Lee Irwin III
2001-12-02  7:08         ` Anton Blanchard
     [not found] <20011118005819.3762.qmail@science.horizon.com>
2001-11-18  1:24 ` William Lee Irwin III
  -- strict thread matches above, loose matches on Subject: below --
2001-11-27  6:38 William Lee Irwin III

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=20011121082045.A17332@holomorphy.com \
    --to=wli@holomorphy.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.