From patchwork Mon Oct 22 11:16:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10651931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CE281822 for ; Mon, 22 Oct 2018 11:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35B76212D8 for ; Mon, 22 Oct 2018 11:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28A8D2893F; Mon, 22 Oct 2018 11:16:40 +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 B6BE6212D8 for ; Mon, 22 Oct 2018 11:16:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7D6E6B0006; Mon, 22 Oct 2018 07:16:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C2BA56B0007; Mon, 22 Oct 2018 07:16:38 -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 B1B686B000C; Mon, 22 Oct 2018 07:16:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 59D326B0006 for ; Mon, 22 Oct 2018 07:16:38 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id v15-v6so24737743edm.13 for ; Mon, 22 Oct 2018 04:16:38 -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:date:from:to :cc:subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=ZlZ/q+BwM48K+EMZf5n3TfMmAYpunDeEBHn7iqS1uVA=; b=J+eDJqGitHB8m4kNLdT8nDZJuAnBtLGHdyfds8jCPmuzfslSwlSVhBIN7vmZ45l0HP VKJmUDiJp79lzGMuk/kksrTYWeE8URh/3H4WJuKf3bOh80JYxjur3qemMxvbzYOCLvWn LdpIuZw1F+1OrpUggpr1a9CTVSDZ/U0P2058sBcsjAHHkOxYMxPOQcnn7e1s+SfIqZ4O cdYkbZCIqpt9UxpUHriML14f/d9HAe48cP6qK3Zc2KVV6i20FtTVcqCDQNlxowNfp+DN Of2Xv6P5nxHJcdiO0QjGww03ZM9dgmJ74F43npYpa1qR0AVQKQ3dVm+85IxoNeB1c3Vw kEYw== X-Original-Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: ABuFfojfeuus/FjvOso+c4hiy9pHomJfK1/VT2O88JgzNcTd835WHL/0 +3veBDXUUcR2XcRXBevKk28kabpa4/TzwLjMm4VVkLT2BxLt0Xp+4TxNZ+tfpe4NSXPsaN3moZc frONGvS/RHl0Z5rHNekqE1wlrZTnX1qKrH0+oHPdJRE3mEz4wUCOSSXFRq0SpzGY= X-Received: by 2002:a17:906:64cb:: with SMTP id p11-v6mr249742ejn.181.1540206997884; Mon, 22 Oct 2018 04:16:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV6337GXyFfcScNBcFd1qQegne+X8dFrIISp3h2cYcoYM4oITHZh8Ww7dENKByoZdH9FKGlvU X-Received: by 2002:a17:906:64cb:: with SMTP id p11-v6mr249720ejn.181.1540206997193; Mon, 22 Oct 2018 04:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540206997; cv=none; d=google.com; s=arc-20160816; b=uE+r6exkXmHO0pR4ZrttLo9hmaUnYByUVMdSHY0dGtxWjrLR+iwGZG8DXBj/G0yEKW 4LlOZxog4e2pzFzEvZcEeqThB5qZGwdTylC+hoHUzkB9k+4B4/nSwuENBs7oXJKjUOLC jLARtEAlutKx5W3bbFNYLhj28SgV2mpwGtxWLAHJJphnHlNeMBU/SEz2UY09i75qDTBd CmzYEHYjgO0Ry4U/OKC6Ofb0U/H8OSuSRm/mwt0HoK3BajI7oaqSYlcTher/iYjW3LJz VFkblPmdls1bnghSLXxMW+Paky9FE9Dw88ya/9pBVNxm7zXR+nifb2u/qu10MRWkk9wY yBzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date; bh=ZlZ/q+BwM48K+EMZf5n3TfMmAYpunDeEBHn7iqS1uVA=; b=wUcYVN+OIUvN1NH+YlFc2daple8ivsJKs5D5lSAnNCTGT+uN+VAAklRdl+e0lRZGuF zKljpjvbdeZU2fxhWgTGCVl46ZVRqPa1m+GzIIQoQ/j5WI3n5TL/zs5UHth+n4+GAYd7 H4nCdRE1L0ZeT8XFoAPEAx6zVPcmDPYuWE7SSw7uC1kzQbftj1lDRk39VTUT2ik1YjxI 4Zq3oJVODF7FJmB3Xy0XDmpPuJ9PusKikWVcc5qOmOJJgYWxKuZtWJ0jvVFdybXrrVns ED43vH1sL9/mPueLMqAMD5pYk+UaXFmhQ2F7FjUZIZVBqBVQEPT06BrHkH+pD0qJ+0Fq aQXw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id f20-v6si3637303edt.166.2018.10.22.04.16.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 04:16:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C5BF9AECD; Mon, 22 Oct 2018 11:16:36 +0000 (UTC) Date: Mon, 22 Oct 2018 13:16:36 +0200 From: Michal Hocko To: linux-mm@kvack.org Cc: Johannes Weiner , Tetsuo Handa , David Rientjes , Andrew Morton , LKML Subject: [RFC PATCH v2 1/2] mm, oom: marks all killed tasks as oom victims Message-ID: <20181022111636.GA18839@dhcp22.suse.cz> References: <20181022071323.9550-1-mhocko@kernel.org> <20181022071323.9550-2-mhocko@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181022071323.9550-2-mhocko@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Updated version From fdd46ec5dbc0cf571c5a2b9e23a021e0c46b4641 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Mon, 22 Oct 2018 08:52:33 +0200 Subject: [PATCH 1/2] mm, oom: marks all killed tasks as oom victims Historically we have called mark_oom_victim only to the main task selected as the oom victim because oom victims have access to memory reserves and granting the access to all killed tasks could deplete memory reserves very quickly and cause even larger problems. Since only a partial access to memory reserves is allowed there is no longer this risk and so all tasks killed along with the oom victim can be considered as well. The primary motivation for that is that process groups which do not shared signals would behave more like standard thread groups wrt oom handling (aka tsk_is_oom_victim will work the same way for them). - Use find_lock_task_mm to stabilize mm as suggested by Tetsuo Signed-off-by: Michal Hocko --- mm/oom_kill.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index f10aa5360616..6be22a0b0ff2 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -879,6 +879,7 @@ static void __oom_kill_process(struct task_struct *victim) */ rcu_read_lock(); for_each_process(p) { + struct task_struct *t; if (!process_shares_mm(p, mm)) continue; if (same_thread_group(p, victim)) @@ -898,6 +899,11 @@ static void __oom_kill_process(struct task_struct *victim) if (unlikely(p->flags & PF_KTHREAD)) continue; do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, PIDTYPE_TGID); + t = find_lock_task_mm(p); + if (!t) + continue; + mark_oom_victim(t); + task_unlock(t); } rcu_read_unlock();