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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 0FBDFC43460 for ; Fri, 9 Apr 2021 16:27:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 90E3161074 for ; Fri, 9 Apr 2021 16:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90E3161074 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 2862E6B006C; Fri, 9 Apr 2021 12:27:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2230E6B006E; Fri, 9 Apr 2021 12:27:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 072B36B0070; Fri, 9 Apr 2021 12:27:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id DAA7A6B006C for ; Fri, 9 Apr 2021 12:27:29 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9240818463FB7 for ; Fri, 9 Apr 2021 16:27:29 +0000 (UTC) X-FDA: 78013359018.32.B6751B1 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 5C51C2000255 for ; Fri, 9 Apr 2021 16:27:29 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id b139so1005552qkc.10 for ; Fri, 09 Apr 2021 09:27:28 -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=LjrPz2s8A9wB9g0uw7ei0A966rFvFTwMq2h7wfTVNEI=; b=cEkeJQ7Yo/U8WUtvJkxyLqjM00FlFriq23RSEutb7fQpsQXbaWooEUM46FjU3qaPWU yjgVQcQarxtZH0u/3srZMcyZyhyyMuA12/rExznBOiFsAe9zYdz5AdV0n7zHSuUaA2T/ 1Y5QZHlzFe7/5vS82uVNeUsQjowWsqNcO41TmLLj8+5bZQgFDancNOMdDMt4QDnXlGWH fzBg6hJ+xnGtvQiHqSct+DvpA9uCb3sxN0mw39lOOeehk5ld3MJSJIfvxCop6vcrAKLE 8y43RPPhPKcaqP/AJzAb0+K1Qw47hZzlQC3pLB87AOmn3/ovXwwaitera1iDAWuJLt2m bWiA== 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=LjrPz2s8A9wB9g0uw7ei0A966rFvFTwMq2h7wfTVNEI=; b=iOyJgQrljxtlCM/qAyGFomK55CJ/l+1iZEyj07RgWQtnNW+I+GWTMWUI+CU2BhTCy9 FEk9KIy2ySgTOExtOxcdde7VNB8WeXFmscOk7AI3psuNncECZWeEih7UuiszkqnqbzPg iwVg/nk+voq+fK4eJyxj5XqhXh+yAuunquagxj12btnAuuQeWEaYgR6Z7D3RbZV7K98X rQ1/+XV05Fa+/nzjvvKDckjMYVXP+i+vLgSQ4c1GKRJXUcy2dnMWCrvt8xrd73y9gG5P MjGPNIXw/lsQT2brVTjVTSmnI3YU4IOO+qpf765F9cg0KDWNgXvOlVy3Var4Eis4Otq4 YLXw== X-Gm-Message-State: AOAM530PfJL/yqvyhkegdGHhlhq3x3kDZhrx8ya6mRnMfYkHxAO4wtDO YAixtdjeBt476GO4jyTOjPTWEA== X-Google-Smtp-Source: ABdhPJw9IByqUYH8m38ORw7YCYBB7s9HYJU7n5MHBiv8feb5avOqDYhLDTefZNXWuHD4YqkwPnEvhw== X-Received: by 2002:a37:76c2:: with SMTP id r185mr14303169qkc.204.1617985648354; Fri, 09 Apr 2021 09:27:28 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id v2sm2044427qkv.39.2021.04.09.09.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 09:27:27 -0700 (PDT) Date: Fri, 9 Apr 2021 12:27:27 -0400 From: Johannes Weiner To: Muchun Song Cc: guro@fb.com, mhocko@kernel.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, bsingharora@gmail.com, shy828301@gmail.com, alex.shi@linux.alibaba.com Subject: Re: [RFC PATCH v2 05/18] mm: memcontrol: simplify the logic of objcg pinning memcg Message-ID: References: <20210409122959.82264-1-songmuchun@bytedance.com> <20210409122959.82264-6-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210409122959.82264-6-songmuchun@bytedance.com> X-Rspamd-Queue-Id: 5C51C2000255 X-Stat-Signature: m5udhnxos9aa5zd6wa1bc3pa8ik77pjd X-Rspamd-Server: rspam02 Received-SPF: none (cmpxchg.org>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mail-qk1-f172.google.com; client-ip=209.85.222.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617985649-714405 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 Fri, Apr 09, 2021 at 08:29:46PM +0800, Muchun Song wrote: > The obj_cgroup_release() and memcg_reparent_objcgs() are serialized by > the css_set_lock. We do not need to care about objcg->memcg being > released in the process of obj_cgroup_release(). So there is no need > to pin memcg before releasing objcg. Remove those pinning logic to > simplfy the code. Hm yeah, it's not clear to me why inherited objcgs pinned the memcg in the first place, since they are reparented during memcg deletion and therefor have no actual impact on the memcg's lifetime. > There are only two places that modifies the objcg->memcg. One is the > initialization to objcg->memcg in the memcg_online_kmem(), another > is objcgs reparenting in the memcg_reparent_objcgs(). It is also > impossible for the two to run in parallel. So xchg() is unnecessary > and it is enough to use WRITE_ONCE(). Good catch. > Signed-off-by: Muchun Song Looks like a nice cleanup / simplification: Acked-by: Johannes Weiner