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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 202FFC10DCE for ; Wed, 18 Mar 2020 12:32:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D597C20767 for ; Wed, 18 Mar 2020 12:32:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D597C20767 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 85F296B000D; Wed, 18 Mar 2020 08:32:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 80FF36B000E; Wed, 18 Mar 2020 08:32:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 725406B0010; Wed, 18 Mar 2020 08:32:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 58A526B000D for ; Wed, 18 Mar 2020 08:32:06 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1B998180AD820 for ; Wed, 18 Mar 2020 12:32:06 +0000 (UTC) X-FDA: 76608420252.10.ice43_699f8a3d9c53a X-HE-Tag: ice43_699f8a3d9c53a X-Filterd-Recvd-Size: 4481 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Mar 2020 12:32:05 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id n8so3110938wmc.4 for ; Wed, 18 Mar 2020 05:32:05 -0700 (PDT) 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=K+CS+21zAUZ2xO+PTmoIDEUvzM3H5I3+5QSeJVuTL7A=; b=JHDb3jesVsPNwpFgmhQ/fGEIZpL/173xCemvQA6pQepk/oCEZ4Uux0lxD8SAzgXUTM BZGOZv1rdnWi9wj2Gs+ObQOVpU6hxIlVtkvHJr3z3rFOxnkCJMX+6klfgfbM9H9GHEk1 l9Ek+FBDgF2UvJI5R5teW+rw85uVyz5lZYxXY9VR2s1yVlS0ChBso3+XLjV/ByJ7E/sI j/vjs+vQzQkMbHSQt+iSLpneXpggRZNTZy48rYvXbrE1wdFCsYwik30KaY+NQWP/AXsl KQ7hTlHLa4OHG9m0VJDO89RDVbA6jXkZuPAwGd2WxbUXI3slTtHu+OYODwdVAj20ZN0B kZmA== X-Gm-Message-State: ANhLgQ0W+PK/+fbrveKKpFbkCzXE8qyU+BZIhLhhqRZYlSUh3iMjQqqA TwZvvGl+zuVbkIBLSTf5nL8= X-Google-Smtp-Source: ADFU+vuAQsgX66PrkR6JCtqUCcdlrkbBb7+WbC0oVYs93TcsdO4r5YEBTFxFaosH22KxzSgv7jDmXA== X-Received: by 2002:a1c:68c2:: with SMTP id d185mr5133224wmc.150.1584534724510; Wed, 18 Mar 2020 05:32:04 -0700 (PDT) Received: from localhost (ip-37-188-180-89.eurotel.cz. [37.188.180.89]) by smtp.gmail.com with ESMTPSA id u17sm9248479wrm.43.2020.03.18.05.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 05:32:03 -0700 (PDT) Date: Wed, 18 Mar 2020 13:32:02 +0100 From: Michal Hocko To: Roman Gushchin Cc: Andrew Morton , 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: <20200318123202.GL21362@dhcp22.suse.cz> 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 16-03-20 15:35:10, 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 After the follow up discussion I do agree that this should be sufficient for now. Acked-by: Michal Hocko > --- > mm/memcontrol.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index daa399be4688..d8c4b7aa4e73 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1930,6 +1930,14 @@ struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, > if (memcg == root_mem_cgroup) > goto out; > > + /* > + * If the victim task has been asynchronously moved to a different > + * memory cgroup, we might end up killing tasks outside oom_domain. > + * In this case it's better to ignore memory.group.oom. > + */ > + if (unlikely(!mem_cgroup_is_descendant(memcg, oom_domain))) > + goto out; > + > /* > * Traverse the memory cgroup hierarchy from the victim task's > * cgroup up to the OOMing cgroup (or root) to find the > -- > 2.24.1 -- Michal Hocko SUSE Labs