From patchwork Fri Oct 22 08:10:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12577377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66992C433FE for ; Fri, 22 Oct 2021 08:11:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F22DA610EA for ; Fri, 22 Oct 2021 08:11:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F22DA610EA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6DAFD900003; Fri, 22 Oct 2021 04:11:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68970900002; Fri, 22 Oct 2021 04:11:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57778900003; Fri, 22 Oct 2021 04:11:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 47BC1900002 for ; Fri, 22 Oct 2021 04:11:10 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 04E0418343F4C for ; Fri, 22 Oct 2021 08:11:10 +0000 (UTC) X-FDA: 78723353100.39.3F96FBC Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by imf28.hostedemail.com (Postfix) with ESMTP id 6BCEC900009E for ; Fri, 22 Oct 2021 08:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:Subject :From; bh=I94JF+1Ykb3U0G26LvnbC6EWbDpqVzT8bJcMB6mWzrA=; b=EmZl+hgNLkbPo1rB/Ms dotFtuMe+e6rzOv5Pz5/dmgyjg9fh/DFh2nJnICgZqxYqgNnjzLeZtfoXSMLl8vXc8eAm2Inc4c/z /bxHuu8lQdcxpbOB/W0t/hoxUrq6uHRKTBV2ZFvhi8q1U8hqxCRO46JREZtsA3uq+vZgLkaG0xc=; Received: from [172.29.1.17] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1mdpdl-006oMy-HF; Fri, 22 Oct 2021 11:11:01 +0300 From: Vasily Averin Subject: [PATCH memcg v2 0/2] memcg: prohibit unconditional exceeding the limit of dying tasks To: Michal Hocko , Johannes Weiner , Vladimir Davydov , Andrew Morton Cc: Roman Gushchin , Uladzislau Rezki , Vlastimil Babka , Shakeel Butt , Mel Gorman , Tetsuo Handa , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org References: Message-ID: <21d79b86-476c-a8f2-e950-2339606f1253@virtuozzo.com> Date: Fri, 22 Oct 2021 11:10:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6BCEC900009E X-Stat-Signature: msktkjkozwgn3mg4jwzyhbxjnjkq77qd Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=relay header.b=EmZl+hgN; dmarc=pass (policy=quarantine) header.from=virtuozzo.com; spf=pass (imf28.hostedemail.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com X-HE-Tag: 1634890269-99411 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: Memory cgroup charging allows killed or exiting tasks to exceed the hard limit. It can be misused and allow to trigger global OOM from inside memcg-limited container. On the other hand if memcg fail allocation, called from inside #PF handler it trigger global OOM from inside pagefault_out_of_memory(). To prevent these problems this patch set: 1) removes execution of out_of_memory() from pagefault_out_of_memory(), becasue nobody can explain why it is necessary. 2) allows memcg to fail the allocations of dying/killed tasks. v2: resplit, use old patch from Michal Hocko removing out_of_memory() from pagefault_out_of_memory() Michal Hocko (1): mm, oom: do not trigger out_of_memory from the #PF Vasily Averin (1): memcg: prohibit unconditional exceeding the limit of dying tasks mm/memcontrol.c | 27 ++++++++------------------- mm/oom_kill.c | 23 ++++++++++------------- 2 files changed, 18 insertions(+), 32 deletions(-)