Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2307117iog; Sun, 19 Jun 2022 13:38:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sSPA2fEz0Y4jewV7JncCaxSlRMEI3GmjgwBjwm0tp4LtAIvmtmVvUBZv58DNVW9Kpt47mQ X-Received: by 2002:a63:114:0:b0:3fd:431a:dd77 with SMTP id 20-20020a630114000000b003fd431add77mr18885288pgb.619.1655671083685; Sun, 19 Jun 2022 13:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655671083; cv=none; d=google.com; s=arc-20160816; b=ko+5KF1IPt1JMMuEVdkh6s8RrgjvOZ8ygj325ih95B+Zkk/UcXnDnzn9uEKugTVzue tQeMwTYybBpZo1GO/91yRfNGEIg8H5+PocZ/BkFbFs4WZ78fLLd9AYwP1UZovaVlhLfO cNXavxvvmbNvrdfOt1WFvWYT5YLC7DSH9rpWYccysU1ZmypIDz8XbZA1gJ7UcQ5/3J6m 3PV9URG5qxDwuAwC2kwl7ASCp3E2B/0Ni2emBBvPTfHTAwhVU9Gyjk8UBiFRFP1JyNim sADNif6+Hp7upqASBORsLoySz6XLx5cUvQmRFoCxHn+xXwbZmBLpjHKI/rmD8SrUijKo hflA== 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=/iFzVnSMJWQfW6ecslMrsDUmHZ1b88XfEpJU+8AWm4I=; b=g7ctcMBmhfVQ/KGb3Rp9r6Oj2nFoOV03qL1/r9S7n3/QwhsBlHHBSNawXXzuefJ/NK cQuBrG353aKYLexjFoK/IE1PPPLUhcwbcD/RxBrF0PubNg/WLxgxpEzG3SORZtW90zzm SNDJSv5w5nYRXnLx8iXGYtZuUqZV7DuJXf/MSZC7W2FGkDUkq1Ix0+H6iV0vhp3O7511 A4bs8koBJb7u5iid7oO1Mv8ir39/xVoOa9hBlIJeOwFLLISnxICiNOtNEQIddkT/++pQ PSEbwW7/Cp+JHRiNdLjglzQkdln3TGSdmvCSkSAYYfSlqzkE9V1QTaJeJI/rLOTu3wVq oDrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jdnZFEZH; 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 q23-20020a170902b11700b0016a0e0ee5dbsi7129167plr.521.2022.06.19.13.37.52; Sun, 19 Jun 2022 13:38:03 -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=jdnZFEZH; 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 S236943AbiFSUc2 (ORCPT + 99 others); Sun, 19 Jun 2022 16:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235930AbiFSUc1 (ORCPT ); Sun, 19 Jun 2022 16:32:27 -0400 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9E5E71; Sun, 19 Jun 2022 13:32:25 -0700 (PDT) Date: Sun, 19 Jun 2022 13:32:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1655670744; 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=/iFzVnSMJWQfW6ecslMrsDUmHZ1b88XfEpJU+8AWm4I=; b=jdnZFEZHOLbOp782xUrFZDV9bkoz87qvOXXknUfwfEDMS6vQCKYIHqWX9FuG3L49Ub8CqO X2SHeiVHXr59jzxUDeShfbhkM1/S8dJKtZWUxV3s1aCoQSk3UGq8JQ4OQBiQdMsu6iT7jb qHFttOTcjUj8VNbKGY4/L59wUe54hKQ= 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 09/11] mm: memcontrol: use obj_cgroup APIs to charge the LRU pages Message-ID: References: <20220530074919.46352-1-songmuchun@bytedance.com> <20220530074919.46352-10-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220530074919.46352-10-songmuchun@bytedance.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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:17PM +0800, Muchun Song wrote: > We will reuse the obj_cgroup APIs to charge the LRU pages. Finally, > page->memcg_data will have 2 different meanings. > > - For the slab pages, page->memcg_data points to an object cgroups > vector. > > - For the kmem pages (exclude the slab pages) and the LRU pages, > page->memcg_data points to an object cgroup. > > In this patch, we reuse obj_cgroup APIs to charge LRU pages. In the end, > The page cache cannot prevent long-living objects from pinning the original > memory cgroup in the memory. > > At the same time we also changed the rules of page and objcg or memcg > binding stability. The new rules are as follows. > > For a page any of the following ensures page and objcg binding stability: > > - the page lock > - LRU isolation > - lock_page_memcg() > - exclusive reference > > Based on the stable binding of page and objcg, for a page any of the > following ensures page and memcg binding stability: > > - objcg_lock > - cgroup_mutex > - the lruvec lock > - the split queue lock (only THP page) > > If the caller only want to ensure that the page counters of memcg are > updated correctly, ensure that the binding stability of page and objcg > is sufficient. > > Signed-off-by: Muchun Song Aside from two questions, which I raised in the comments to previous patches in the series: 1) perf impact, 2) should we open-code the reparenting procedure to show the locking in a more explicit ways? Acked-by: Roman Gushchin Thanks!