Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161391738
D21882.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D21882.id.diff
View Options
Index: head/sys/compat/linprocfs/linprocfs.c
===================================================================
--- head/sys/compat/linprocfs/linprocfs.c
+++ head/sys/compat/linprocfs/linprocfs.c
@@ -1174,8 +1174,7 @@
l_map_str = l32_map_str;
map = &vm->vm_map;
vm_map_lock_read(map);
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
name = "";
freename = NULL;
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
Index: head/sys/dev/hwpmc/hwpmc_mod.c
===================================================================
--- head/sys/dev/hwpmc/hwpmc_mod.c
+++ head/sys/dev/hwpmc/hwpmc_mod.c
@@ -1884,7 +1884,7 @@
map = &vm->vm_map;
vm_map_lock_read(map);
- for (entry = map->header.next; entry != &map->header; entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
if (entry == NULL) {
PMCDBG2(LOG,OPS,2, "hwpmc: vm_map entry unexpectedly "
@@ -1988,7 +1988,7 @@
* new lookup for this entry. If there is no entry
* for this address range, vm_map_lookup_entry() will
* return the previous one, so we always want to go to
- * entry->next on the next loop iteration.
+ * the next entry on the next loop iteration.
*
* There is an edge condition here that can occur if
* there is no entry at or before this address. In
Index: head/sys/fs/procfs/procfs_map.c
===================================================================
--- head/sys/fs/procfs/procfs_map.c
+++ head/sys/fs/procfs/procfs_map.c
@@ -118,8 +118,7 @@
return (ESRCH);
map = &vm->vm_map;
vm_map_lock_read(map);
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
continue;
Index: head/sys/fs/tmpfs/tmpfs_vfsops.c
===================================================================
--- head/sys/fs/tmpfs/tmpfs_vfsops.c
+++ head/sys/fs/tmpfs/tmpfs_vfsops.c
@@ -262,8 +262,7 @@
vm_map_lock(map);
if (map->busy)
vm_map_wait_busy(map);
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
if ((entry->eflags & (MAP_ENTRY_GUARD |
MAP_ENTRY_IS_SUB_MAP | MAP_ENTRY_COW)) != 0 ||
(entry->max_protection & VM_PROT_WRITE) == 0)
Index: head/sys/kern/imgact_elf.c
===================================================================
--- head/sys/kern/imgact_elf.c
+++ head/sys/kern/imgact_elf.c
@@ -1738,8 +1738,7 @@
boolean_t ignore_entry;
vm_map_lock_read(map);
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
/*
* Don't dump inaccessible mappings, deal with legacy
* coredump mode.
Index: head/sys/kern/kern_proc.c
===================================================================
--- head/sys/kern/kern_proc.c
+++ head/sys/kern/kern_proc.c
@@ -2239,8 +2239,7 @@
map = &vm->vm_map;
vm_map_lock_read(map);
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
vm_object_t obj, tobj, lobj;
vm_offset_t addr;
@@ -2455,8 +2454,7 @@
error = 0;
map = &vm->vm_map;
vm_map_lock_read(map);
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
continue;
Index: head/sys/kern/sys_process.c
===================================================================
--- head/sys/kern/sys_process.c
+++ head/sys/kern/sys_process.c
@@ -382,21 +382,18 @@
vm_map_lock_read(map);
do {
- entry = map->header.next;
+ KASSERT((map->header.eflags & MAP_ENTRY_IS_SUB_MAP) == 0,
+ ("Submap in map header"));
index = 0;
- while (index < pve->pve_entry && entry != &map->header) {
- entry = entry->next;
+ VM_MAP_ENTRY_FOREACH(entry, map) {
+ if (index >= pve->pve_entry &&
+ (entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0)
+ break;
index++;
}
- if (index != pve->pve_entry) {
+ if (index < pve->pve_entry) {
error = EINVAL;
break;
- }
- KASSERT((map->header.eflags & MAP_ENTRY_IS_SUB_MAP) == 0,
- ("Submap in map header"));
- while ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0) {
- entry = entry->next;
- index++;
}
if (entry == &map->header) {
error = ENOENT;
Index: head/sys/security/mac/mac_process.c
===================================================================
--- head/sys/security/mac/mac_process.c
+++ head/sys/security/mac/mac_process.c
@@ -264,7 +264,7 @@
return;
vm_map_lock(map);
- for (vme = map->header.next; vme != &map->header; vme = vme->next) {
+ VM_MAP_ENTRY_FOREACH(vme, map) {
if (vme->eflags & MAP_ENTRY_IS_SUB_MAP) {
mac_proc_vm_revoke_recurse(td, cred,
vme->object.sub_map);
Index: head/sys/vm/swap_pager.c
===================================================================
--- head/sys/vm/swap_pager.c
+++ head/sys/vm/swap_pager.c
@@ -2621,7 +2621,7 @@
map = &vmspace->vm_map;
count = 0;
- for (cur = map->header.next; cur != &map->header; cur = cur->next) {
+ VM_MAP_ENTRY_FOREACH(cur, map) {
if ((cur->eflags & MAP_ENTRY_IS_SUB_MAP) != 0)
continue;
object = cur->object.vm_object;
Index: head/sys/vm/vm_map.h
===================================================================
--- head/sys/vm/vm_map.h
+++ head/sys/vm/vm_map.h
@@ -416,6 +416,10 @@
vm_pindex_t *, vm_prot_t *, boolean_t *);
void vm_map_lookup_done (vm_map_t, vm_map_entry_t);
boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *);
+#define VM_MAP_ENTRY_FOREACH(it, map) \
+ for ((it) = (map)->header.next; \
+ (it) != &(map)->header; \
+ (it) = (it)->next)
int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t);
int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t);
void vm_map_try_merge_entries(vm_map_t map, vm_map_entry_t prev,
Index: head/sys/vm/vm_object.c
===================================================================
--- head/sys/vm/vm_object.c
+++ head/sys/vm/vm_object.c
@@ -2376,29 +2376,22 @@
vm_map_t tmpm;
vm_map_entry_t tmpe;
vm_object_t obj;
- int entcount;
if (map == 0)
return 0;
if (entry == 0) {
- tmpe = map->header.next;
- entcount = map->nentries;
- while (entcount-- && (tmpe != &map->header)) {
+ VM_MAP_ENTRY_FOREACH(tmpe, map) {
if (_vm_object_in_map(map, object, tmpe)) {
return 1;
}
- tmpe = tmpe->next;
}
} else if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) {
tmpm = entry->object.sub_map;
- tmpe = tmpm->header.next;
- entcount = tmpm->nentries;
- while (entcount-- && tmpe != &tmpm->header) {
+ VM_MAP_ENTRY_FOREACH(tmpe, tmpm) {
if (_vm_object_in_map(tmpm, object, tmpe)) {
return 1;
}
- tmpe = tmpe->next;
}
} else if ((obj = entry->object.vm_object) != NULL) {
for (; obj; obj = obj->backing_object)
Index: head/sys/vm/vm_pageout.c
===================================================================
--- head/sys/vm/vm_pageout.c
+++ head/sys/vm/vm_pageout.c
@@ -1783,8 +1783,7 @@
KASSERT(!map->system_map, ("system map"));
sx_assert(&map->lock, SA_LOCKED);
res = 0;
- for (entry = map->header.next; entry != &map->header;
- entry = entry->next) {
+ VM_MAP_ENTRY_FOREACH(entry, map) {
if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0)
continue;
obj = entry->object.vm_object;
Index: head/sys/vm/vm_swapout.c
===================================================================
--- head/sys/vm/vm_swapout.c
+++ head/sys/vm/vm_swapout.c
@@ -284,8 +284,7 @@
* first, search out the biggest object, and try to free pages from
* that.
*/
- tmpe = map->header.next;
- while (tmpe != &map->header) {
+ VM_MAP_ENTRY_FOREACH(tmpe, map) {
if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
obj = tmpe->object.vm_object;
if (obj != NULL && VM_OBJECT_TRYRLOCK(obj)) {
@@ -302,7 +301,6 @@
}
if (tmpe->wired_count > 0)
nothingwired = FALSE;
- tmpe = tmpe->next;
}
if (bigobj != NULL) {
@@ -313,8 +311,7 @@
* Next, hunt around for other pages to deactivate. We actually
* do this search sort of wrong -- .text first is not the best idea.
*/
- tmpe = map->header.next;
- while (tmpe != &map->header) {
+ VM_MAP_ENTRY_FOREACH(tmpe, map) {
if (pmap_resident_count(vm_map_pmap(map)) <= desired)
break;
if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
@@ -326,7 +323,6 @@
VM_OBJECT_RUNLOCK(obj);
}
}
- tmpe = tmpe->next;
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jul 4, 9:08 AM (3 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34662291
Default Alt Text
D21882.id.diff (8 KB)
Attached To
Mode
D21882: Use a loop macro for enumerating vm map entries
Attached
Detach File
Event Timeline
Log In to Comment