I am running tor on a small OpenWRT router, where swapping can't be avoided due to the limited amount of ram available (32mb).
Most of the time the router doesn't do anything else, however from time to time a postgresql database also running on the router is accessed. Due to tor constantly running, postgresql is completly swapped out and the first few accesses have very high latency, which is bad because it is a interactively used system.
I've already assigned a nice value of -15 to postgres and +15 to tor, but it doesn't seem to affect memory management very much. Setting swappiness=1 globally doesn't change things too, because swapping can not be avoided, and because postgresql isn't running most of the time, it is swapped out anyway.
Is there any way to a something like a memory priority to a Linux process? I had a look at cgroup specific swappiness, however the only description I found was that it affects the decision page-cache vs swap.
What I am looking for is a parameter to tell the linux kernel to not swap out postgresql as aggresivly as the other processes (but I don't want to mlock the whole process). Or would assigning swappiness=80 system-wide and swapiness=1 for postgresql keep postgresql in memory while swaping out everything else when required?