Date: Sun, 18 Aug 2024 02:08:17 -0700 From: Yuri <yuri@FreeBSD.org> To: Freebsd hackers list <freebsd-hackers@FreeBSD.org> Subject: Can free swap size be determined from the sysctl information ? Message-ID: <6076fe34-eb23-47cc-8bd2-6000ddf0a091@FreeBSD.org>
index | next in thread | raw e-mail
[-- Attachment #1 --]
It seems that it should be possible to find free swap size from the
sysctl information, but it isn't obvious how to do this.
Here are all *swap* entries in the sysctl information:
$ sysctl -a | grep swap
0 MD md98 68719441408 512 u 98 s 512 f 0 fs 0 l 68719441408 t vnode file
/disk-large1/swap-64GB label
z0xfffff8004d862400 [shape=box,label="SWAP\nswap\nr#2"];
<name>swap</name>
<file>/disk-large1/swap-64GB</file>
vm.swap_enabled: 1
vm.domain.0.stats.unswappable: 0
vm.swap_idle_threshold2: 10
vm.swap_idle_threshold1: 2
vm.swap_idle_enabled: 0
vm.disable_swapspace_pageouts: 0
vm.stats.vm.v_swappgsout: 433264
vm.stats.vm.v_swappgsin: 94457
vm.stats.vm.v_swapout: 65078
vm.stats.vm.v_swapin: 11121
vm.stats.swap.free_completed: 65205
vm.stats.swap.free_deferred: 86103
vm.nswapdev: 1
vm.swap_fragmentation:
vm.swap_async_max: 4
vm.swap_maxpages: 48890752
vm.swap_total: 68719439872
vm.swap_reserved: 16267402461184
top(1) shows 775M of free swap out of 64G total.
top(1) gets swap information from kvm_getswapinfo(3).
Motivation: one Golang-based port needs free swap size information, and
I am trying to figure out how to get this information in Golang.
Golang has the "sysctl" module.
Thanks,
Yuri
[-- Attachment #2 --]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="monospace">It seems that it should be possible to find
free swap size from the sysctl information, but it isn't obvious
how to do this.</font><br>
<font face="monospace"><br>
</font><br>
<font face="monospace">Here are all *swap* entries in the sysctl
information:</font><br>
<font face="monospace"><span
style="color:#000000;background-color:#ffffff;">$ sysctl -a |
grep swap
</span><br>
0 MD md98 68719441408 512 u 98 s 512 f 0 fs 0 l 68719441408 t
vnode file /disk-large1/swap-64GB label <br>
z0xfffff8004d862400 [shape=box,label="SWAP\nswap\nr#2"];
<br>
<name>swap</name>
<br>
<file>/disk-large1/swap-64GB</file>
<br>
vm.swap_enabled: 1
<br>
vm.domain.0.stats.unswappable: 0
<br>
vm.swap_idle_threshold2: 10
<br>
vm.swap_idle_threshold1: 2
<br>
vm.swap_idle_enabled: 0
<br>
vm.disable_swapspace_pageouts: 0
<br>
vm.stats.vm.v_swappgsout: 433264
<br>
vm.stats.vm.v_swappgsin: 94457
<br>
vm.stats.vm.v_swapout: 65078
<br>
vm.stats.vm.v_swapin: 11121
<br>
vm.stats.swap.free_completed: 65205
<br>
vm.stats.swap.free_deferred: 86103
<br>
vm.nswapdev: 1
<br>
vm.swap_fragmentation: <br>
vm.swap_async_max: 4
<br>
vm.swap_maxpages: 48890752
<br>
vm.swap_total: 68719439872
<br>
vm.swap_reserved: 16267402461184<br>
</font>
<font face="monospace"><br>
</font><br>
<font face="monospace">top(1) shows <span
style="color:#000000;background-color:#ffffff;">775M of free
swap out of </span><span
style="color:#000000;background-color:#ffffff;">64G total.</span></font><br>
<font face="monospace">top(1) gets swap information from <span
style="color:#000000;background-color:#ffffff;">kvm_getswapinfo(3).</span></font><br>
<p><br>
</p>
<p><font face="monospace">Motivation: one Golang-based port needs
free swap size information, and I am trying to figure out how to
get this information in Golang.</font></p>
<p><font face="monospace">Golang has the "sysctl" module.<br>
</font></p>
<p><font face="monospace"><br>
</font></p>
<p><font face="monospace"><br>
</font></p>
<p><font face="monospace">Thanks,</font></p>
<p><font face="monospace">Yuri</font></p>
<p><font face="monospace"><br>
</font></p>
</body>
</html>
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6076fe34-eb23-47cc-8bd2-6000ddf0a091>
