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 C85D0C433EF for ; Tue, 24 May 2022 19:01:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AB9D8D0006; Tue, 24 May 2022 15:01:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55E278D0001; Tue, 24 May 2022 15:01:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 421038D0006; Tue, 24 May 2022 15:01:28 -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 33D948D0001 for ; Tue, 24 May 2022 15:01:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 13BC9609E5 for ; Tue, 24 May 2022 19:01:28 +0000 (UTC) X-FDA: 79501555056.18.7F26BA4 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf04.hostedemail.com (Postfix) with ESMTP id 98FDB4003B for ; Tue, 24 May 2022 19:01:11 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id 11so13169589qtp.9 for ; Tue, 24 May 2022 12:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=N1NyblKLcbohBQoY7VD4CeyW8jWo8CQASjSrNPOY/Yo=; b=5jbLkbR/uOOEGcHuRkQuqxaY6Whn0WWZJI73E9T6SlozE5nWJfDFv28tOhdw2Irpoo ynu/oD5zPSoRnvOuieUuisexDncUJ9EhvY4IxA0FYIs846o/GA08BcTErhQHfklV/qf0 jg0IcxxINtvlr2Bxdr4w1FKtN4Hr/+eb58jqrlcI8O9fldRZrzN4qtR3yJ5NQHkSSx87 QVBY1FH1zFqA1zpBb6JeXcIx3cjBFrwrFWuWBTy1j0DS5ZAGQwmItNhPF5kCU5Dw8Pmf 843ZDy7B/DAg+XUmHuEO5HppBvbMLLsifaMMzS6+fo5EuIPCFt1xQwZG7gG/nNEj74ye IG2w== 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=N1NyblKLcbohBQoY7VD4CeyW8jWo8CQASjSrNPOY/Yo=; b=kXpddRignQj3KkLSWj3VxDY2gTzDRIDksOj+iH2+wdvu7K1+MvQsKHsTiV3lrMwi9P IDrgBZhPIxmOKgI54Gl0L1p2jAlJcloCLCB4reGawtbKVZKpN/IcfCx+0JHJuNgIuswq dSx2Tp+UBdIhoaTlW/1RBiByR34iZdfxeD8rj9bCe3fyzN0lOH9OhYC1QQnbx26nYequ yMP3wknYd8nJ2fZUtENNwfhxJB2vFIuRuWHMeW6O/7/RN7d9J6Ipk/MvqqFtTzNOB/TA 8uD2b04QHzniU6MZ3yUxrn6Yu1ZfMyAUTR96lDt+UMucshcS4h2oZOa13M0EkRUGN8GJ tV7g== X-Gm-Message-State: AOAM533chWmvQaojFIg6OxDCC3uV0cUJ0yl5d8XA78HWNabVSniTjoEv zB5/hvM8GSUxhxYS3zplUp6cKQ== X-Google-Smtp-Source: ABdhPJwyJDma/cDSH1QDMd/26bP9vKjCHlXwU76/B8cVC9D3MAicjzWFuXlvICvkqo3oAg4VMZPAjQ== X-Received: by 2002:a05:622a:110c:b0:2f3:d347:6f8d with SMTP id e12-20020a05622a110c00b002f3d3476f8dmr21461556qty.403.1653418886409; Tue, 24 May 2022 12:01:26 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:741f]) by smtp.gmail.com with ESMTPSA id l11-20020ac84a8b000000b002f39b99f6c4sm48783qtq.94.2022.05.24.12.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 12:01:26 -0700 (PDT) Date: Tue, 24 May 2022 15:01:25 -0400 From: Johannes Weiner To: Muchun Song 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: <20220524060551.80037-2-songmuchun@bytedance.com> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 98FDB4003B X-Stat-Signature: qam1pycfubsynpuib9zt63ukdib59189 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="5jbLkbR/"; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf04.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspam-User: X-HE-Tag: 1653418871-151638 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 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.