diff --git a/MANPAGE.md b/MANPAGE.md index 7a2315b..b6b62b5 100644 --- a/MANPAGE.md +++ b/MANPAGE.md @@ -71,7 +71,7 @@ Send SIGKILL if at or below KILL_SIZE (default SIZE/2), otherwise SIGTERM. removed in earlyoom v1.2, ignored for compatibility #### -i -user-space oom killer should ignore positive oom_score_adj values +removed in earlyoom v1.7, ignored for compatibility #### -d enable debugging messages diff --git a/README.md b/README.md index 5a52c38..4c8d948 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,8 @@ Changelog --------- * vNEXT * Add `-g` flag to kill whole process group ([#247](https://github.com/rfjakob/earlyoom/pull/247)) + * Remove `-i` flag (ignored for compatibility), it does + not work properly on Linux kernels 5.9+ ([#234](https://github.com/rfjakob/earlyoom/issues/234)) * v1.6.2, 2020-10-14 * Double-check memory situation before killing victim ([commit](https://github.com/rfjakob/earlyoom/commit/e34e0fcec5d9f60eb19a48a3ec2bab175818fdd8)) diff --git a/kill.c b/kill.c index 57305b9..5c175da 100644 --- a/kill.c +++ b/kill.c @@ -171,17 +171,6 @@ procinfo_t find_largest_process(const poll_loop_args_t* args) } cur.badness = res; } - if (args->ignore_oom_score_adj) { - int oom_score_adj = 0; - int res = get_oom_score_adj(cur.pid, &oom_score_adj); - if (res < 0) { - debug(" error reading oom_score_adj: %s\n", strerror(-res)); - continue; - } - if (oom_score_adj > 0) { - cur.badness -= oom_score_adj; - } - } if ((args->prefer_regex || args->avoid_regex)) { int res = get_comm(cur.pid, cur.name, sizeof(cur.name)); diff --git a/kill.h b/kill.h index d854dc8..33d92bb 100644 --- a/kill.h +++ b/kill.h @@ -14,8 +14,6 @@ typedef struct { double mem_kill_percent; double swap_term_percent; double swap_kill_percent; - /* ignore /proc/PID/oom_score_adj? */ - bool ignore_oom_score_adj; /* send d-bus notifications? */ bool notify; /* kill all processes within a process group */ diff --git a/main.c b/main.c index b0c09cd..8d62558 100644 --- a/main.c +++ b/main.c @@ -166,8 +166,7 @@ int main(int argc, char* argv[]) fprintf(stderr, "Option -k is ignored since earlyoom v1.2\n"); break; case 'i': - args.ignore_oom_score_adj = 1; - fprintf(stderr, "Ignoring positive oom_score_adj values (-i)\n"); + fprintf(stderr, "Option -i is ignored since earlyoom v1.7\n"); break; case 'n': args.notify = true; diff --git a/testsuite_cli_test.go b/testsuite_cli_test.go index d315fff..4fb51e4 100644 --- a/testsuite_cli_test.go +++ b/testsuite_cli_test.go @@ -4,8 +4,6 @@ import ( "fmt" "io/ioutil" "math" - "os/exec" - "regexp" "strconv" "strings" "testing" @@ -105,7 +103,7 @@ func TestCli(t *testing.T) { // Test --avoid and --prefer {args: []string{"--avoid", "MyProcess1"}, code: -1, stderrContains: "Will avoid killing", stdoutContains: memReport}, {args: []string{"--prefer", "MyProcess2"}, code: -1, stderrContains: "Preferring to kill", stdoutContains: memReport}, - {args: []string{"-i"}, code: -1, stderrContains: "Ignoring positive oom_score_adj values"}, + {args: []string{"-i"}, code: -1, stderrContains: "Option -i is ignored"}, // Extra arguments should error out {args: []string{"xyz"}, code: 13, stderrContains: "extra argument not understood", stdoutEmpty: true}, {args: []string{"-i", "1"}, code: 13, stderrContains: "extra argument not understood", stdoutEmpty: true}, @@ -216,47 +214,3 @@ func TestRss(t *testing.T) { } t.Logf("earlyoom RSS: %d kiB", res.rss) } - -// TestI tests that `earlyoom -i` works as expected -func TestI(t *testing.T) { - cmd := exec.Command("sleep", "60") - err := cmd.Start() - if err != nil { - t.Fatal(err) - } - defer cmd.Process.Kill() - path := fmt.Sprintf("/proc/%d/oom_score_adj", cmd.Process.Pid) - err = ioutil.WriteFile(path, []byte("1000"), 0600) - if err != nil { - t.Fatal(err) - } - res := runEarlyoom(t, "-d") - // We should see a line like this: - // pid 2308155: badness 1000 vm_rss 708 uid 1026 "sleep" <--- new victim - // Or, for some reason, this: - // pid 6950: badness 999 vm_rss 772 uid 1026 "sleep" <--- new victim - matched := false - for _, b := range []int{1000, 999} { - pattern := fmt.Sprintf(`pid\s+%d: badness %d`, cmd.Process.Pid, b) - matched, err = regexp.MatchString(pattern, res.stdout) - if err != nil { - t.Fatal(err) - } - if matched { - break - } - } - if !matched { - t.Error("did not see badness 1000 or 999 in output") - t.Log(res.stdout) - } - res = runEarlyoom(t, "-d", "-i") - pattern := fmt.Sprintf(`pid\s+%d: badness %d`, cmd.Process.Pid, 1000) - matched, err = regexp.MatchString(pattern, res.stdout) - if err != nil { - t.Fatal(err) - } - if matched { - t.Error("saw badness 1000, but should not have") - } -}