5

current configurations is swappiness = 40; zswap cache = 40

free -m command says

               total        used        free      shared  buff/cache   available
Mem:           3615        1353        1232         191        1029        1806
Swap:          4095           4        4091

zswap debug info by command sudo grep -r . /sys/kernel/debug/zswap

/sys/kernel/debug/zswap/stored_pages:892
/sys/kernel/debug/zswap/pool_total_size:1220608
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0
1
  • I've just been testing and have seen the system go massively into swap without hitting the pool limit. Very odd. I've spent an hour reading the source and still can't see how this could happen...
    – Steve Dee
    Commented Jun 17, 2018 at 22:57

1 Answer 1

5

Pages in zswap still get counted as disk swapped. I believe this is needed because the zswap pool size is dynamic and this allows to eventually move all pages to the disk swap.

/sys/kernel/debug/zswap/written_back_pages shows how many pages where actually written to disk, but as far as I understand this is an all time cumulative increment.

To get the current number of bytes swapped on disk :
You want to calculate

$used_swap_in_bytes(as shown by "free -b" or "swapon -s") -
/sys/kernel/debug/zswap/stored_pages * $(getconf PAGESIZE)

eg (in bytes)

echo "$(LANG=c free -b |grep Swap |awk '{print $3}') - $(sudo \
cat /sys/kernel/debug/zswap/stored_pages)*$(getconf PAGESIZE)" |bc -l
echo bytes swapped on disk

or in Mio (floor rounded ):

echo | awk '{value='"$(LANG=c free -b |grep Swap |awk '{print $3}')\
- $(sudo cat /sys/kernel/debug/zswap/stored_pages)*\
$(getconf PAGESIZE)"';printf "%.0f\n", value/1024**2}'
echo Mio swapped on disk

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .