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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 89ABDC433DB for ; Tue, 2 Mar 2021 03:52:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D897460240 for ; Tue, 2 Mar 2021 03:52:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D897460240 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 54FB38D00D4; Mon, 1 Mar 2021 22:52:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FED18D0063; Mon, 1 Mar 2021 22:52:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3ED7B8D00D4; Mon, 1 Mar 2021 22:52:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 2554B8D0063 for ; Mon, 1 Mar 2021 22:52:16 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DB503181AF5D0 for ; Tue, 2 Mar 2021 03:52:15 +0000 (UTC) X-FDA: 77873561430.19.A3DF796 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf25.hostedemail.com (Postfix) with ESMTP id 1C61D600249F for ; Tue, 2 Mar 2021 03:52:14 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id a4so12966485pgc.11 for ; Mon, 01 Mar 2021 19:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=57oy+i2wyCGM30/m8sTFwn3B8L9Scmi9y+74jBQL4vs=; b=eDNo6T5R9U/hOaETJQW7tHVGPRRrxSUybhcdsh8luN7bLlUhFb4Hoycj+OMDnhBnql 65FHpbOfmlHmgyxtM3JVmc2mQcitwZGb8tPB8LJAR0V04VWVQ0yl2fA9n8X/H2RiZ5o8 JGhQpb6kj7Bn2HCSfEfmHnkSuyEJgV8VA36qB/Ai+2icthxmSKekehKAFBdJyduJorSy JXHanj6IjXxeePGyeLl7WILWzYWblG6hddeH7BOK/Eb1M1g+BU3MDjIDdKBxOMGWBDr5 bma2ZRCT0zWPmAzH8UPm3dquhCdPzxobKiz8h8rReCBscZrY7bHEITUNeFORv60B6zj0 Zfqg== 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=57oy+i2wyCGM30/m8sTFwn3B8L9Scmi9y+74jBQL4vs=; b=c5M1C+VXUUrIcfUGZhcR9YpcLqWlBtKmsCmehejdF8308lCLlDCFCqq8+bOKtYCPIM fpRnBX03ed3EqDoSh4bQPCxRZ0Lmr2dMUfyd9LuuldtwmEOcooK3dr7ZcsP3Y/E2Sgow zGTng/rUqDq5PIlvRui7JQVn5rsBmbPfACtcCPn2R2NDsJKz/kbhlNZ0eiO1aOb6I+GU YsU1xcoIGOV1UWmJTsxBYh3Wzkj4S4VZ8zi2+7cUH3nPcb0OinJpcrtQrVrsUyNpwecq fDLc23ZH2oCBQMEwtjnJFwc0UB8e66Zb25Sacl4u0TyKSGmcs+ojgoFFH2nKlA6+pWEr 0piA== X-Gm-Message-State: AOAM533o3Dtz23qsNS2zMXadV7WwMN9AUUlJRw5IKwz/4cKLfHCbWvl3 V0i6s3IVi2mE/UW7YjnOujqwV99FxKn/k8Mlfdu0ew== X-Google-Smtp-Source: ABdhPJzcaUfOFHNGcSwihHOwcKhocr1mJt3SRQ35DB3BbiQ0eJJN8kETf2XLREn+v+AQ4squnM1FDAmvmjrcrb0kGao= X-Received: by 2002:aa7:9342:0:b029:1ee:8893:8554 with SMTP id 2-20020aa793420000b02901ee88938554mr9846451pfn.2.1614657133983; Mon, 01 Mar 2021 19:52:13 -0800 (PST) MIME-Version: 1.0 References: <20210301062227.59292-1-songmuchun@bytedance.com> <20210301062227.59292-3-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Tue, 2 Mar 2021 11:51:37 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 2/5] mm: memcontrol: make page_memcg{_rcu} only applicable for non-kmem page To: Shakeel Butt Cc: Alexander Viro , Jan Kara , Amir Goldstein , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , kpsingh@kernel.org, Ingo Molnar , "Peter Zijlstra (Intel)" , Juri Lelli , Vincent Guittot , dietmar.eggemann@arm.com, Steven Rostedt , Benjamin Segall , Mel Gorman , bristot@redhat.com, Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Roman Gushchin , Alex Shi , Chris Down , Wei Yang , Vlastimil Babka , Mathieu Desnoyers , Peter Oskolkov , Jann Horn , Joonsoo Kim , Daniel Vetter , Waiman Long , Michel Lespinasse , Christian Brauner , "Eric W. Biederman" , Kees Cook , krisman@collabora.com, esyr@redhat.com, Suren Baghdasaryan , Marco Elver , linux-fsdevel , LKML , netdev , bpf , Cgroups , Linux MM , Xiongchun duan Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1C61D600249F X-Stat-Signature: a17huinomyqipwnqfpnqydqdytjq9yay Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mail-pg1-f171.google.com; client-ip=209.85.215.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614657134-100210 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 Tue, Mar 2, 2021 at 11:36 AM Shakeel Butt wrote: > > On Mon, Mar 1, 2021 at 7:03 PM Muchun Song wrote: > > > > On Tue, Mar 2, 2021 at 2:11 AM Shakeel Butt wrote: > > > > > > On Sun, Feb 28, 2021 at 10:25 PM Muchun Song wrote: > > > > > > > > We want to reuse the obj_cgroup APIs to reparent the kmem pages when > > > > the memcg offlined. If we do this, we should store an object cgroup > > > > pointer to page->memcg_data for the kmem pages. > > > > > > > > Finally, page->memcg_data can have 3 different meanings. > > > > > > > > 1) For the slab pages, page->memcg_data points to an object cgroups > > > > vector. > > > > > > > > 2) For the kmem pages (exclude the slab pages), page->memcg_data > > > > points to an object cgroup. > > > > > > > > 3) For the user pages (e.g. the LRU pages), page->memcg_data points > > > > to a memory cgroup. > > > > > > > > Currently we always get the memcg associated with a page via page_memcg > > > > or page_memcg_rcu. page_memcg_check is special, it has to be used in > > > > cases when it's not known if a page has an associated memory cgroup > > > > pointer or an object cgroups vector. Because the page->memcg_data of > > > > the kmem page is not pointing to a memory cgroup in the later patch, > > > > the page_memcg and page_memcg_rcu cannot be applicable for the kmem > > > > pages. In this patch, we introduce page_memcg_kmem to get the memcg > > > > associated with the kmem pages. And make page_memcg and page_memcg_rcu > > > > no longer apply to the kmem pages. > > > > > > > > In the end, there are 4 helpers to get the memcg associated with a > > > > page. The usage is as follows. > > > > > > > > 1) Get the memory cgroup associated with a non-kmem page (e.g. the LRU > > > > pages). > > > > > > > > - page_memcg() > > > > - page_memcg_rcu() > > > > > > Can you rename these to page_memcg_lru[_rcu] to make them explicitly > > > for LRU pages? > > > > Yes. Will do. Thanks. > > > > Please follow Johannes' suggestion regarding page_memcg_kmem() and > then no need to rename these. OK.