Here is some cleanup of uvm_map.c code.
At first, in uvm_map_advice() function.
Let it looks as simple as uvm_map_inherit() - no need to lock/unlock map
just to realize that sanity check fail. Also no need to do it in every loop.
Second, remove redundant "temp_entry" variable from both functions.
One "entry" variable is enough to do the job.
$ cvs diff -Nup sys/uvm/uvm_map.c
opencvs server: ignoring unknown option 'LockDir'
Index: sys/uvm/uvm_map.c
===================================================================
RCS file: /AerieBSD/src/sys/uvm/uvm_map.c,v
retrieving revision 1.3
diff -N -u -p sys/uvm/uvm_map.c
--- sys/uvm/uvm_map.c 6 Jun 2009 15:06:18 -0000 1.3
+++ sys/uvm/uvm_map.c 31 Jan 2010 12:47:12 -0000
@@ -2325,7 +2325,7 @@ int
uvm_map_inherit(struct vm_map *map, vaddr_t start, vaddr_t end,
vm_inherit_t new_inheritance)
{
- struct vm_map_entry *entry, *temp_entry;
+ struct vm_map_entry *entry;
UVMHIST_FUNC("uvm_map_inherit"); UVMHIST_CALLED(maphist);
UVMHIST_LOG(maphist,"(map=%p,start=0x%lx,end=0x%lx,new_inh=0x%lx)",
map, start, end, new_inheritance);
@@ -2344,11 +2344,10 @@ uvm_map_inherit(struct vm_map *map, vaddr_t start, vad
VM_MAP_RANGE_CHECK(map, start, end);
- if (uvm_map_lookup_entry(map, start, &temp_entry)) {
- entry = temp_entry;
+ if (uvm_map_lookup_entry(map, start, &entry)) {
UVM_MAP_CLIP_START(map, entry, start);
} else {
- entry = temp_entry->next;
+ entry = entry->next;
}
while ((entry != &map->header) && (entry->start < end)) {
@@ -2371,18 +2370,29 @@ uvm_map_inherit(struct vm_map *map, vaddr_t start, vad
int
uvm_map_advice(struct vm_map *map, vaddr_t start, vaddr_t end, int new_advice)
{
- struct vm_map_entry *entry, *temp_entry;
+ struct vm_map_entry *entry;
UVMHIST_FUNC("uvm_map_advice"); UVMHIST_CALLED(maphist);
UVMHIST_LOG(maphist,"(map=%p,start=0x%lx,end=0x%lx,new_adv=0x%lx)",
map, start, end, new_advice);
+ switch (new_advice) {
+ case MADV_NORMAL:
+ case MADV_RANDOM:
+ case MADV_SEQUENTIAL:
+ /* nothing special here */
+ break;
+
+ default:
+ UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
+ return (EINVAL);
+ }
+
vm_map_lock(map);
VM_MAP_RANGE_CHECK(map, start, end);
- if (uvm_map_lookup_entry(map, start, &temp_entry)) {
- entry = temp_entry;
+ if (uvm_map_lookup_entry(map, start, &entry)) {
UVM_MAP_CLIP_START(map, entry, start);
} else {
- entry = temp_entry->next;
+ entry = entry->next;
}
/*
@@ -2391,19 +2401,6 @@ uvm_map_advice(struct vm_map *map, vaddr_t start, vadd
while ((entry != &map->header) && (entry->start < end)) {
UVM_MAP_CLIP_END(map, entry, end);
-
- switch (new_advice) {
- case MADV_NORMAL:
- case MADV_RANDOM:
- case MADV_SEQUENTIAL:
- /* nothing special here */
- break;
-
- default:
- vm_map_unlock(map);
- UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
- return (EINVAL);
- }
entry->advice = new_advice;
entry = entry->next;
}
--
antonvm