From patchwork Wed Oct 28 03:50:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11862427 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 D86DC14B7 for ; Wed, 28 Oct 2020 03:50:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A74D22456 for ; Wed, 28 Oct 2020 03:50:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="GnFZV28/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A74D22456 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E71156B005C; Tue, 27 Oct 2020 23:50:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E21216B005D; Tue, 27 Oct 2020 23:50:52 -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 CE7886B0062; Tue, 27 Oct 2020 23:50:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 9F9706B005C for ; Tue, 27 Oct 2020 23:50:52 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3EFF03622 for ; Wed, 28 Oct 2020 03:50:52 +0000 (UTC) X-FDA: 77419957944.26.sky85_1802a4b27281 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 1F7521804B655 for ; Wed, 28 Oct 2020 03:50:52 +0000 (UTC) X-Spam-Summary: 1,0,0,14f5269e1c2ee12e,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1540:1711:1714:1730:1747:1777:1792:1801:2393:2559:2562:3138:3139:3140:3141:3142:3351:3865:3866:3870:4321:4605:5007:6261:6653:6737:8784:10004:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12895:13069:13311:13357:13894:14096:14181:14384:14394:14581:14721:21080:21444:21451:21627:21990:30054,0,RBL:209.85.210.196:@bytedance.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100;04yr4bhe3z1ns49tzyrobjw37gghuopaf71ixdd1u9byp49mii5r7d8ppgqoryr.jobs5u9aa4c9oh651sfotnkcptf18s61zu5qm1p3p97k9wp46973y8uo4bhz5a4.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:70,LUA_SUMMARY:none X-HE-Tag: sky85_1802a4b27281 X-Filterd-Recvd-Size: 4107 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Wed, 28 Oct 2020 03:50:51 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id w21so2140775pfc.7 for ; Tue, 27 Oct 2020 20:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gP9leRSqd8Nt5uw/ZcHLxalg6StnlmANhYwqDz5BamY=; b=GnFZV28/BNLRDucvzLESFv3OK7W6Iffx80nxt4gJX1KhQieE7APUfRH855/sp8RpMp cgkPejLvI+G6njV9mAmeo8VpZR4SfRadMjAssX2yRNc0iM3vyKnAhArixSQD58RO3L72 Z0dOyUvEwxRX46FND2HUmFnhDDWdGNDCh5D+vNMyuk0wOXQ0ey1QMESV6UzxiDxR0yMU I/NSyZH3V7OUkd/ZNH6L5ToixcPb8J95qJPY7X1JOPEGvzroGJRZk1n/vBLocJO8sU4I fcnSEqdRLC/8x96lYmo1J1CBnTvGU14rV/VVdMwwMHdnccSu1XPj2SlK3p3yIP7wc1RY 4KLQ== 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:mime-version :content-transfer-encoding; bh=gP9leRSqd8Nt5uw/ZcHLxalg6StnlmANhYwqDz5BamY=; b=XM77/CyUABe7aV5Opbx6Ij54Wom+HOwtsdwACpRRZ0Cq83m2Nr2rS8ORwZ8H7CLO3V gGhtcIt1VFa1Jg+vCHJvR/SCDAau8IKqHMtbT7+ayrECVHqZN43C2VqJJmByDrRd468n vI67qf9hH20J1A3KzbX9sDpOGTwoewiSPyvIVlBYS1zpHk1vIEwgKTyG3hXs6+wzdE6Q +1gaOeElZA1xa6H6KdERWljxWxMpHL3W1Ip5abyD6ANkfHo9+SRoU275cngkCRO9+lA8 M1WT7atec+qR7+C9sOL7Q8hoVj3Ya0GP/LKpZEElgyf3jtI3UYBZYdp9A2JEnKsDAqiH cwlw== X-Gm-Message-State: AOAM530d664lfbf+fXbBYe4OUp64u0uh/LGOx8SW8EoCg5KsC5gDW5aP 3EG/Sc60NWqPffCIHMBPKn5m7w== X-Google-Smtp-Source: ABdhPJzaRhN3aDdXWQ0D5XcrckptuF92X7FGcRacXma9zoZkUg7BhB9XvJmIZJEeUtmL/cOvXiejSQ== X-Received: by 2002:a63:4c19:: with SMTP id z25mr4603006pga.58.1603857050037; Tue, 27 Oct 2020 20:50:50 -0700 (PDT) Received: from Smcdef-MBP.local.net ([103.136.220.89]) by smtp.gmail.com with ESMTPSA id s8sm3412273pjn.46.2020.10.27.20.50.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2020 20:50:49 -0700 (PDT) From: Muchun Song To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, iamjoonsoo.kim@lge.com, laoar.shao@gmail.com, chris@chrisdown.name, christian.brauner@ubuntu.com, peterz@infradead.org, mingo@kernel.org, keescook@chromium.org, tglx@linutronix.de, esyr@redhat.com, surenb@google.com, areber@redhat.com, elver@google.com Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Muchun Song Subject: [PATCH v2] mm: memcg/slab: Fix return child memcg objcg for root memcg Date: Wed, 28 Oct 2020 11:50:10 +0800 Message-Id: <20201028035013.99711-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Consider the following memcg hierarchy. root / \ A B If we get the objcg of memcg A failed, the get_obj_cgroup_from_current can return the wrong objcg for the root memcg. Fixes: bf4f059954dc ("mm: memcg/slab: obj_cgroup API") Signed-off-by: Muchun Song Acked-by: Roman Gushchin --- changelog in v2: 1. Do not use a comparison with the root_mem_cgroup mm/memcontrol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1337775b04f3..8c8b4c3ed5a0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2961,6 +2961,7 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void) objcg = rcu_dereference(memcg->objcg); if (objcg && obj_cgroup_tryget(objcg)) break; + objcg = NULL; } rcu_read_unlock();