diff options
author | Stefan Kempf <stefan@cvs.openbsd.org> | 2016-04-12 16:47:34 +0000 |
---|---|---|
committer | Stefan Kempf <stefan@cvs.openbsd.org> | 2016-04-12 16:47:34 +0000 |
commit | d00385743a5ad7fcd5dda91f1c9de4ec2c51328c (patch) | |
tree | 7a8c5335332eef703d0772692103ec0901f9bbac /sys/uvm/uvm_amap.c | |
parent | aa13ac29aeacd0af61b6bf44a645640c24ecd9d0 (diff) |
Simplify amap traversal in amap_swap_off.
There's no need to insert marker elements to find the next item in the
amap list. The next amap can be determined by looking at the currently
examined amap.
Care must be taken to get the next element before the current amap is
possibly deleted, and after all the current amap's pages were read in
from swap (because the page-in may sleep and remove items from the amap
list).
Diffstat (limited to 'sys/uvm/uvm_amap.c')
-rw-r--r-- | sys/uvm/uvm_amap.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index 5f9d778908a..df2b8d2572c 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_amap.c,v 1.64 2016/04/04 16:34:16 stefan Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.65 2016/04/12 16:47:33 stefan Exp $ */ /* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */ /* @@ -733,21 +733,11 @@ amap_swap_off(int startslot, int endslot) { struct vm_amap *am; struct vm_amap *am_next; - struct vm_amap marker_prev; - struct vm_amap marker_next; boolean_t rv = FALSE; -#if defined(DIAGNOSTIC) - memset(&marker_prev, 0, sizeof(marker_prev)); - memset(&marker_next, 0, sizeof(marker_next)); -#endif /* defined(DIAGNOSTIC) */ - for (am = LIST_FIRST(&amap_list); am != NULL && !rv; am = am_next) { int i; - LIST_INSERT_BEFORE(am, &marker_prev, am_list); - LIST_INSERT_AFTER(am, &marker_next, am_list); - for (i = 0; i < am->am_nused; i++) { int slot; int swslot; @@ -766,23 +756,14 @@ amap_swap_off(int startslot, int endslot) rv = uvm_anon_pagein(anon); am->am_flags &= ~AMAP_SWAPOFF; - if (amap_refs(am) == 0) { - amap_wipeout(am); - am = NULL; + if (rv || amap_refs(am) == 0) break; - } - if (rv) { - break; - } i = 0; } - KASSERT(LIST_NEXT(&marker_prev, am_list) == &marker_next || - LIST_NEXT(LIST_NEXT(&marker_prev, am_list), am_list) == - &marker_next); - am_next = LIST_NEXT(&marker_next, am_list); - LIST_REMOVE(&marker_prev, am_list); - LIST_REMOVE(&marker_next, am_list); + am_next = LIST_NEXT(am, am_list); + if (amap_refs(am) == 0) + amap_wipeout(am); } return rv; |