2024-11-20 09:34:50 +08:00
|
|
|
echo always > /sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled
|
|
|
|
|
|
|
|
|
|
tmpfile=$(mktemp)
|
|
|
|
|
|
|
|
|
|
pgfault1=$(cat /proc/vmstat | grep pgfault | awk '{print $2}')
|
|
|
|
|
|
|
|
|
|
./test_swap > $tmpfile
|
|
|
|
|
|
|
|
|
|
pgfault2=$(cat /proc/vmstat | grep pgfault | awk '{print $2}')
|
|
|
|
|
|
|
|
|
|
swapout=$(head -n 1 $tmpfile | awk '{print $4}')
|
|
|
|
|
swapin=$(tail -n 1 $tmpfile | awk '{print $4}')
|
|
|
|
|
|
|
|
|
|
cat /sys/block/zram0/mm_stat > $tmpfile
|
|
|
|
|
|
|
|
|
|
total_size=$(cat $tmpfile | awk '{print $1}')
|
|
|
|
|
used_size=$(cat $tmpfile | awk '{print $2}')
|
|
|
|
|
comp_ratio=`echo "scale=4; $total_size / $used_size" | bc`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
anon_fault_alloc=$(cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_alloc)
|
|
|
|
|
anon_fault_fallback=$(cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_fallback)
|
|
|
|
|
anon_total=$(($anon_fault_fallback + $anon_fault_alloc))
|
|
|
|
|
folio_alloc_success_ratio=`echo "scale=4; $anon_fault_alloc / $anon_total" | bc`
|
|
|
|
|
|
|
|
|
|
swpout_alloc=$(cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpout)
|
|
|
|
|
swpout_fault_fallback=$(cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpout_fallback)
|
|
|
|
|
swpout_total=$(($swpout_fault_fallback + $swpout_alloc))
|
2024-11-20 11:07:56 +08:00
|
|
|
swapout_success_ratio=`echo "scale=4; $swpout_alloc / $swpout_total" | bc`
|
|
|
|
|
|
|
|
|
|
if [ -f /sys/block/zram0/multi_pages_debug_stat ]; then
|
|
|
|
|
|
|
|
|
|
cat /sys/block/zram0/multi_pages_debug_stat > $tmpfile
|
|
|
|
|
|
|
|
|
|
nr_write_multipage=$(head -n 1 $tmpfile | awk '{print $5}')
|
|
|
|
|
nr_read_multipage=$(head -n 1 $tmpfile | awk '{print $6}')
|
|
|
|
|
|
|
|
|
|
nr_write_failed_multipage=$(cat $tmpfile | grep "failed" | awk '{print $6}')
|
|
|
|
|
nr_read_failed_multipage=$(cat $tmpfile | grep "failed" | awk '{print $7}')
|
|
|
|
|
|
|
|
|
|
nr_write_succeed_multipage=$(($nr_write_multipage-$nr_write_failed_multipage))
|
|
|
|
|
nr_read_succeed_multipage=$(($nr_read_multipage-$nr_read_failed_multipage))
|
|
|
|
|
|
|
|
|
|
zram_write_multipage_ratio=`echo "scale=4; $nr_write_succeed_multipage / $nr_write_multipage" | bc`
|
|
|
|
|
zram_read_multipage_ratio=`echo "scale=4; $nr_read_succeed_multipage / $nr_read_multipage" | bc`
|
|
|
|
|
fi
|
2024-11-20 09:34:50 +08:00
|
|
|
|
|
|
|
|
echo swapout $swapout
|
|
|
|
|
echo swapin $swapin
|
|
|
|
|
echo comp_ratio $comp_ratio
|
2024-11-20 11:07:56 +08:00
|
|
|
echo pagefault $(($pgfault2-$pgfault1))
|
2024-11-20 09:34:50 +08:00
|
|
|
echo folio_alloc_success_ratio $folio_alloc_success_ratio
|
2024-11-20 11:07:56 +08:00
|
|
|
echo swapout_success_ratio $swapout_success_ratio
|
|
|
|
|
|
|
|
|
|
if [ -f /sys/block/zram0/multi_pages_debug_stat ]; then
|
|
|
|
|
echo zram_write_multipage_ratio $zram_write_multipage_ratio
|
|
|
|
|
echo zram_read_multipage_ratio $zram_read_multipage_ratio
|
|
|
|
|
fi
|
2024-11-20 09:34:50 +08:00
|
|
|
|
|
|
|
|
killall test_swap
|