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

TestI fails on Alpine Linux (musl libc): did not see badness 1000 or 999 in output #234

Closed
jirutka opened this issue Jan 20, 2021 · 4 comments
Labels

Comments

@jirutka
Copy link

jirutka commented Jan 20, 2021

=== RUN   TestI
    testsuite_cli_test.go:248: did not see badness 1000 or 999 in output
    testsuite_cli_test.go:249: dry-running kill_largest_process()...
        pid     2: badness   0 vm_rss       0  
        pid     3: badness   0 vm_rss       0  
        ...
        pid  2212: badness   0 vm_rss       0  
        pid  2487: badness 666 vm_rss      60 uid    0 oom_score_adj    0 "syslogd" <--- new victim
        pid  2830: badness 666 vm_rss      48   
        pid  2858: badness 666 vm_rss     792 uid    0 oom_score_adj    0 "crond" <--- new victim
        pid  2920: badness 666 vm_rss      48   
        pid  3012: badness 666 vm_rss    2504 uid  100 oom_score_adj    0 "nrpe" <--- new victim
        pid  3039: badness 666 vm_rss    1764   
        pid  3065: badness 666 vm_rss    2004   
        pid  3066: badness 666 vm_rss    1916   
        pid  3072: badness   0 
        pid  3079: badness 666 vm_rss     868   
        pid  3080: badness 666 vm_rss     828   
        pid  3081: badness 666 vm_rss     828   
        pid  3082: badness 666 vm_rss     860   
        pid  3083: badness 666 vm_rss     884   
        pid  3084: badness 666 vm_rss     844   
        pid  9030: badness 666 vm_rss    3704 uid    0 oom_score_adj    0 "sshd" <--- new victim
        pid  9032: badness 666 vm_rss    2576   
        pid  9033: badness 666 vm_rss    1464   
        pid  9075: badness   0 
        pid  9379: badness   0 
        pid 13544: badness   0 
        pid 13897: badness 1332 vm_rss       4 uid 1000 oom_score_adj  999 "sleep" <--- new victim
        pid 14174: badness   0 
        pid 14186: badness   0 
        pid 14210: badness 666 
        pid 14235: badness 666 
        pid 14372: badness 666 
        pid 14429: badness 1332 vm_rss       4   
        pid 14430: badness 666 
        selecting victim took 2.444 ms
        mem avail: 31693 of 32123 MiB (98.66%), swap free: 2047 of 2047 MiB (100.00%)
$ sleep 600 &
$ pid=$!
$ echo 888 > /proc/$pid/oom_score_adj

$ cat /proc/$pid/oom_adj
15
$ cat /proc/$pid/oom_score
1258
$ cat /proc/$pid/oom_score_adj
888

$ ./earlyoom -d
...
pid 14755: badness 1258 vm_rss       4 uid 1000 oom_score_adj  888 "sleep" <--- new victim
...

Environment:

  • x86_64 / QEMU/KVM VM
  • Linux 5.10.9
  • Alpine Linux Edge
  • musl 1.2.2
  • gcc 10.2.1 (with downstream patches)
  • earlyoom 1.6.2
@rfjakob
Copy link
Owner

rfjakob commented Jan 22, 2021

Thanks for the report. Kernel 5.9 changed the default oom_score from 0 to 666, which means that the -i option does not work properly anymore.

@jirutka
Copy link
Author

jirutka commented Jan 22, 2021

Oh, really 666? I cannot wait for brainless numerologists starting freaking out from it! 🤣

@rfjakob rfjakob added the bug label May 6, 2021
@rfjakob
Copy link
Owner

rfjakob commented May 6, 2021

This is pretty messy. Now writing 1000 to oom_score_adj raises oom_score by 666 points (instead of 1000 as before):

$ grep . /proc/$$/oom_score*
/proc/62520/oom_score:666
/proc/62520/oom_score_adj:0

$ echo 1000 > /proc/$$/oom_score_adj
$ grep . /proc/$$/oom_score*
/proc/62520/oom_score:1333
/proc/62520/oom_score_adj:1000

I think I will drop the -i option altogether (objections?).

@rfjakob rfjakob closed this as completed in 545a65d May 7, 2021
rfjakob added a commit that referenced this issue May 7, 2021
Kernel 5.9 changed how oom_score_adj works, and
I don't think this feature is worth having kernel
version detection to make it work on older & newer
kernels. Just drop it.

Fixes #234
rfjakob added a commit that referenced this issue May 7, 2021
@hakavlad
Copy link
Contributor

hakavlad commented May 10, 2021

This is pretty messy.

It's easy to understand:

666 is 1000 * 2/3.

If oom_score_adj=300 than 300 * 2/3 (= 200) will be added to oom_score.

It's easy to fix -i option to work with new (Linux 5.9+) kernels: add oom_score_adj * 2/3 to oom_score instead of adding oom_score_adj. And describe this change in the changelog instead of removing -i option completely. Of course, with older kernels, the option will work less efficiently in this case.

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

No branches or pull requests

3 participants