From patchwork Sat Oct 23 13:18:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12579611 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 5A731C433F5 for ; Sat, 23 Oct 2021 13:19:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C2A28610EA for ; Sat, 23 Oct 2021 13:19:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C2A28610EA 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 F2BFB940008; Sat, 23 Oct 2021 09:19:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDB8D940007; Sat, 23 Oct 2021 09:19:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF195940008; Sat, 23 Oct 2021 09:19:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id D0A92940007 for ; Sat, 23 Oct 2021 09:19:26 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8CB5D180ACEE6 for ; Sat, 23 Oct 2021 13:19:26 +0000 (UTC) X-FDA: 78727758732.38.AA7A0E8 Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by imf04.hostedemail.com (Postfix) with ESMTP id 232575000097 for ; Sat, 23 Oct 2021 13:19:22 +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=8UnnDRqw1eQkdViplyQTAIcge1Yu9hofXdZZzzuk4p0=; b=lrFx+iduxqiGySqgByy T0lniizeMHv+jFlBbTcd2TPw3FbwrptbgYNOU6RQPkGI+3qEEgilJNCu2is/MGSSvf2+RFMv71ppi 2oPcHrmYKnwRhHJ0ns9KfeowxcMTEUe3AXgBk2zuv+cnZ14iTt4Jy7+VFxIuXnYugopxOyL20Bw=; Received: from [172.29.1.17] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1meGvf-006vPv-Fv; Sat, 23 Oct 2021 16:19:19 +0300 From: Vasily Averin Subject: [PATCH memcg v3 0/3] 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: <20e50917-3589-bcb7-0174-b6fccfd15c66@virtuozzo.com> Date: Sat, 23 Oct 2021 16:18:58 +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: 232575000097 X-Stat-Signature: sqso6556mjz5p4fd3uqj531n4ytknpjk Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=relay header.b=lrFx+idu; dmarc=pass (policy=quarantine) header.from=virtuozzo.com; spf=pass (imf04.hostedemail.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com X-HE-Tag: 1634995162-676091 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: a) removes execution of out_of_memory() from pagefault_out_of_memory(), becasue nobody can explain why it is necessary. b) allow memcg to fail allocation of dying/killed tasks. v3: resplit, improved patch descriptions 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 (2): mm, oom: pagefault_out_of_memory: don't force global OOM for dying tasks 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(-)