Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend regex expressions to match more detailed process info via /proc/PID/cmdline #196

Open
MurzNN opened this issue May 8, 2020 · 5 comments

Comments

@MurzNN
Copy link

MurzNN commented May 8, 2020

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:

  1. First step is match is process basename via --prefer, like now
  2. Second step is (if filled --prefer-cmdline), get pids of matched processes from first step, load cmdline info and match it via regex.

What do you think about this idea?

@hakavlad
Copy link
Contributor

hakavlad commented May 8, 2020

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)

@paprickar
Copy link

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.

@FichteFoll
Copy link

FichteFoll commented Mar 1, 2024

Would be very useful to target various electron processes with --type=zygote or --type=renderer parameters in the cmdline with very few expression branches instead of adding all the executable names.

@hakavlad
Copy link
Contributor

hakavlad commented Mar 1, 2024

@paprickar

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).

soft_threshold_min_mem = 5 %
soft_threshold_min_swap = 10 %
hard_threshold_min_mem = 2 %
hard_threshold_min_swap = 4 %

It is default values.
https://github.com/hakavlad/nohang/blob/master/conf/nohang/nohang.conf.in

@hakavlad
Copy link
Contributor

hakavlad commented Mar 1, 2024

# Prefer Chromium tabs and Electron-based apps
@BADNESS_ADJ_RE_CMDLINE  200 /// --type=renderer

@FichteFoll How to do this with nohang
https://github.com/hakavlad/nohang/blob/master/conf/nohang/nohang.conf.in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants