diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2024-11-03 08:02:16 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2024-11-03 08:02:16 +0000 |
commit | 038e0edc47cec156f6d0d2521ce7c06ad82950c2 (patch) | |
tree | cdb9e4159d9039d131b3746f2b293dec5561f7cf /sys/uvm | |
parent | af57841497cf37ca64bc5ba845b26e6a25953cb7 (diff) |
Introduce a `shortage' variable to reduce accesses to `uvmexp.free' & friends.
ok miod@
Diffstat (limited to 'sys/uvm')
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 146333eefee..3a5f7be6038 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.118 2024/11/02 07:57:54 mpi Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.119 2024/11/03 08:02:15 mpi Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -102,7 +102,7 @@ extern unsigned long drmbackoff(long); */ struct rwlock *uvmpd_trylockowner(struct vm_page *); -void uvmpd_scan(struct uvm_pmalloc *, int, +void uvmpd_scan(struct uvm_pmalloc *, int, int, struct uvm_constraint_range *); int uvmpd_scan_inactive(struct uvm_pmalloc *, struct uvm_constraint_range *); @@ -206,7 +206,7 @@ uvm_pageout(void *arg) { struct uvm_constraint_range constraint; struct uvm_pmalloc *pma; - int inactive_shortage, free; + int shortage, inactive_shortage; /* ensure correct priority and set paging parameters... */ uvm.pagedaemon_proc = curproc; @@ -237,7 +237,7 @@ uvm_pageout(void *arg) } else constraint = no_constraint; } - free = uvmexp.free - BUFPAGES_DEFICIT; + shortage = uvmexp.freetarg - uvmexp.free + BUFPAGES_DEFICIT; uvm_unlock_fpageq(); /* @@ -254,8 +254,8 @@ uvm_pageout(void *arg) size = 0; if (pma != NULL) size += pma->pm_size >> PAGE_SHIFT; - if (free < uvmexp.freetarg) - size += uvmexp.freetarg - free; + if (shortage > 0) + size += shortage; if (size == 0) size = 16; /* XXX */ @@ -269,12 +269,12 @@ uvm_pageout(void *arg) * scan if needed */ uvm_lock_pageq(); - free = uvmexp.free - BUFPAGES_DEFICIT; + shortage = uvmexp.freetarg - uvmexp.free + BUFPAGES_DEFICIT; inactive_shortage = uvmexp.inactarg - uvmexp.inactive - BUFPAGES_INACT; - if (pma != NULL || (free < uvmexp.freetarg) || - (inactive_shortage > 0)) { - uvmpd_scan(pma, inactive_shortage, &constraint); + if (pma != NULL || (shortage > 0) || (inactive_shortage > 0)) { + uvmpd_scan(pma, shortage, inactive_shortage, + &constraint); } /* @@ -861,10 +861,10 @@ uvmpd_scan_inactive(struct uvm_pmalloc *pma, */ void -uvmpd_scan(struct uvm_pmalloc *pma, int inactive_shortage, +uvmpd_scan(struct uvm_pmalloc *pma, int shortage, int inactive_shortage, struct uvm_constraint_range *constraint) { - int free, swap_shortage, pages_freed; + int swap_shortage, pages_freed; struct vm_page *p, *nextpg; struct rwlock *slock; paddr_t paddr; @@ -873,20 +873,16 @@ uvmpd_scan(struct uvm_pmalloc *pma, int inactive_shortage, uvmexp.pdrevs++; /* counter */ - /* - * get current "free" page count - */ - free = uvmexp.free - BUFPAGES_DEFICIT; #ifdef __HAVE_PMAP_COLLECT /* * swap out some processes if we are below our free target. * we need to unlock the page queues for this. */ - if (free < uvmexp.freetarg) { + if (shortage > 0) { uvmexp.pdswout++; uvm_unlock_pageq(); - uvm_swapout_threads(); + shortage -= uvm_swapout_threads(); uvm_lock_pageq(); } #endif @@ -899,6 +895,7 @@ uvmpd_scan(struct uvm_pmalloc *pma, int inactive_shortage, */ pages_freed = uvmpd_scan_inactive(pma, constraint); uvmexp.pdfreed += pages_freed; + shortage -= pages_freed; /* * we have done the scan to get free pages. now we work on meeting @@ -907,11 +904,10 @@ uvmpd_scan(struct uvm_pmalloc *pma, int inactive_shortage, * detect if we're not going to be able to page anything out * until we free some swap resources from active pages. */ - free = uvmexp.free - BUFPAGES_DEFICIT; swap_shortage = 0; - if (free < uvmexp.freetarg && uvm_swapisfilled() && !uvm_swapisfull() && + if ((shortage > 0) && uvm_swapisfilled() && !uvm_swapisfull() && pages_freed == 0) { - swap_shortage = uvmexp.freetarg - free; + swap_shortage = shortage; } for (p = TAILQ_FIRST(&uvm.page_active); |