[Bug 238670] [libkvm][patch] kvm_getswapinfo() returns swap device sizes too small incorrectly

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Jun 17 17:34:06 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238670

            Bug ID: 238670
           Summary: [libkvm][patch] kvm_getswapinfo() returns swap device
                    sizes too small incorrectly
           Product: Base System
           Version: 12.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: ota at j.email.ne.jp

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

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list