From patchwork Mon Apr 27 15:17:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tim.gore@intel.com X-Patchwork-Id: 6281571 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1D4A7BF4A6 for ; Mon, 27 Apr 2015 15:17:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E87B20304 for ; Mon, 27 Apr 2015 15:17:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3EB69202F0 for ; Mon, 27 Apr 2015 15:17:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 522E56E1D5; Mon, 27 Apr 2015 08:17:54 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 25D276E1D5 for ; Mon, 27 Apr 2015 08:17:53 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 27 Apr 2015 08:17:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,657,1422950400"; d="scan'208";a="562514374" Received: from tgore-linux.isw.intel.com ([10.102.226.89]) by orsmga003.jf.intel.com with ESMTP; 27 Apr 2015 08:17:52 -0700 From: tim.gore@intel.com To: intel-gfx@lists.freedesktop.org Date: Mon, 27 Apr 2015 16:17:50 +0100 Message-Id: <1430147870-30875-1-git-send-email-tim.gore@intel.com> X-Mailer: git-send-email 2.3.0 Cc: thomas.wood@intel.com Subject: [Intel-gfx] [PATCH i-g-t v2] lib/igt_core.c : only disable low mem killer once X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tim Gore The call to low_mem_killer_disable(true) was being done from within function oom_adjust_for_doom. However, oom_adjust_for_doom gets called from 3 places. We only want the call to low_mem_killer_disable(true) to happen during common_init, so call it from here instead of from oom_adjust_for_doom. v2:Thomas Wood pointed out that the initial call to disable the low_mem_killer does not get made when we are just listing subtests; so I have qualified the call from the exit handler, which re-enables the low_mem_killer, with if (!igt_only_list_subtests()). For belt and braces I have also made low_mem_killer_disable idempotent, so multiple calls to disable or re-enable are safe. Signed-off-by: Tim Gore --- lib/igt_core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 7d04f2c..15f3922 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -396,6 +396,7 @@ static void low_mem_killer_disable(bool disable) /* The following must persist across invocations */ static char prev_adj_scores[256]; static int adj_scores_len = 0; + static bool is_disabled = false; /* capture the permissions bits for the lowmemkiller adj pseudo-file. * Bail out if the stat fails; it probably means that there is no @@ -408,7 +409,7 @@ static void low_mem_killer_disable(bool disable) /* make sure the file can be read/written - by default it is write-only */ chmod(adj_fname, S_IRUSR | S_IWUSR); - if (disable) { + if (disable && !is_disabled) { /* read the current oom adj parameters for lowmemorykiller */ fd = open(adj_fname, O_RDWR); igt_assert(fd != -1); @@ -421,13 +422,15 @@ static void low_mem_killer_disable(bool disable) igt_assert_eq(write(fd, no_lowmem_killer, sizeof(no_lowmem_killer)), sizeof(no_lowmem_killer)); close(fd); - } else { + is_disabled = true; + } else if (is_disabled) { /* just re-enstate the original settings */ fd = open(adj_fname, O_WRONLY); igt_assert(fd != -1); igt_assert_eq(write(fd, prev_adj_scores, adj_scores_len), adj_scores_len); close(fd); + is_disabled = false; } /* re-enstate the file permissions */ @@ -437,7 +440,10 @@ static void low_mem_killer_disable(bool disable) bool igt_exit_called; static void common_exit_handler(int sig) { - low_mem_killer_disable(false); + if (!igt_only_list_subtests()) + { + low_mem_killer_disable(false); + } /* When not killed by a signal check that igt_exit() has been properly * called. */ @@ -490,7 +496,6 @@ static void oom_adjust_for_doom(void) igt_assert(write(fd, always_kill, sizeof(always_kill)) == sizeof(always_kill)); close(fd); - low_mem_killer_disable(true); } static int common_init(int *argc, char **argv, @@ -653,6 +658,7 @@ out: print_version(); oom_adjust_for_doom(); + low_mem_killer_disable(true); } /* install exit handler, to ensure we clean up */