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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 3A963C433E0 for ; Fri, 19 Mar 2021 13:59:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A012964F11 for ; Fri, 19 Mar 2021 13:59:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A012964F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 164236B006E; Fri, 19 Mar 2021 09:59:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13C016B0072; Fri, 19 Mar 2021 09:59:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0026F6B0073; Fri, 19 Mar 2021 09:59:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DA8E56B006E for ; Fri, 19 Mar 2021 09:59:27 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9B743A2B4 for ; Fri, 19 Mar 2021 13:59:27 +0000 (UTC) X-FDA: 77936781174.18.CE5CF11 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by imf27.hostedemail.com (Postfix) with ESMTP id 3090980192E4 for ; Fri, 19 Mar 2021 13:59:27 +0000 (UTC) Received: by mail-lf1-f41.google.com with SMTP id a198so10153859lfd.7 for ; Fri, 19 Mar 2021 06:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DNIwjkC1S9o2xuElvHyMZN9mH83zWdQwYUBfBnqGovs=; b=EUJAmvbInnyEI94Eq1yJqB8E15rmGmxd0eGp7zoE+XyWeXOiuUQl/gTgforvibnFmx hiGgvaB527Ji9acOUTwCbLjnHOI7J4vzq86AFrM35DO4bpAfcfmHlSuAqoS9G8qPchZI y3yDbf3nyFuo7cOWKpKm0Ph3ki5Emui2ijrCnlOMG18pn2UrYt/vKicm4eW3b8667Mho aaoC4erUOR0/cUjxAofObB/A+7pGHsEOFfyZ45A8KDw8Cy6tLDi75/QbjCu8B80rI3xM 3SLhOiMidT60OzSFpngLbdjcn9Pl7JFG/FwFdWEqC6DX6KQv4gWSRXxcE790tWHEF+zd LHSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DNIwjkC1S9o2xuElvHyMZN9mH83zWdQwYUBfBnqGovs=; b=QFS6S6epU9s4TvhZkUagToI0cpoglMWq6tS4UsJcLvpksoLvFc71OwB2cNTm0vmLtI oBH0dqZgawn3/1FRxkx/MSixspP94WoWdfgyVxEJSFEz5VLDRNVUaL7jK9gzRxYOIeco zRf9o8ZLM7pLa6hKQnbEV8yCdMKAt8uZtvVt+rwnQc65o4wbnu1dYvxN2nTlWO3tGlBD U7ctkC5x+Oav+KoH7rKl3J2I95tFaqIFqci0JHKAhTJ48RM1QtztIAGz9BJzCzU0J0kq uuAG5/1Aw28MPhTS5Y+VXMbheMa6HlLn2rZ6Md3W67n5whBlvYVyzeGDNOU7v4UUGIqR up4A== X-Gm-Message-State: AOAM5302JgV2C/v8fDVlD1JtQ+tZUAELCrSXyxBbRw2RDmcpkQW0KsPb sTrBxGY4tq8uGLKONCUdiHZsmy7472ytplXI98Cr7g== X-Google-Smtp-Source: ABdhPJxnob7NEKnE/oW7ZfcQUJDMcqfLGaOgMxiTJQSaqKoRAFOHIpsgwLehlAH+c2zqo8KRkaAae+5NHF4GP0n4zH8= X-Received: by 2002:a19:e0d:: with SMTP id 13mr887724lfo.549.1616162365516; Fri, 19 Mar 2021 06:59:25 -0700 (PDT) MIME-Version: 1.0 References: <20210318110658.60892-1-songmuchun@bytedance.com> <20210318110658.60892-5-songmuchun@bytedance.com> In-Reply-To: From: Shakeel Butt Date: Fri, 19 Mar 2021 06:59:13 -0700 Message-ID: Subject: Re: [External] Re: [PATCH v4 4/5] mm: memcontrol: use obj_cgroup APIs to charge kmem pages To: Muchun Song Cc: Roman Gushchin , Johannes Weiner , Michal Hocko , Andrew Morton , Vladimir Davydov , LKML , Linux MM , Xiongchun duan Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3090980192E4 X-Stat-Signature: ubmknnw1dxmi8ofyc9mbz8aahx94iyou Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=mail-lf1-f41.google.com; client-ip=209.85.167.41 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616162367-955872 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 Thu, Mar 18, 2021 at 9:05 PM Muchun Song wrote: > > On Fri, Mar 19, 2021 at 11:40 AM Shakeel Butt wrote: > > > > On Thu, Mar 18, 2021 at 4:08 AM Muchun Song wrote: > > > > > [...] > > > > > > +static inline struct mem_cgroup *get_obj_cgroup_memcg(struct obj_cgroup *objcg) > > > > I would prefer get_mem_cgroup_from_objcg(). > > Inspired by obj_cgroup_memcg() which returns the memcg from objcg. > So I introduce get_obj_cgroup_memcg() which obtains a reference of > memcg on the basis of obj_cgroup_memcg(). > > So that the names are more consistent. Just my thought. > > So should I rename it to get_mem_cgroup_from_objcg? > If you look at other functions which get reference on mem_cgroup, they have the format of get_mem_cgroup_*. Similarly the current function to get a reference on obj_cgroup is get_obj_cgroup_from_current(). So, from the name get_obj_cgroup_memcg(), it seems like we are getting reference on obj_cgroup but the function is getting reference on mem_cgroup. > > > > > +{ > > > + struct mem_cgroup *memcg; > > > + > > > + rcu_read_lock(); > > > +retry: > > > + memcg = obj_cgroup_memcg(objcg); > > > + if (unlikely(!css_tryget(&memcg->css))) > > > + goto retry; > > > + rcu_read_unlock(); > > > + > > > + return memcg; > > > +} > > > + > > > #ifdef CONFIG_MEMCG_KMEM > > > int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s, > > > gfp_t gfp, bool new_page) > > > @@ -3070,15 +3088,8 @@ static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp, > > > struct mem_cgroup *memcg; > > > int ret; > > > > > > - rcu_read_lock(); > > > -retry: > > > - memcg = obj_cgroup_memcg(objcg); > > > - if (unlikely(!css_tryget(&memcg->css))) > > > - goto retry; > > > - rcu_read_unlock(); > > > - > > > + memcg = get_obj_cgroup_memcg(objcg); > > > ret = __memcg_kmem_charge(memcg, gfp, nr_pages); > > > > Why not manually inline __memcg_kmem_charge() here? This is the only user. > > > > Similarly manually inline __memcg_kmem_uncharge() into > > obj_cgroup_uncharge_pages() and call obj_cgroup_uncharge_pages() in > > obj_cgroup_release(). > > Good point. I will do this. > > > > > > - > > > css_put(&memcg->css); > > > > > > return ret; > > > @@ -3143,18 +3154,18 @@ static void __memcg_kmem_uncharge(struct mem_cgroup *memcg, unsigned int nr_page > > > */ > > > int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order) > > > { > > > - struct mem_cgroup *memcg; > > > + struct obj_cgroup *objcg; > > > int ret = 0; > > > > > > - memcg = get_mem_cgroup_from_current(); > > > > This was the only use of get_mem_cgroup_from_current(). Why not remove it? > > I saw a potential user. > > [PATCH v10 0/3] Charge loop device i/o to issuing cgroup > > To avoid reintroducing them. So I did not remove it. > Don't worry about that. Most probably that user would be changing this function, so it would to better to introduce from scratch.