Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp664886ybg; Thu, 19 Mar 2020 06:39:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu/0IX3w6HWRCA31i3pXJECB5DuO7hT1UX9oJdOBsbifnBGsPqY7Q8xHupK7YC+FgUdjw59 X-Received: by 2002:a05:6830:110c:: with SMTP id w12mr2157832otq.175.1584625155156; Thu, 19 Mar 2020 06:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584625155; cv=none; d=google.com; s=arc-20160816; b=ZTlzi09tDtk5zy0wFCMDVWN26t4yPaTjphWT5hDWzeWTGQufuKEnLQEPR+bEsj9K6o eSgw/RW7IQDMLmipBqesl+CmBQfDPQ/cljf3065mceWL7wC2QU2jtTKGh7oCs+1VnvRV RwNL//mZit5atxC695LNSSaLXHiEbRSY74azCVWWmVmcMjUj6KGS0EKtbR0cHltfYJNj NCNw9+HUGLcPV1aO8js3WHgrLymtdGaj4s/3KWzTwdz9FgsIs1ggzlL7CRifdo1M0MMo KyZCkxEO2rbUy6igVx9KT4szx5EAxFVFcG1wH5p/iCS3OKX6ThtfgxAlH0il82n6ylwS kFxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bzGn7Gk/5VEP8iiNf0RI2RP1uEYAlH6euk3f2j6y39w=; b=HPVohNWTNjgEGIcJopH13fjcrCPaB5i0Hr+H1EG97VDQfikM6C9rlGY/vIxzjeQjem ANB000lfgLxrnMgY/JQM1oJn2EH4Ri/4rWCUwtaWUexD1P9ZulT3YkSB/1/u53kq5glY Ph+EaaT4evmjBaRsx5U80vEzcGgzr73uHu68EM5MfjnHrDozTjIbdUJ7dZS1R/Ye9ewf DjCg98qoJ1jyfuLZV8Msbp50Y/ACJTAyLIJsSTeGzsIuIT0c9zjOrIqQQ6+NS01Tsug6 ZVD52ezcTEm31ZzCWFTavjS1xQEqCd6vqI1poIlHh93YioEWhDouQg+XQKw04bWdregd xuhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=ER44yHPU; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si1244145otn.120.2020.03.19.06.39.03; Thu, 19 Mar 2020 06:39:15 -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; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=ER44yHPU; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbgCSNht (ORCPT + 99 others); Thu, 19 Mar 2020 09:37:49 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:41802 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727415AbgCSNhs (ORCPT ); Thu, 19 Mar 2020 09:37:48 -0400 Received: by mail-qk1-f194.google.com with SMTP id s11so2976010qks.8 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=ClJ7Nr+ixYySBUMOMvd7hAE9FY0fzqSNPuYvIf14nI8jnWT/3TXgIbaU074uipLu89 rYEEls+X0Rz5Cpu8zSpXyq6rokcwBn25E6L0Ttq6tvzs6NzLT9olAnkrf/k5UaKvjuja aVRfFFVcR0TFtk1VQ/X1dO19ce0qhdeBIaSVXfV5k+xGuIi4SzKTr3MStA+6beUg1nxT ai4jcEK9QKKIFVUSnZsAJ7pfb3QjAFH8ETNtuEB640tk9lTN101BjnVPNQTh02xV3ArL 4bAe/vv2zk6UifdYI8PjQSZRLofI6GCpuCuSkc2YkbisvSEWCUbzLMSSwQh8TueWCMmQ pcEg== X-Gm-Message-State: ANhLgQ1VU0Epo0EUjdLMeD1MsJTon9W+rxznF2MDcKYNkrtsAaJqWulD lEjFIqPQ6BcYy9ow+6j6trQ/lg== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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