Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp253987imm; Mon, 9 Jul 2018 00:48:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeUkkDalkigwFSo8V1Sm548LokWw3OZyHhnWwjFewJihN0cM++LRhGyewMwvtPj2APHG3Re X-Received: by 2002:a62:2541:: with SMTP id l62-v6mr20403760pfl.0.1531122487642; Mon, 09 Jul 2018 00:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531122487; cv=none; d=google.com; s=arc-20160816; b=E5W3jlp1dPD51focvuH4kx+n9sFdOrvbnkHjSzljVcY9am5xJp+hbb5cHLJG9zV70B 33jhOqFqDAZQ2DsVFQlPNaHZQLGSSHYaDvvYRJeoMaS1hHp2ZHA2eRhtKc2XIge0olAa Yqu3foFokbDFXHWNoOHIo1VJDOe70Z89wNnU7nYDSQh47FrTpWk+lvqwthulIQ3vUOvz 4M+RXZ1RD0bwZs+gWdjSpN/3xU9ZC54WpdQt19Ypco52MLKmG+7sUjWmlw7XJ5HH+kD2 uLBapcP9lU8g10jfTHsWw5prWFDo8gJQkBBkshTOE22FRegQvJ7IuLINrj5mq9OT2Mde 3EBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZH7enT3vT1Ar8WueFAqatFtw3lASThB9hmJKWhdyUrU=; b=IlyAyqh5y1ZuKlEfo0rEvmt1jnB+vMRdzMqANEXLJy0azxrHf6yfvsq6CiT3zlOyKC +F/zGXeM1mkT3snPSFlZ4q2IBHyzhkSdb8d5y7kr83SmqzX9ZK6AinY7Bw5ZNTSL92io lDpMmnHneczYGuT9G3iQ5qJ4IIvkck7d+6ZMp/NiolIpm2esiLscxLhIYx8V3UvsJehF hrJTfK8JHeRtcThDApWNhsKGH3B9c9cwAPVoLvBBsIjaW6ASgwgHktfYB+inM5M4VwU3 BikAKRdcCZtWbBJrfMCiL+ikMLTs7OSMoSmUOc4WHC4XAeSPUksM7BxNhHLc5WU0ilpR AjqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65-v6si10784200pld.395.2018.07.09.00.47.52; Mon, 09 Jul 2018 00:48:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932422AbeGIHrN (ORCPT + 99 others); Mon, 9 Jul 2018 03:47:13 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:34297 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932225AbeGIHrM (ORCPT ); Mon, 9 Jul 2018 03:47:12 -0400 Received: by mail-ed1-f65.google.com with SMTP id d3-v6so13179327edi.1 for ; Mon, 09 Jul 2018 00:47:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZH7enT3vT1Ar8WueFAqatFtw3lASThB9hmJKWhdyUrU=; b=FQcdwaXtB6jSd3JOEEOMHKOIhWQRHKP7ucMpKioIebZzaTkmslnVETO7+3CSdT9LV+ EzEa52d1hirXjgMAhabqJcahg9f2NCnzTmmxZ80taR7FPgCQL3Ub3M3QioMbp7+zE/Mg xvHEy+fYBhXjHcpvaUb5CmYNMzVnsoV8Znqg0jFOEmbYRKTrTCCSuk1JeDfmjdpSOQUx 6CH6WrmzPJirml/kx9/D2AOx9S5ElSUzROsokjtZD4slQ/Twi22OWzNHqnd4l+PKsv0R 367tw5X5NHbub9g5rkNd0YvRgv+h/cgtWoWrzKC1DeLU/epcabuAwj0KBYdsaS16Efo8 A1wQ== X-Gm-Message-State: APt69E3/xaKyBFmm5r4eDMZogzFvCVti0e0ncn7LdASgnzb1cVDaj9qg Dlvein68Ky1HUVnu65ALNg0= X-Received: by 2002:a50:b410:: with SMTP id b16-v6mr9280230edh.190.1531122431577; Mon, 09 Jul 2018 00:47:11 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id e20-v6sm6235649eds.20.2018.07.09.00.47.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 00:47:10 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Tetsuo Handa , David Rientjes , , LKML , Michal Hocko Subject: [PATCH] mm, oom: remove sleep from under oom_lock Date: Mon, 9 Jul 2018 09:47:06 +0200 Message-Id: <20180709074706.30635-1-mhocko@kernel.org> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko Tetsuo has pointed out that since 27ae357fa82b ("mm, oom: fix concurrent munlock and oom reaper unmap, v3") we have a strong synchronization between the oom_killer and victim's exiting because both have to take the oom_lock. Therefore the original heuristic to sleep for a short time in out_of_memory doesn't serve the original purpose. Moreover Tetsuo has noticed that the short sleep can be more harmful than actually useful. Hammering the system with many processes can lead to a starvation when the task holding the oom_lock can block for a long time (minutes) and block any further progress because the oom_reaper depends on the oom_lock as well. Drop the short sleep from out_of_memory when we hold the lock. Keep the sleep when the trylock fails to throttle the concurrent OOM paths a bit. This should be solved in a more reasonable way (e.g. sleep proportional to the time spent in the active reclaiming etc.) but this is much more complex thing to achieve. This is a quick fixup to remove a stale code. Reported-by: Tetsuo Handa Signed-off-by: Michal Hocko --- mm/oom_kill.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8ba6cb88cf58..ed9d473c571e 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1077,15 +1077,9 @@ bool out_of_memory(struct oom_control *oc) dump_header(oc, NULL); panic("Out of memory and no killable processes...\n"); } - if (oc->chosen && oc->chosen != (void *)-1UL) { + if (oc->chosen && oc->chosen != (void *)-1UL) oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : "Memory cgroup out of memory"); - /* - * Give the killed process a good chance to exit before trying - * to allocate memory again. - */ - schedule_timeout_killable(1); - } return !!oc->chosen; } -- 2.18.0