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 0FF89C43334 for ; Sun, 19 Jun 2022 20:32:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FF3C6B0071; Sun, 19 Jun 2022 16:32:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B0076B0072; Sun, 19 Jun 2022 16:32:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39DE66B0073; Sun, 19 Jun 2022 16:32:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 28F7C6B0071 for ; Sun, 19 Jun 2022 16:32:26 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EA12420DA8 for ; Sun, 19 Jun 2022 20:32:25 +0000 (UTC) X-FDA: 79596133050.18.E1C46D3 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf18.hostedemail.com (Postfix) with ESMTP id 66D211C0094 for ; Sun, 19 Jun 2022 20:32:25 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655670745; a=rsa-sha256; cv=none; b=SETQ17TenheuuvqTEvgxWRLApfrej7kHkkCoawBEYBDe8pw/7KkNS3B8BJBlMDwXNK091A oNcBMHs8BTn7ff7OKz0Eglo8qVpOtP6/Hq8TAX5hsvTPzxOEbSJFS8kijVZuLQ2lWDye3q 1y9yRGd0+h7SRzTIB5Dz83VCKrZMBD8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jdnZFEZH; spf=pass (imf18.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655670745; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/iFzVnSMJWQfW6ecslMrsDUmHZ1b88XfEpJU+8AWm4I=; b=mHNiotWg/mdVxRPSpG8qGf6p+e/JIwakHh0YVCRcZqUQMV+Dbe/HGWtJO9JYLdutEqCxtJ PuqoFMVs6SATp2k00N73/tZdjqW/U9GZ+HXHT4nWoUNoSd+t+ULWzFNkVoPHxhx84p9tEg OyKTfl6zcj250+yKd8FBTHr6WPQEihY= X-Stat-Signature: 5ut6abqrgq78cdib47mjkiuh94wu41dy X-Rspamd-Queue-Id: 66D211C0094 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jdnZFEZH; spf=pass (imf18.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1655670745-224620 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 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!