Exact duplicate of this question, which has an accepted answer that doesn't solve the problem.
How do I set sshd to run with a higher priority, so that even if the system is massively overloaded (e.g. by a fork bomb) and the cpu usage is at 100%, I can still connect to it?
Using /etc/security/limits.conf does no good, because that won't let you say "process X should always have priority", it just sets general limits.
Using cgroups doesn't work, because as far as I can tell, it lets you set absolute limits on process, but not relative ones - you can't tell it to give one process priority over others.