rfjakob / earlyoom

earlyoom - Early OOM Daemon for Linux
MIT License
2.96k stars 157 forks source link

Preferring or ignoring processes based on their user? #316

Closed danya02 closed 5 months ago

danya02 commented 6 months ago

I'm running a desktop that also has some background server processes. The server processes aren't particularly important, but they do take up a lot of memory at times. When OOMing, however, sometimes my desktop apps end up being killed instead of the servers, and I'd like to avoid this. Mentioning some of the biggest processes in --avoid/--ignore helps, but I'd prefer to avoid listing everything I'd ever use in there.

There is already an option for --ignore-root-user, but you don't run your desktop environment as root, and you probably don't want it outright ignored either. How about adding options for --prefer/--avoid/--ignore that act on process users instead of regexes regexes?

hakavlad commented 6 months ago

sometimes my desktop apps end up being killed instead of the servers, and I'd like to avoid this

btw nohang allows this:

##  7.2.4. Matching eUIDs with RE patterns
# avoid killing processes with UID=1000
@BADNESS_ADJ_RE_UID -300 /// ^1000$

see https://github.com/hakavlad/nohang/blob/master/conf/nohang/nohang.conf.in

rfjakob commented 5 months ago

I suggest to instead use OOMScoreAdjust for those server processes: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#OOMScoreAdjust=

earlyoom respects that (expect when running with --sort-by-rss)