From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16FD0C4332B for ; Thu, 19 Mar 2020 13:37:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D146020787 for ; Thu, 19 Mar 2020 13:37:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="ER44yHPU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D146020787 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 57D016B0003; Thu, 19 Mar 2020 09:37:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52D116B0005; Thu, 19 Mar 2020 09:37:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 443816B0006; Thu, 19 Mar 2020 09:37:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 30B8E6B0003 for ; Thu, 19 Mar 2020 09:37:49 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D24894DC0 for ; Thu, 19 Mar 2020 13:37:48 +0000 (UTC) X-FDA: 76612214616.22.dime86_9f02e1719939 X-HE-Tag: dime86_9f02e1719939 X-Filterd-Recvd-Size: 4271 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Mar 2020 13:37:48 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id j2so2985184qkl.7 for ; Thu, 19 Mar 2020 06:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bzGn7Gk/5VEP8iiNf0RI2RP1uEYAlH6euk3f2j6y39w=; b=ER44yHPUvm/hh/WnOk5P3sKimpp5bJ0Uzl0FlbO+RjM+gRbmYvwO6LNLLbvRfiXf/X 51vNNRNLuVFdMpNJcVZPYBQGp/ClvS5o8pckbAdvDIQxMXJjD8nZF9zFfm4ZMDJ7H/ql FhLuIMRYSizr3PcZ2j0HVcE27h58yp1fN9+qv3OeS5KiJXC1Vm0QHlRkKSg05kIwuTUI 494p/5zlzQZWVLByzpLFfG8daRQKP360jXQcdphoiuMs5RG7AgpMD3EwrNe6Sva/Oz0Q 09MHPwzORFjJwSJ+j+f3xzh3iIorGb0sqm31so/eylT4HNZ+zz2YdgQI6Ff2hBfZM93p u7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bzGn7Gk/5VEP8iiNf0RI2RP1uEYAlH6euk3f2j6y39w=; b=Tmw3ft5Lw+XTwlyFNY2Jb6txXb+YM2nxuNByZ572pLEyUr/N0uqE/bY9alBXm3duDs rfNXjwg0JmtXWdhKeHcQSrs1CgBhswm8G1b1w7bsqqXXmOc2cIbNaEfIEOt2yAUgODKd mzzcB8R4/wnRQSx8H1TQZOmM+VDPIPFwFHahAXqnx5JC0IfTKXeLBFCzbNr+yDL1xmTW xwxrYEVeuaMUO6PcYlQCcikbZu7B5enq7kaDXOXStN512jsxuEvtuROgTqMQ96dKmHp/ 54PH43o8RqgUtQ37UaCKvYRs4kJswj1KOjVrMdEPg5fMSL94N+YD1K5SdaNtqa+3wX7x CmGQ== X-Gm-Message-State: ANhLgQ1kkVvo/AFlihvIGr6Fu1A9eaDXtlDol5tWU6hiDNi4VgLaNAGm du+BUjVSaRK+1nZSP1NXt3lXbQ== X-Google-Smtp-Source: ADFU+vseiJmYb7eviCZYeaPPVuhz439HV1+w/jx7c51VK1F3Gt6H+2pCESvAHgNnp+uVwYyN0c/TbQ== X-Received: by 2002:ae9:ef92:: with SMTP id d140mr2836542qkg.412.1584625067514; Thu, 19 Mar 2020 06:37:47 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:a9a9]) by smtp.gmail.com with ESMTPSA id v1sm1532669qtc.30.2020.03.19.06.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 06:37:47 -0700 (PDT) Date: Thu, 19 Mar 2020 09:37:46 -0400 From: Johannes Weiner To: Roman Gushchin Cc: Andrew Morton , Michal Hocko , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: memcg: make memory.oom.group tolerable to task migration Message-ID: <20200319133746.GA187654@cmpxchg.org> References: <20200316223510.3176148-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200316223510.3176148-1-guro@fb.com> 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: On Mon, Mar 16, 2020 at 03:35:10PM -0700, Roman Gushchin wrote: > If a task is getting moved out of the OOMing cgroup, it might > result in unexpected OOM killings if memory.oom.group is used > anywhere in the cgroup tree. > > Imagine the following example: > > A (oom.group = 1) > / \ > (OOM) B C > > Let's say B's memory.max is exceeded and it's OOMing. The OOM killer > selects a task in B as a victim, but someone asynchronously moves > the task into C. mem_cgroup_get_oom_group() will iterate over all > ancestors of C up to the root cgroup. In theory it had to stop > at the oom_domain level - the memory cgroup which is OOMing. > But because B is not an ancestor of C, it's not happening. > Instead it chooses A (because it's oom.group is set), and kills > all tasks in A. This behavior is wrong because the OOM happened in B, > so there is no reason to kill anything outside. > > Fix this by checking it the memory cgroup to which the task belongs > is a descendant of the oom_domain. If not, memory.oom.group should > be ignored, and the OOM killer should kill only the victim task. > > Signed-off-by: Roman Gushchin > Reported-by: Dan Schatzberg Acked-by: Johannes Weiner