Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2197620ima; Mon, 22 Oct 2018 06:04:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV63xrLjJGUaSt+HkbRp+jiP0+HmbyCu9CrLjXAO29tNT6jnLxk5+wcxQ06IT0G2ZpBF3Gp0g X-Received: by 2002:a63:e04d:: with SMTP id n13-v6mr23877606pgj.426.1540213458918; Mon, 22 Oct 2018 06:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540213458; cv=none; d=google.com; s=arc-20160816; b=Fq2lND/eRSYTWJvNkMyI34kHi3h2hxdknPgAEvUdRP96+oZRGNiQI1wiituJLkEPx3 PN/e3SCBBo7Fsm1wXyPQqBcFuz1HUPRsDB11OQiObW+/sTGcrQrHviH1mMEfZXrLJIm/ Pu9UiGJhch1Mk+8PfItuGIkJ2mn7za+yBLA225WukzQIswNF85rTZNpL9/GXhJYh7Ita r6SU/6i2lts1PkIdTWejI/Qj6mSe5Zb9TRIaNGZ3X5DDAB3sJxSFoL0n5euAsAMfQ40A PVLjL6Ae1bfQYSBUYoQF3Yi+7KvZ6E139Yfe2N1Gm1aD+MSJdOJLE0Cwh6dp/qb5+jAt V5Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZlZ/q+BwM48K+EMZf5n3TfMmAYpunDeEBHn7iqS1uVA=; b=RdUubzGnI9cPxBt7v2ZxJUVoUNk/vRjG/1aeI0QYwoQvW/Gp3EssyZA8DKSEnlfEyX TIg6RpHaYXXbER5mIf5YWnUsc6gwo7hXi8QMn8cvyURGBB7icyz2r5v1VJZ0I81lTr1q tm48SLvjuMxkMWHPcAFeJe6ZqQLvb5losAXWqpOGQCCjLkTSIUZRCYs10AVJKuV2RIbF e9jRX/H2OrUfZIpW/FtmonlBHrIcvLQOCIwt8a2IlOnylWT5LjN/62g9+t8rLFCRjMMM YpQRUfpe3sv/IkJkrgtPNUOQuVNU2fA1w0oHBl7Ycu2kvrVnW3M4C9sC4K/V01buOZc6 jgwA== 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 u8-v6si3314321pgo.224.2018.10.22.06.03.59; Mon, 22 Oct 2018 06:04:18 -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 S1728616AbeJVTeq (ORCPT + 99 others); Mon, 22 Oct 2018 15:34:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:56268 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726946AbeJVTep (ORCPT ); Mon, 22 Oct 2018 15:34:45 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181022071323.9550-2-mhocko@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); -- 2.19.1