Extend regex expressions to match more detailed process info via /proc/PID/cmdline
At now regex expressions for --avoid and --prefer options only match process base name, that often too short and not contain useful info.
For example, all Node.js processes have node as basename, so there are no ways to prefer only specific node processes, not all running. Same problem with php processes and many other programs.
So, please, allow extend regular expressions for match more detailed process information!
As I understand, earlyoom get current process info from /proc/PID/status file, that contain not so much info. Can we extend this info with data from /proc/PID/cmdline?
For not broke current behavior, we can add additional keys like --prefer-cmdline regexps.
And for not reduce performance of process listener, we can make regex matches two stepped:
- First step is match is process basename via
--prefer, like now - Second step is (if filled
--prefer-cmdline), get pids of matched processes from first step, loadcmdlineinfo and match it via regex.
What do you think about this idea?
You can use https://github.com/hakavlad/nohang
It supports multiple and flexible regex matching with cmdline, exe realpath, cwd, cgroup and other.
Look at the config example https://github.com/hakavlad/nohang/blob/master/conf/nohang/nohang.conf.in (Chapter 7. Customize victim selection: adjusting badness of processes)
I had a look into nohang but I did not found a way to start killing processes in the way earlyoom is doing it (if X % memory and X % swap is left start killing).
To my understanding nohang can be configured only to act based on the PSI information which is to late for my point of view.