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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39433C433F5 for ; Wed, 25 May 2022 08:46:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 940878D0002; Wed, 25 May 2022 04:46:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F01C8D0001; Wed, 25 May 2022 04:46:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DCED8D0002; Wed, 25 May 2022 04:46:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6FF158D0001 for ; Wed, 25 May 2022 04:46:30 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3A2AF2100E for ; Wed, 25 May 2022 08:46:30 +0000 (UTC) X-FDA: 79503634140.20.4016D65 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf21.hostedemail.com (Postfix) with ESMTP id 951591C0032 for ; Wed, 25 May 2022 08:46:16 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id x2-20020a17090a1f8200b001e07a64c461so1072257pja.4 for ; Wed, 25 May 2022 01:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=d/L9bJONQPp0uSY28kh2HkObDppTNggSH2SJIKJfLuk=; b=2GEuOFvz3Bywye/v7GI6JcRFObM9JkE9PB987vWqYpJiiyxSqKAphe+RZffoCyw3Z8 dQ4s8QBk94CQnN1GPQjqLpFQQtB6tVtsrCMONfYb8ZH+S3ljKkkBZntxUWs+DW5oOLCY MVoldevPZzFme10e5rTEUi02U4vA4Is0+GRUtHOulZuFhPIOnv5LIbwIJq2lSGo5/6La lqm5E+niPY2k3kRldtKfA/ZIldsMIrJrdsia9LnJH2u2QRZX927wPJ/hO1yElkEsN67n ACcx7saaMsBzaEhlKwdSQPEdtY1RGNsTc69pkFZHcT7E3YFH+3JoignnjhAtztA1LuMA B9cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=d/L9bJONQPp0uSY28kh2HkObDppTNggSH2SJIKJfLuk=; b=GqkMv0gqGoisQQSh4/YCr+XYvacwLSfy0/pwraSFFYxM2dc9tHuR75J6pX9J97pKj/ +YU6yl5MsJ7BvwSRiZYAvkYs0ZkwD84QppAoTTYKQqTwiguR2/N0/F/GCfDKHuUdztsx kQJKBG5m97KgxNuC/zoJN0abH0kM29gAqJn3qabHxvoTRDCEeAVsjSO0L3JPgjkkFyoj IVFYFhKDCFwZlNqRIcmMyrJeZzd2/ep2BHri2CLkkFW6nJhRsk2Uu6TXs/HhZeEGd92c kpaFKsw55LMKf5gie0TQyNVlAwJtVaJHyJngips2+EaKw19aw0Kgk/CF7gsMMtJljRNr Inow== X-Gm-Message-State: AOAM531yVZdE/FJNHwn4DEPXtVFZai1/gfLTSkikX7Qzu4j1Z1m0HsJY SReVUiZo6umTcwKtX/egGNpGSw== X-Google-Smtp-Source: ABdhPJwnmL+cvLM5lHxHfpGLmHf4g+oYpN6zeK6b7y0jWu6+wMWakWV0yI6oG3RyjogpIQyC6oZmtQ== X-Received: by 2002:a17:902:748c:b0:163:5fa0:68c0 with SMTP id h12-20020a170902748c00b001635fa068c0mr953508pll.123.1653468382775; Wed, 25 May 2022 01:46:22 -0700 (PDT) Received: from localhost ([2408:8207:18da:2310:c40f:7b5:4fa8:df3f]) by smtp.gmail.com with ESMTPSA id m24-20020a170902bb9800b0015e8d4eb28csm8643430pls.214.2022.05.25.01.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 01:46:22 -0700 (PDT) Date: Wed, 25 May 2022 16:46:17 +0800 From: Muchun Song To: Johannes Weiner Cc: mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, longman@redhat.com Subject: Re: [PATCH v4 01/11] mm: memcontrol: prepare objcg API for non-kmem usage Message-ID: References: <20220524060551.80037-1-songmuchun@bytedance.com> <20220524060551.80037-2-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 951591C0032 X-Stat-Signature: i4dpkdspetfqu6jdthckjidx9pstrudr Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=2GEuOFvz; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf21.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1653468376-226589 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, May 24, 2022 at 03:01:25PM -0400, Johannes Weiner wrote: > On Tue, May 24, 2022 at 02:05:41PM +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 > > Acked-by: Johannes Weiner > > Looks good to me. Also gets rid of some use_hierarchy cruft. > Thanks for taking a look.