aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/cgroup/cgroup_util.c
diff options
context:
space:
mode:
authorJay Kamat <jgkamat@fb.com>2018-09-07 14:34:05 -0700
committerShuah Khan (Samsung OSG) <shuah@kernel.org>2018-09-07 16:36:01 -0600
commita987785dcd6c8ae2915460582aebd6481c81eb67 (patch)
treec451b56d196e449bade01055bc30dd43eaad8d4d /tools/testing/selftests/cgroup/cgroup_util.c
parentFix cg_read_strcmp() (diff)
downloadlinux-dev-a987785dcd6c8ae2915460582aebd6481c81eb67.tar.xz
linux-dev-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.c21
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;
+}