Subject: kern/7539: extent_alloc_subregion() doesn't
To: None <gnats-bugs@gnats.netbsd.org>
From: Lennart Augustsson <augustss@augustsson.net>
List: netbsd-bugs
Date: 05/09/1999 08:36:27
>Number: 7539
>Category: kern
>Synopsis: extent_alloc_subregion() doesn't
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 9 08:35:00 1999
>Last-Modified:
>Originator: Lennart Augustsson
>Organization:
>Release: NetBSD-current 1999-05-09
>Environment:
System: NetBSD opus 1.4B NetBSD 1.4B (OPUS) #0: Sun May 9 16:53:38 CEST 1999 augustss@opus:/extra/NetBSD/src/sys/arch/i386/compile/OPUS i386
>Description:
The extent_alloc_subregion() function is supposed to allocate
an extent within the given substart-subend interval (if I
understand right). But sometimes it doesn't. If the interval
is above the last previous allocation it will allocate
below substart.
>How-To-Repeat:
Try it as described above.
>Fix:
Well, just removing the code that moves the start location
down seems to work for me. But since this piece of code
even has a comment describing what it does I don't dare make
the change. I simply don't understand why it was there in
the first place, but it seems deliberate.
I'll let the original author of the code figure it out.
Furthermore, I've added a DIAGNOSTIC message if the allocation
is outside the bounds.
*** subr_extent.c Thu Feb 18 19:57:41 1999
--- /users/augustss/subr_extent.c Sun May 9 17:22:00 1999
***************
*** 603,616 ****
last = rp;
}
- /*
- * If there are no allocated regions beyond where we want to be,
- * relocate the start of our candidate region to the end of
- * the last allocated region (if there was one).
- */
- if (rp == NULL && last != NULL)
- newstart = EXTENT_ALIGN((last->er_end + 1), alignment, skew);
-
for (; rp != NULL; rp = rp->er_link.le_next) {
/*
* Check the chunk before "rp". Note that our
--- 603,608 ----
***************
*** 817,822 ****
--- 809,819 ----
return (EAGAIN);
found:
+ #ifdef DIAGNOSTIC
+ if (newstart < substart || newstart + size > subend) {
+ printf("extent_alloc_subregion: substart=%lx subend=%lx newstart=%lx\n", substart, subend, newstart);
+ }
+ #endif
/*
* Insert ourselves into the region list.
*/
>Audit-Trail:
>Unformatted: