From patchwork Fri May 25 12:19:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10427185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB2AB601D5 for ; Fri, 25 May 2018 12:19:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B221029674 for ; Fri, 25 May 2018 12:19:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6B542969A; Fri, 25 May 2018 12:19:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E7CB29674 for ; Fri, 25 May 2018 12:19:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A78AD6E1D3; Fri, 25 May 2018 12:19:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7770C6E1C6; Fri, 25 May 2018 12:19:38 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 11841313-1500050 for multiple; Fri, 25 May 2018 13:19:31 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Fri, 25 May 2018 13:19:30 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 25 May 2018 13:19:28 +0100 Message-Id: <20180525121929.10112-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.0 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH i-g-t 1/2] lib: Prioritise oom targetting our children. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We are not nice parents and would sacrifice any one of our children so that the core process can report the failure neatly. Signed-off-by: Chris Wilson --- lib/igt_core.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index e292ca24c..2bee0831b 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -564,17 +564,27 @@ static void print_usage(const char *help_str, bool output_on_stderr) fprintf(f, "%s\n", help_str); } - static void oom_adjust_for_doom(void) { + const char always_kill[] = "900"; /* leave room for children! */ 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)); close(fd); +} +static void oom_adjust_for_greater_doom(void) +{ + const char always_kill[] = "1000"; + int fd; + + fd = open("/proc/self/oom_score_adj", O_WRONLY); + if (fd != -1) { + igt_ignore_warn(write(fd, always_kill, sizeof(always_kill))); + close(fd); + } } #ifdef HAVE_GLIB @@ -1618,7 +1628,7 @@ bool __igt_fork_helper(struct igt_helper_process *proc) igt_assert(0); case 0: reset_helper_process_list(); - oom_adjust_for_doom(); + oom_adjust_for_greater_doom(); return true; default: @@ -1721,7 +1731,7 @@ bool __igt_fork(void) test_child = true; exit_handler_count = 0; reset_helper_process_list(); - oom_adjust_for_doom(); + oom_adjust_for_greater_doom(); return true; default: