Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1832690iol; Fri, 10 Jun 2022 16:25:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJbDpK0L/UlAZ/sap2sq6yUpvpwuzyLSVrsHzW9tqWZyUDJ8qt6r5QP5iBsex5y93EAE+/ X-Received: by 2002:a05:6402:31fa:b0:42d:cd6d:c8fd with SMTP id dy26-20020a05640231fa00b0042dcd6dc8fdmr53018799edb.347.1654903552735; Fri, 10 Jun 2022 16:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654903552; cv=none; d=google.com; s=arc-20160816; b=MeEJdGJj32cJhuJjpxiLj5yAsJnxV95v0yVnQEfvD8MF7SIuy+PJN823E38pb27a9G IE3QnM5aw/wVUEhTnLnL0ND4mHJpnQ+GcONtDddcoGUXnrYjhaQPol6x3jNcsnw6kbNv Yh3Tcgof9d/xNaW7ZudXBP8JW0uaOvfwKWKQxVx2r14miRevSLeR62A0buHhlrng0Sge NLWQeKvGxkRZsZ7wh2GYT0ngZDPilWcHz5DHa4qBzmjCRfYS2LAHX7Q9lauoamwIoBXs /HIQCqTZvkz+6QYft0vV1Dcw/4Hob7of7k/EqcRM/uMmuyGQnbDFRu6MA8QtF6Qy6Ctx yidQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=TrSEiM07rzBXOnvoC0Ky3MYG75s35r1Z3atOF4M4Vgo=; b=hWbD/GUB+IJvwgAaHRAsdQ4ZbvOZ0SWt9/v24y4t+HodSb3cMAi/4wlAw2CMiArWJX zWtaXlEKAPwv3D/MB7H8IG1rENtAV92QVHgVbm32Wbxr0ne7D6n2gsjWR36T80PgoNPj /1j/yaOjDjuiVNUlJEHrPM5+K5CHMPZKHU/lJS6lnNLeJvVNmO5GV8t1a37yBOotIJGq s2rdit11hwfANCQ8QRxfwvGTqALKo6RRSd2XqeKEwOucizfxHgMuAJWtJO+2CuuG5kxh R9GiGAzIafNKA7So2XbcFwumEiSFF6R/9SXy/SoTLCcv2zuqwPh/KZnKfTBOlwtS1Mx7 44OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=AMOxHK6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a50d0d6000000b0042a9fccd3f2si471077edf.353.2022.06.10.16.25.21; Fri, 10 Jun 2022 16:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=AMOxHK6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347241AbiFJXNp (ORCPT + 99 others); Fri, 10 Jun 2022 19:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343938AbiFJXNo (ORCPT ); Fri, 10 Jun 2022 19:13:44 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE7611A25; Fri, 10 Jun 2022 16:13:42 -0700 (PDT) Date: Fri, 10 Jun 2022 16:13:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1654902820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TrSEiM07rzBXOnvoC0Ky3MYG75s35r1Z3atOF4M4Vgo=; b=AMOxHK6N2JOosdOfl0+XPzd/eYTQapToCZY4I1JYebewZncs47nQy7E5QzcCHFfBbNnr1d ZZ43ny9GLnosRlHAAJIxP9VYN6T0mUCdJ2T5H+/4VrFnQApaZzyHxS7RtXV/3nGaJue2Wn YZOOFxIk562TyU5GacNnmu6acEjlYkk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Muchun Song Cc: hannes@cmpxchg.org, mhocko@kernel.org, shakeelb@google.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, longman@redhat.com Subject: Re: [PATCH v5 03/11] mm: memcontrol: prepare objcg API for non-kmem usage Message-ID: References: <20220530074919.46352-1-songmuchun@bytedance.com> <20220530074919.46352-4-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220530074919.46352-4-songmuchun@bytedance.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 30, 2022 at 03:49:11PM +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 LGTM Acked-by: Roman Gushchin