Date: Tue, 9 Jun 2020 14:16:18 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361965 - head/sys/vm Message-ID: <202006091416.059EGIZt013469@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Tue Jun 9 14:16:18 2020 New Revision: 361965 URL: https://svnweb.freebsd.org/changeset/base/361965 Log: 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). Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Tue Jun 9 09:42:39 2020 (r361964) +++ head/sys/vm/swap_pager.c Tue Jun 9 14:16:18 2020 (r361965) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006091416.059EGIZt013469>