To use zram the Linux kernel zsmalloc needs to be enabled. The zsmalloc functionality in turn allows to use two methods to access allocations of multiple pages: Copy-based or using VM mapping. Depending on platform one or the other is faster, and the configuration option already suggests that ARM the VM mapping method is typically faster. Hence I was wondering whether that is also true for ARM64 platforms (running in Aarch64 mode). Outcome: On a quad Cortex-A35 platform using Linux 4.14 VM mapping was ~20-50% faster.
The measurement was done using the zsmalloc microbenchmark linked in the kernel configuraiton. To work with Linux 4.14 I used this fork of zsmalloc. Here are the logs of two runs:
CONFIG_PGTABLE_MAPPING disabled
# insmod /tmp/zsmapbench.ko single_threaded=0 [ 70.243246] zsmapbench: loading out-of-tree module taints kernel. [ 70.249970] running zsmapbench... [ 70.253870] starting zsmb_kthread [ 70.257112] starting zsmb_kthread [ 70.257126] starting zsmb_kthread [ 70.257132] starting zsmb_kthread [ 71.269098] 8087556 cycles [ 71.271911] 872547 mappings [ 71.275308] 9 cycles/map [ 71.278077] stopping zsmb_kthread [ 71.281731] 8193562 cycles [ 71.284443] 880742 mappings [ 71.287268] 9 cycles/map [ 71.289821] stopping zsmb_kthread [ 71.293250] 8285606 cycles [ 71.295963] 893724 mappings [ 71.298778] 9 cycles/map [ 71.301343] stopping zsmb_kthread [ 71.304743] 8299217 cycles [ 71.307469] 898431 mappings [ 71.310296] 9 cycles/map [ 71.312834] stopping zsmb_kthread [ 71.316475] zsmapbench complete ... # insmod /tmp/zsmapbench.ko single_threaded=1 [ 87.134504] running zsmapbench... [ 87.138006] starting zsmb_kthread [ 88.165339] 8189148 cycles [ 88.168070] 1081365 mappings [ 88.170984] 7 cycles/map [ 88.173546] stopping zsmb_kthread [ 88.177124] zsmapbench complete
CONFIG_PGTABLE_MAPPING enabled
# insmod /tmp/zsmapbench.ko single_threaded=0 [ 51.344365] zsmapbench: loading out-of-tree module taints kernel. [ 51.351160] running zsmapbench... [ 51.354916] starting zsmb_kthread [ 51.354918] starting zsmb_kthread [ 51.354967] starting zsmb_kthread [ 51.357148] starting zsmb_kthread [ 52.383034] 8196954 cycles [ 52.385753] 721562 mappings [ 52.388960] 11 cycles/map [ 52.391766] stopping zsmb_kthread [ 52.395384] 8215377 cycles [ 52.398095] 720467 mappings [ 52.400908] 11 cycles/map [ 52.403545] stopping zsmb_kthread [ 52.406945] 8413254 cycles [ 52.409672] 738590 mappings [ 52.412490] 11 cycles/map [ 52.415133] stopping zsmb_kthread [ 52.418524] 8489886 cycles [ 52.421253] 744137 mappings [ 52.424075] 11 cycles/map [ 52.426703] stopping zsmb_kthread [ 52.430352] zsmapbench complete # insmod /tmp/zsmapbench.ko single_threaded=1 [ 67.197377] running zsmapbench... [ 67.200880] starting zsmb_kthread [ 68.223545] 8151926 cycles [ 68.226268] 718261 mappings [ 68.229083] 11 cycles/map [ 68.231728] stopping zsmb_kthread [ 68.235331] zsmapbench complete