kvm_getswapinfo() function returns smaller device sizes than the actual swap device sizes configured available. "systat -swap" uses this API and shows problem. "sysctl -c" uses a different API and displays correct sizes. While "usesd" swap device sizes are reported correctly, when a swap device is used fully, it looks like system haven overwritten next partition. The root of problem is libkvm subtracts vm.dmmax, maximum VOP I/O allowed, form size of device erroneously. The following shows that 1 MB swap device is prepared, attached, and then fully used. Given FreeBSD swap skips 2 4k blocks, 1016 is the correct size available for swapping. # dd if=/dev/zero of=1MB bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes transferred in 0.035823 secs (29271150 bytes/sec) # mdconfig -a -t vnode -f 1MB md0 # swapon /dev/md0 # swapctl -l Device: 1024-blocks Used: /dev/ada0s1b 2097144 0 /dev/md0 1016 0 # mount -t tmpfs tmpfs /mnt/tmp # dd if=/dev/zero of=/mnt/tmp/fill bs=1M count=2000 2000+0 records in 2000+0 records out 2097152000 bytes transferred in 36.267636 secs (57824337 bytes/sec) # swapctl -l Device: 1024-blocks Used: /dev/ada0s1b 2097144 144220 /dev/md0 1016 1016 # systat -swap Disk 1K-blocks Used /0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100 ada0s1b 2097016 144216 XXXX md0 888 1016 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX 2097904 145232 XXXX
No patch seems attached?
(In reply to Mark Linimon from comment #1) Bugzilla was unstable, I got lots of database error, and couldn't get this page. https://reviews.freebsd.org/D20674 is my proposal.
By the way, this problem goes back to 11 releases, too. https://svnweb.freebsd.org/base/stable/11/lib/libkvm/kvm_getswapinfo.c?revision=331722&view=markup#l135 Is this a candidate for 11.3 release patch, too?
Keyword: patch or patch-ready – in lieu of summary line prefix: [patch] * bulk change for the keyword * summary lines may be edited manually (not in bulk). Keyword descriptions and search interface: <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
^Triage: now see https://reviews.freebsd.org/D20674 .