diff options
author | Jay Kamat <jgkamat@fb.com> | 2018-09-07 14:34:05 -0700 |
---|---|---|
committer | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-09-07 16:36:01 -0600 |
commit | a987785dcd6c8ae2915460582aebd6481c81eb67 (patch) | |
tree | c451b56d196e449bade01055bc30dd43eaad8d4d /tools/testing/selftests/cgroup/cgroup_util.c | |
parent | 48c2bb0b9cf863e0ed78e269f188ce65b73e0fd1 (diff) | |
download | lwn-a987785dcd6c8ae2915460582aebd6481c81eb67.tar.gz lwn-a987785dcd6c8ae2915460582aebd6481c81eb67.zip |
Add tests for memory.oom.group
Add tests for memory.oom.group for the following cases:
- Killing all processes in a leaf cgroup, but leaving the
parent untouched
- Killing all processes in a parent and leaf cgroup
- Keeping processes marked by OOM_SCORE_ADJ_MIN alive when considered
for being killed by the group oom killer.
Signed-off-by: Jay Kamat <jgkamat@fb.com>
Acked-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Diffstat (limited to 'tools/testing/selftests/cgroup/cgroup_util.c')
-rw-r--r-- | tools/testing/selftests/cgroup/cgroup_util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c index f857def9a9e6..14c9fe284806 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.c +++ b/tools/testing/selftests/cgroup/cgroup_util.c @@ -348,3 +348,24 @@ int is_swap_enabled(void) return cnt > 1; } + +int set_oom_adj_score(int pid, int score) +{ + char path[PATH_MAX]; + int fd, len; + + sprintf(path, "/proc/%d/oom_score_adj", pid); + + fd = open(path, O_WRONLY | O_APPEND); + if (fd < 0) + return fd; + + len = dprintf(fd, "%d", score); + if (len < 0) { + close(fd); + return len; + } + + close(fd); + return 0; +} |