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=unavailable 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 ECC45C4320A for ; Fri, 20 Aug 2021 06:44:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7DF2C610CF for ; Fri, 20 Aug 2021 06:44:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7DF2C610CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 138F76B0072; Fri, 20 Aug 2021 02:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EADC6B0073; Fri, 20 Aug 2021 02:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F41B06B0074; Fri, 20 Aug 2021 02:44:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id DB3546B0072 for ; Fri, 20 Aug 2021 02:44:47 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8656B827D1F8 for ; Fri, 20 Aug 2021 06:44:47 +0000 (UTC) X-FDA: 78494521014.07.445BA29 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf17.hostedemail.com (Postfix) with ESMTP id 62017F00038D for ; Fri, 20 Aug 2021 06:44:46 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id k24so8206079pgh.8 for ; Thu, 19 Aug 2021 23:44:45 -0700 (PDT) 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=KE1zb6m8muvukw7sccIpaWu9LaRU18Aa0FS6/xMdGNo=; b=bbyBO+VBSqjFPmChF/PUQMrXZ+tNKSnjEZo+/rf8AwVRMwGy+TnHXfIleNPM9rLe1L qqL0MRTutOdwQKxRjGe0pA7A8m9Pe+1yq+jaJ12cF7IcBZUeKN32RNYQQigaerpdw2Nr q3xsbrn5vY7IKwGvweMK13Z1KF+p+gNta/GxYEeptWPoATQQZXAwl6Ku+uxn18nD1jFR IzzMwqifQS+riB7eTXIQQRCbSDGcI538TgQS5qyXM6HeGNKXSEwWcfqjacJIs+n155VV rw5kONuOd52RX6RedS9Sb/ncVSYJY0/mmvLOfNDGp+VnrXypKn8xYF/MSauNNI5uqpgq DcBQ== 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=KE1zb6m8muvukw7sccIpaWu9LaRU18Aa0FS6/xMdGNo=; b=i2pyW4xsDaVaaWY07PiYgOXdqipPca0YTa4+nOclp0b/Dx5yjRAb8yn56yVGi1qBxA hIV08XfIO7A8LanzbZCt3wCtXd7TDgvjeiGLzn+Cn2R+a9xb9173cg4VZz60g7bJJWzA ApuZKIp4wdUCrNjVOr6/vbFfJ0iQ0UsCiQ2nCuDS/ph8NK0XWiRcSLk21ImEv/XFo4wU EFNg6ila1G/TiRKOzSdCG+d/T7SsTkXIx3kUMOhGJTWoQe87ujbhQYk02+sT1nDhETgt sETekbWoEwkDZOjrsSrsnmqNBJVumULpl3ZkUkoSDAV89klgSMaemC3qW04R5iLJiLBI IefA== X-Gm-Message-State: AOAM532oZ1IWnw4cSGax6Vc3WluKqtefWkDLajHyPEuTqkmhbAOV850f 18WvkWlGLfO/wvf1mQ92mg8AgLBuU6M8zTmkCAhMzw== X-Google-Smtp-Source: ABdhPJzjCKemjp4rN7FqnClXF7A2/Ui/MfIaVs0es2mwWAIM3ZFyKAYmEpJmgTHfdKFuNosU+oid82ft5IgdaYv0asE= X-Received: by 2002:a63:f804:: with SMTP id n4mr17132101pgh.341.1629441884963; Thu, 19 Aug 2021 23:44:44 -0700 (PDT) MIME-Version: 1.0 References: <20210814052519.86679-1-songmuchun@bytedance.com> <20210814052519.86679-2-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Fri, 20 Aug 2021 14:44:08 +0800 Message-ID: Subject: Re: [PATCH v1 01/12] mm: memcontrol: prepare objcg API for non-kmem usage To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Andrew Morton , Shakeel Butt , Vladimir Davydov , LKML , Linux Memory Management List , Xiongchun duan , fam.zheng@bytedance.com, "Singh, Balbir" , Yang Shi , Alex Shi , Muchun Song , Qi Zheng Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 62017F00038D X-Stat-Signature: u6cfdxy6i49ccgfiwf9x13i7gggoxyra Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=bbyBO+VB; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf17.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1629441886-836202 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 Wed, Aug 18, 2021 at 11:01 AM Roman Gushchin wrote: > > On Sat, Aug 14, 2021 at 01:25:08PM +0800, Muchun Song wrote: > > Pagecache pages are charged at the allocation time and holding a > > reference to the original memory cgroup until being reclaimed. > > Depending on the memory pressure, specific patterns of the page > > sharing between different cgroups and the cgroup creation and > > destruction rates, a large number of dying memory cgroups can be > > pinned by pagecache pages. It makes the page reclaim less efficient > > and wastes memory. > > > > We can convert LRU pages and most other raw memcg pins to the objcg > > direction to fix this problem, and then the page->memcg will always > > point to an object cgroup pointer. > > > > Therefore, the infrastructure of objcg no longer only serves > > CONFIG_MEMCG_KMEM. In this patch, we move the infrastructure of the > > objcg out of the scope of the CONFIG_MEMCG_KMEM so that the LRU pages > > can reuse it to charge pages. > > > > We know that the LRU pages are not accounted at the root level. But > > the page->memcg_data points to the root_mem_cgroup. So the > > page->memcg_data of the LRU pages always points to a valid pointer. > > But the root_mem_cgroup dose not have an object cgroup. If we use > > obj_cgroup APIs to charge the LRU pages, we should set the > > page->memcg_data to a root object cgroup. So we also allocate an > > object cgroup for the root_mem_cgroup. > > > > Signed-off-by: Muchun Song > > I like the "move objcg stuff to memcg/css level" part. > > I'm less convinced about making byte-sized charging kmem-specific > (both naming and #ifdef CONFIG_MEMCG_KMEM). Do we really win a lot? > > I understand why we might wanna compile out some checks from the > hot allocation path, but few bytes in struct objcg will not make a big > difference, as well as few lines of code in cgroup creation/removal paths. > > Also it might be useful for byte-sized accounting outside kmem, e.g. zswap. > So, I'd remove this dependency and rename to something like > obj_cgroup_release_bytes(). Got it. I'll do that in the next version. Thanks for your suggestions. > > In the long run we might wanna to eliminate CONFIG_MEMCG_KMEM completely, > so let's at least not add new dependencies. Got it. > > Thanks!