From patchwork Sun Apr 12 14:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11484559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 572ED14B4 for ; Sun, 12 Apr 2020 14:04:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 193362063A for ; Sun, 12 Apr 2020 14:04:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vPEz/SDB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 193362063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 200CE8E0007; Sun, 12 Apr 2020 10:04:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A7A48E00D1; Sun, 12 Apr 2020 10:04:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C7F18E0007; Sun, 12 Apr 2020 10:04:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id E2B3D8E0007 for ; Sun, 12 Apr 2020 10:04:44 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9C59A87F3 for ; Sun, 12 Apr 2020 14:04:44 +0000 (UTC) X-FDA: 76699373688.30.hate41_295cabf7fcd5b X-Spam-Summary: 2,0,0,df7eca2159b5b601,d41d8cd98f00b204,laoar.shao@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3866:3868:3870:3871:3872:3874:4321:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12895:13069:13311:13357:14093:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:30054,0,RBL:209.85.216.66:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: hate41_295cabf7fcd5b X-Filterd-Recvd-Size: 4344 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Sun, 12 Apr 2020 14:04:44 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id cl8so1658243pjb.3 for ; Sun, 12 Apr 2020 07:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=eixCw1xPj/tb4QlnWiRc+JPy+QFvVa7Xxm9n1sZX7yw=; b=vPEz/SDBW0I9ywKFJJ8l5YRbowg1JkuJGzHS7nGpQhnVLyymZPd8I5TOkd5YtMzMfO n4vm2pj3iV2XOusfQc8+JuP32LnpBuPLmdJpD4UnE5+MPv41tW7wtzE6gikudcl50pr/ +Tt3kOmAaDGy0XkNlBQABv1yiWcXYAvkto9lbBEaGlUjXnOGUPKgwkHx5r0RgUpBdL/2 rvNISWVhVURTzop52NfSWJqkPlAys+gAhzs255X7PQztCj/fL+vYEo+W+ZTUYYVIBKM6 WgWG68v0xlxKFvaq7UqEZ+x1yNGFni8PO5pFJ5NsjVhKkbhXo5U7Jp5dJLSz4lxIndk4 WX6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eixCw1xPj/tb4QlnWiRc+JPy+QFvVa7Xxm9n1sZX7yw=; b=rPuvaEfXJdHT3VfViRr0Vq0ixddpOgFXgx0dokqq36tUIWMy0f3FdQ5S+Icjb796Wr okvkNn4SoqFOgtiPYWExXrBcN9siQ7rTmG2dYAoeGe9gE3Awv1AhJ1a2j9gl/kJ+AkjD Or6i/0rGID355PMMnhPzXcIZChzErYSf2/SXpelOQvh6ye9AATFgFYHcbrKaN22PR7Ss 8UoojgYGYLaaxsMEh2R2XzIttzTnF2SXA3m5OOydLdk5d42veyRBv77IN+NTibCQUzfJ IeT4920VXlL6Pq+scZ/dKSjWJiG2nykYXhPC3zK3QvCEQq+R8TGMyNXM4N1prZDKgEry ab0A== X-Gm-Message-State: AGi0Pua6WEsxdN1k05KOysnBhTgEhwrmV4OOm7JvYdm/dfzKjQH/8n0A 6bCNYhospCh4X7PMqxh0Ejc= X-Google-Smtp-Source: APiQypKgTTLbS3ZJQ2z0w045ILIZohPJBD9PL9EjSqmAwr7g1vYTEx20P+F48CbAz3x8ZURKxFymig== X-Received: by 2002:a17:90a:e515:: with SMTP id t21mr16118524pjy.123.1586700283142; Sun, 12 Apr 2020 07:04:43 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id r28sm49894pfg.186.2020.04.12.07.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 07:04:42 -0700 (PDT) From: Yafang Shao To: chris@chrisdown.name, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Yafang Shao , Shakeel Butt , stable@vger.kernel.org Subject: [PATCH] mm, memcg: fix inconsistent oom event behavior Date: Sun, 12 Apr 2020 10:04:27 -0400 Message-Id: <20200412140427.6732-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.18.1 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: A recent commit 9852ae3fe529 ("mm, memcg: consider subtrees in memory.events") changes the behavior of memcg events, which will consider subtrees in memory.events. But oom_kill event is a special one as it is used in both cgroup1 and cgroup2. In cgroup1, it is displayed in memory.oom_control. The file memory.oom_control is in both root memcg and non root memcg, that is different with memory.event as it only in non-root memcg. That commit is okay for cgroup2, but it is not okay for cgroup1 as it will cause inconsistent behavior between root memcg and non-root memcg. Let's recover the original behavior for cgroup1. Fixes: 9852ae3fe529 ("mm, memcg: consider subtrees in memory.events") Cc: Chris Down Cc: Johannes Weiner Cc: Shakeel Butt Cc: stable@vger.kernel.org Signed-off-by: Yafang Shao Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 8c340e6b347f..a0ae080a67d1 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -798,7 +798,8 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, atomic_long_inc(&memcg->memory_events[event]); cgroup_file_notify(&memcg->events_file); - if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) + if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS || + !cgroup_subsys_on_dfl(memory_cgrp_subsys)) break; } while ((memcg = parent_mem_cgroup(memcg)) && !mem_cgroup_is_root(memcg));