mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
vm: rework swap_pager_status to execute in constant time
The lock-protected iteration is trivially avoidable. This removes a serialisation point from Linux binaries (which end up calling here from the sysinfo syscall).
This commit is contained in:
parent
4707401c75
commit
7ce3a31286
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361965
|
@ -2541,16 +2541,10 @@ swapoff_all(void)
|
|||
void
|
||||
swap_pager_status(int *total, int *used)
|
||||
{
|
||||
struct swdevt *sp;
|
||||
|
||||
*total = 0;
|
||||
*used = 0;
|
||||
mtx_lock(&sw_dev_mtx);
|
||||
TAILQ_FOREACH(sp, &swtailq, sw_list) {
|
||||
*total += sp->sw_nblks;
|
||||
*used += sp->sw_used;
|
||||
}
|
||||
mtx_unlock(&sw_dev_mtx);
|
||||
*total = swap_total;
|
||||
*used = swap_total - swap_pager_avail -
|
||||
nswapdev * howmany(BBSIZE, PAGE_SIZE);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue