public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t] runner: Make sure oom-killer doesn't kill the runner
Date: Thu, 11 Apr 2019 12:40:12 +0300	[thread overview]
Message-ID: <20190411094012.4288-1-petri.latvala@intel.com> (raw)

Tests that eat all of the RAM and then some to invoke the oom-killer
deliberately sometimes cause extra casualties. Make sure the runner
stays alive.

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
 runner/executor.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/runner/executor.c b/runner/executor.c
index 0e91b7ab..7e5fbe8f 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -1221,6 +1221,22 @@ static void write_abort_file(int resdirfd,
 	}
 }
 
+static void oom_immortal(void)
+{
+	int fd;
+	const char never_kill[] = "-1000";
+
+	fd = open("/proc/self/oom_score_adj", O_WRONLY);
+	if (fd < 0) {
+		fprintf(stderr, "Warning: Cannot adjust oom score.\n");
+		return;
+	}
+	if (write(fd, never_kill, sizeof(never_kill)) != sizeof(never_kill))
+		fprintf(stderr, "Warning: Adjusting oom score failed.\n");
+
+	close(fd);
+}
+
 bool execute(struct execute_state *state,
 	     struct settings *settings,
 	     struct job_list *job_list)
@@ -1268,6 +1284,8 @@ bool execute(struct execute_state *state,
 		close(timefd);
 	}
 
+	oom_immortal();
+
 	init_watchdogs(settings);
 
 	if (!uname(&unamebuf)) {
-- 
2.19.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-04-11  9:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11  9:40 Petri Latvala [this message]
2019-04-11  9:44 ` [igt-dev] [PATCH i-g-t] runner: Make sure oom-killer doesn't kill the runner Chris Wilson
2019-04-11 13:22 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-04-11 16:50 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190411094012.4288-1-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox