With two swap areas, Linux fills the older one first unless you say otherwise. If one is fast and one is slow, I want the fast one used first. A priority does that.
sudo swapon -p 10 /swap-fast
sudo swapon -p 5 /swap-slow
swapon --show=TYPE,SIZE,USED,PRIO
The priority is a number from 0 to 32767, and a higher number means the area is used first. With two small test swap files, one at priority 10 and one at 5, the table looked like this:
TYPE SIZE USED PRIO
file 4M 0B 10
file 4M 0B 5
The swapon(2) man page explains the rules. Pages are allocated in priority order, and a higher-priority area is used up before the next one is touched. Areas that share the same, highest priority are used round-robin. If you set nothing, the kernel hands out negative numbers, and newer areas get an even lower priority than older ones.
To make it permanent, put pri= in the options field of /etc/fstab. Here the swap file path is made up:
/swap-fast none swap sw,pri=10 0 0
The man page says pri= is used with swapon -a. If you pair a compressed zram device with a swap area on disk, give the zram device the higher number. I’d keep the numbers simple, like 100 and 10, so the order is obvious next time you read the file.
One caveat: the priority only decides the order, not the size. A high-priority area that is small fills up first, and then the kernel moves on to the next one.
Further reading: swapon(8) man page, swapon(2) man page