From patchwork Mon Jul 9 07:47:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10513785 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 5D1FD60318 for ; Mon, 9 Jul 2018 07:47:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6EE287FA for ; Mon, 9 Jul 2018 07:47:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D987289F1; Mon, 9 Jul 2018 07:47:15 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D2B9287FA for ; Mon, 9 Jul 2018 07:47:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 887836B0010; Mon, 9 Jul 2018 03:47:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 811116B026E; Mon, 9 Jul 2018 03:47:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B1816B0277; Mon, 9 Jul 2018 03:47:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 079A86B0010 for ; Mon, 9 Jul 2018 03:47:13 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id v26-v6so521105eds.9 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-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=ZH7enT3vT1Ar8WueFAqatFtw3lASThB9hmJKWhdyUrU=; b=hRbWDfYYb8MLJqW+JijuEvXOnPYU0rhtMuAG9vcHZ50PL1PlHJHkjrtVeJJaf+Pj6y CF/1Ln99vsic6yOH02lNU3575Df/KiYB2W0uN+R3KSWELJq0QAQ/DEaUb/4uEW4cVbu5 CJmRrOixPlKlN8To83aYreyJxs1PI8AJIiO9orrnno5IDRmpC05BJzXFWR20/5GclanJ Z8VakljbX5i1Pb/rf3f1weEqfsFCEy40YmB4+QCmtFNE+FzsLvEi57pHWEr9G68OtrGP zfxUbpHSBpOgHx025OIbZmOG1maFIhas2omZsIcmBOD7wDLNwyH9a/dA3PXmnUHeioiE 3iDw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: APt69E2OWm5kXdugwZOlGmqvF2QK6Rv1KKQXmIszQzn2Uvm3OLTLThas Hex2FBoxosvnk+bwPGofPbPog/FZyyF4XIEWAuazAFUyE5YO1vFZLNd/5U0drmdYyMPOBO0JCCg hYqOk3GMybzlvT+H0W9hwW7CtpCjUqko8foCvTZBWyLa/dVTUW5q6fl0ItQ/EK6rvJN4K8yQmqI iC3dJVdybEbyycBvMzw4DwfAsX9tiwjBAniWR+E8lqro2el7hQBdxBtoyPZznWDAxEUkeewiyNO gNYxtxH4X1kgqwjF7pbf4xMFhu8JYqhjxV97tRrS260kfEp/rpfKJiYWWGKkKJAUSq1tz9bENDv 9eo6Ltd7VQVM/HJKIfgXqMb8dmSu08iDdL0/8F2v2REcZxA3Y3YoEo2NWPkQ4af74mMZNtPzEA= = X-Received: by 2002:a50:a446:: with SMTP id v6-v6mr20615220edb.237.1531122432592; Mon, 09 Jul 2018 00:47:12 -0700 (PDT) X-Received: by 2002:a50:a446:: with SMTP id v6-v6mr20615185edb.237.1531122431867; Mon, 09 Jul 2018 00:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531122431; cv=none; d=google.com; s=arc-20160816; b=DyDJwtYZU34pYRzuvMU1VV+zgQd4om3De1MyjTsFLz0Ld9ysne92DkI3GrmbQyifA1 EVGiu4bDZu8xgfvIlvQsVVW0VA2vN8+h0T4TfUueZgoWyyl4u3/jg7APQwSHFhalpq7w I7+W7DsWjPi8rH+ymbnI+YS1IaSzwD9t6X9d4N5VuJcwR0arD4/ewUmr5PlsCgeVxGiu OQt1zTHXdCSv6CTIL0FrOLM0IM6lp0xfsrIntrRQMSMpRw4DOqYKCSCd9+rF73QCdOa2 RX+peVOQoes+p2P4AHs+4k0zdYWziFJUQhC7qnO7WAJU8R40aZULoNU+O2ljBWvdyo5w Uwxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=ZH7enT3vT1Ar8WueFAqatFtw3lASThB9hmJKWhdyUrU=; b=JIWUahHLfGlwbZFOxKqrNpUMCwCdjqTiBdovWb1+g4jWUYsThdcAR61vAiJoavzXCT uO3mgVTrsohkFLaQejHH+bp5QConWaya6qgGFRwlgn15Q8YNZpJiuLgEN94UfH16CL7Z YOuwgMNn4MKSiZsyoXkCMxBSg8cofty9palZViJm7ZPeyUsVGFm8IBgJZIeINgojwTkV VVqFx8rCg+Ph+wrWbNy4r/MDJXGVJUKzymKYN53IPjccUewsLIWDcx3pelqy3+GOJqVS iNkqoPwhWNYNJHsC1F3UrrRB1j8wZ7kXzgrqOEIaRYTnTGwLZLBzhSe5Oe6+dLdCi2FE /9+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i7-v6sor6611704edq.24.2018.07.09.00.47.11 for (Google Transport Security); Mon, 09 Jul 2018 00:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AAOMgpe+lYuDeuT4w/Y4cpotsv3872vZqikzG/aHOGvoKMZrVAR1aGMikVsH7GldHoZzCzGiYpSFGg== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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; }