2010/2/1 Bob Beck <[email protected]>:
> On 31 January 2010 05:43, Anton Maksimenkov <[email protected]> wrote:
>> Second, remove redundant "temp_entry" variable from both functions.
>> One "entry" variable is enough to do the job.
> I don't think you want to do that.. uvm_map_lookup_entry can screw
> with that pointer even when it fails.
Sorry, I don't clearly understand what you mean. What is bad?
I think that "screw with that pointer even when it fails" is exactly
what uvm_map_lookup_entry must do and what we need here.
uvm_map_protect() exploit exactly same trick. And uvm_map_extract() do the same:
...
if (uvm_map_lookup_entry(srcmap, start, &entry)) {
...do some work with entry...
} else {
/* "start" is not within an entry ... skip to next entry */
if (flags & UVM_EXTRACT_CONTIG) {
error = EINVAL;
goto bad; /* definite hole here ... */
}
entry = entry->next;
fudge = 0;
}
AFAIS, uvm_map_lookup_entry() set the "entry" either to the
vm_map_entry which contain "start" address (success)
or to the last vm_map_entry in the map (fail).
If it fail and set "entry" to the last vm_map_entry then "entry =
entry->next" move entry to the map->header.
So loop with
while ((entry != &map->header) && (entry->start < end)) {
will never be executed (it is right thing).
Overcomplicated using of RB_TREE in uvm_map_lookup_entry() making it
hard to understand.
I thinking about drop this RB_TREE out from uvm_map.c or completely
rewrite using of this RB_TREE.
--
antonvm