Subject: Re: vm_map.{min,max}_offset
To: Bang Jun-Young <junyoung@NetBSD.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 04/27/2004 09:04:11
>Could anybody shed a light why the following two defines, min_offset and 
>max_offset are reversed?
>
>struct vm_map {
>...
>	struct vm_map_entry	header;		/* List of entries */
>...
>#define	min_offset		header.end
>#define	max_offset		header.start
>};
>
>Shouldn't min_offset be smaller than max_offset like
>
>#define	min_offset		header.start
>#define	max_offset		header.end
>
>? In uvmspace_exec() in uvm_map.c those are initialized as
>
>		...
>		map->min_offset = start;
>		map->max_offset = end;
>		...

iirc...

so that the header entry can appear to be at or below the first entry
(since it also "starts" at zero) and at the same time, at or above the
last entry (since it also "ends" at the top).  this requires that the
start and end in the header be upside-down.

for example, the lines marked "H" are the vm_map.header entry and the
lines marked "E" are the regular map entries.

    H    start = bfc00000, end = 0, object.uvm_obj/sub_map = 0x0,
    E    start = 8048000, end = 808b000, object.uvm_obj/sub_map = 0xc5f8a860,
    E    start = 808b000, end = 808f000, object.uvm_obj/sub_map = 0xc5f8a860,
    ...
    E    start = bfbe0000, end = bfbf0000, object.uvm_obj/sub_map = 0x0,
    E    start = bfbf0000, end = bfc00000, object.uvm_obj/sub_map = 0x0,
    H    start = bfc00000, end = 0, object.uvm_obj/sub_map = 0x0,

i duplicated the H line so you can see how it seems to fit at both
ends and for all possible values of "e" (either "H" or "E") the
constraint:

	(e->end <= e->next->start) && (e->start >= e->prev->end)

is valid.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."