Date: Wed, 8 Nov 2017 11:47:00 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325545 - stable/11/usr.bin/top Message-ID: <201711081147.vA8Bl0Mq035622@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Nov 8 11:47:00 2017 New Revision: 325545 URL: https://svnweb.freebsd.org/changeset/base/325545 Log: MFC r324972: Tweaks to the top swap size calculations. PR: 223149 Modified: stable/11/usr.bin/top/machine.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/top/machine.c ============================================================================== --- stable/11/usr.bin/top/machine.c Wed Nov 8 11:44:02 2017 (r325544) +++ stable/11/usr.bin/top/machine.c Wed Nov 8 11:47:00 2017 (r325545) @@ -1671,8 +1671,9 @@ static int swapmode(int *retavail, int *retfree) { int n; - int pagesize = getpagesize(); struct kvm_swap swapary[1]; + static int pagesize = 0; + static u_long swap_maxpages = 0; *retavail = 0; *retfree = 0; @@ -1682,6 +1683,16 @@ swapmode(int *retavail, int *retfree) n = kvm_getswapinfo(kd, swapary, 1, 0); if (n < 0 || swapary[0].ksw_total == 0) return (0); + + if (pagesize == 0) + pagesize = getpagesize(); + if (swap_maxpages == 0) + GETSYSCTL("vm.swap_maxpages", swap_maxpages); + + /* ksw_total contains the total size of swap all devices which may + exceed the maximum swap size allocatable in the system */ + if ( swapary[0].ksw_total > swap_maxpages ) + swapary[0].ksw_total = swap_maxpages; *retavail = CONVERT(swapary[0].ksw_total); *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711081147.vA8Bl0Mq035622>