summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-11-11 23:04:11 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-11-14 18:14:38 +0100
commit2d1119dfc0b0e0187f8ee89e144a391f7ccfedd5 (patch)
tree62ed94d2ffd5ba1550339e97479ed22375eb7201 /lib
parent4697cf4286f3ac3cc80744c3eac2c0579c215d6c (diff)
lib: adjust oom_score
This way the igt test will always be killed first (hopefully), preventing mayhem when one of the memory thrashing tests treatens to take down the entire system. To avoid any burden on test writers we adjust the oom score on drm_open, any of the fork helpers and subtest init. That should cover everything. v2: Fix it up. Cc: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 75f49cd7..15ed8474 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -204,6 +204,16 @@ int drm_get_card(void)
return -1;
}
+static void oom_adjust_for_doom(void)
+{
+ int fd;
+ const char always_kill[] = "1000";
+
+ fd = open("/proc/self/oom_score_adj", O_WRONLY);
+ igt_assert(fd != -1);
+ igt_assert(write(fd, always_kill, sizeof(always_kill)) == sizeof(always_kill));
+}
+
/** Open the first DRM device we can find, searching up to 16 device nodes */
static int __drm_open_any(void)
{
@@ -222,6 +232,8 @@ static int __drm_open_any(void)
fd = -1;
}
+ oom_adjust_for_doom();
+
return fd;
}
@@ -251,6 +263,8 @@ static int __drm_open_any_render(void)
return fd;
}
+ oom_adjust_for_doom();
+
return fd;
}
@@ -844,6 +858,7 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
}
igt_install_exit_handler(check_igt_exit);
+ oom_adjust_for_doom();
out:
return ret;
@@ -1115,6 +1130,7 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
case 0:
exit_handler_count = 0;
reset_helper_process_list();
+ oom_adjust_for_doom();
return true;
default:
@@ -1197,6 +1213,7 @@ bool __igt_fork(void)
test_child = true;
exit_handler_count = 0;
reset_helper_process_list();
+ oom_adjust_for_doom();
return true;
default: