On 21/06/2024 00:34, Chris Li wrote:
- thp_swap_allocator_test
- The purpose of this test program is helping check if THP swpout
- can correctly get swap slots to swap out as a whole instead of
- being split. It randomly releases swap entries through madvise
- DONTNEED and do swapout on two memory areas: a memory area for
- 64KB THP and the other area for small folios. The second memory
- can be enabled by "-s".
- Before running the program, we need to setup a zRAM or similar
- swap device by:
- echo lzo > /sys/block/zram0/comp_algorithm
- echo 64M > /sys/block/zram0/disksize
- echo never > /sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled
- echo always > /sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled
- mkswap /dev/zram0
- swapon /dev/zram0
This setup needs to go into run_vmtest.sh as well.
Also tear it down after the test.
Additionally, if keeping this as a selftest, you'll want to add
CONFIG_ZRAM=y
to tools/testing/selftests/mm/config so that automated systems ensure zram is available in the kernel under test.
And you will need to ensure that the zram device has a higher priority than any other already configured swap devices. Otherwise there will not even be an attempt to use it for mTHP. The easy way is to do "swapoff -a" as the first step but that makes cleanup tricky.