Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1362595pxb; Fri, 21 Jan 2022 16:33:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrnarf9kebWGMT8dw75fxuhCqeNXhdn+fkeoVJ5SMyHlpleVzF/VnXHDUHN6rnfX84bltK X-Received: by 2002:a05:6a00:1995:b0:4c5:eb10:c83d with SMTP id d21-20020a056a00199500b004c5eb10c83dmr5577168pfl.70.1642811595907; Fri, 21 Jan 2022 16:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811595; cv=none; d=google.com; s=arc-20160816; b=zKQEsEkCR+4H37YCVGcFejvX60OU4mnrHQBHs5B6ap0YuF4NELNCbkSDk1Yl29PESy cyv+oQPvDpQZ/Ik5gkiOX1eQ4lGftpOq9emxI5D401MzKMzbeTTR1lWTzcdBBwgZo6k5 HwoMnSb9dUjlEY5QMbrRJOHdChd494al2xKvyTukl+nL69xrLF/0DTn5fH6sq6lPBOaK bAffaBWdgUMGu2ci2LmNJPqXv+Z3vNYnUc1uCG+ZIJOrl8JGQ3nuZJ1fFM7/6asnj38O FUTxhpQrvnHNEkfFaOYeGEIo4AdLvQ6nOTMr9NGPmXl4znKFskKmQSDTI8xcVZIa6kZ+ Uvxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oLfplAHSJpoJoro49dxV+IqhVZCDx28Jwklvx67FrF8=; b=Bw0l/1Q8unuoz6nnvl/PD5yPYE0AC+JuQs/FFm2b1UA0uvQnsQ2o9CmaoGGM7Qk70C HtY7qB58p4Cz+vMtIpVbabPjfmWax9VZNuzn95bdtY7NLAUjgiF/VvrGxEs/ZmhmT5rH AATYvSxIg09KaXnVzEBd0YVRs/mz/ZLPaR4EL1jTeWcRMsPHkcUZSi65+33OIy7hrf7L zureqYDxHEWyTpQcRmnEU8ztxJqGmE++Q6i8cmic0sOKfxkrVwFd9doJew3P5rMig99k aAdky1BC2JF8McRmU9VrGkEyudgMl4iuj64ioKzLAICtr4XQx9LjDo5Ve3vx0MYt0toN xcGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=nYs10YR6; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e2si6947900pfe.62.2022.01.21.16.33.03; Fri, 21 Jan 2022 16:33:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=nYs10YR6; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348599AbiAUF2t (ORCPT + 99 others); Fri, 21 Jan 2022 00:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348559AbiAUF2p (ORCPT ); Fri, 21 Jan 2022 00:28:45 -0500 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F438C061401 for ; Thu, 20 Jan 2022 21:28:45 -0800 (PST) Received: by mail-yb1-xb2c.google.com with SMTP id g14so24324143ybs.8 for ; Thu, 20 Jan 2022 21:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oLfplAHSJpoJoro49dxV+IqhVZCDx28Jwklvx67FrF8=; b=nYs10YR6ocJHBHrLUw73ps3g3PLSvZRhMinzM7yDV+hDZbTjOND8oCKxMyT7zy/s6G tMcswUlEq+K9VtnMpJY8Xe3qmK/c1WZ9QqmGTojYfVkIdyJLSktRljR0K344YxrVYsho MGaOplQaamQhQjtxmTuX0r5hMqG+z7HJAKD/xjQcVsT+9Rt98UEiiqDM96vc1p4plXhh s+y4/thwlfHz5n1UEfgYRc+Ya43KcxPrf6NoyTTXhWIhs8F1sdwuJWe3djxrPQXheYmt hNhNIxcu/lF+d/J/Mw7B90xjkN4AdX9GUzOTS4wopMsCv309Ogv7RLpi322UUxcI4Bhf XRIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oLfplAHSJpoJoro49dxV+IqhVZCDx28Jwklvx67FrF8=; b=KAZnsWSVpwzb2SkvNFo8ZIbCnRdjBKqgGaDYLPtlII4lUceMfG43fXwpmpwkkjMFIe KDRmMDjaUUXIMWvVnZ6WKK/VFJ1I2cwmzGgXqU25MJKEUSYqBSp//253b5piIzqRCi9e jnJQOkSw2OblC5ISKJD2DcaCEsD4BgqXOtLEq9YMbM9lwo+VTaHXLrC0fHkyopbQwCKZ Fkjko7Z9gAXFQF/GqWu+b0MVX6VHjjHj/X/g7/bQ0dZQK+ywRPpOaB+OAP1+94CqbNBQ veU+TornidD6qjtVE9qxI+Oa+2VrweC3c5F7zW/CWyOjNHFnwlY3P/UzB61nfBrjAVYa 3xkw== X-Gm-Message-State: AOAM531l7+7/+EzBPc2RtvEY+SrVJWFasYa3ydf/kHF2rj4HO5VkVnXC gLkI/iZnEaqV1rI5ycwkDC1gJvyO2fY8UVkMiATb3w== X-Received: by 2002:a25:6186:: with SMTP id v128mr3977526ybb.485.1642742924405; Thu, 20 Jan 2022 21:28:44 -0800 (PST) MIME-Version: 1.0 References: <20211220085649.8196-1-songmuchun@bytedance.com> <20211220085649.8196-11-songmuchun@bytedance.com> <20220106110051.GA470@blackbody.suse.cz> <20220113133213.GA28468@blackbody.suse.cz> <20220119093311.GD15686@blackbody.suse.cz> In-Reply-To: <20220119093311.GD15686@blackbody.suse.cz> From: Muchun Song Date: Fri, 21 Jan 2022 13:28:05 +0800 Message-ID: Subject: Re: [PATCH v5 10/16] mm: list_lru: allocate list_lru_one only when needed To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Matthew Wilcox , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Roman Gushchin , Yang Shi , Alex Shi , Wei Yang , Dave Chinner , trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, jaegeuk@kernel.org, chao@kernel.org, Kari Argillander , linux-fsdevel , LKML , Linux Memory Management List , linux-nfs@vger.kernel.org, Qi Zheng , Xiongchun duan , Fam Zheng , Muchun Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Jan 19, 2022 at 5:33 PM Michal Koutn=C3=BD wrote= : > > On Tue, Jan 18, 2022 at 08:05:44PM +0800, Muchun Song wrote: > > I have thought about this. It's a little different to rely on objcg > > reparenting since the user can get memcg from objcg and > > then does not realize the memcg has reparented. > > When you pointed that out, I'm now also wondering how > memcg_list_lru_alloc() would be synchronized against > reparenting/renumbering of kmemcg_ids. What I suspect is that newly > allocated mlru may be stored into the xarray with a stale kmemcg_id. The synchronization is based on the lock of list_lru->lock. memcg_list_lru_free() will help us do housekeeping. > > > Maybe holding css_set_lock can do that. I do not think this > > is a good choice. > > I agree, it doesn't sound well. > > > Do you have any thoughts about this? > > Thoughts / questions of what I don't undestand well: > - Why do you allocate mlrus for all ancestors in memcg_list_lru_alloc()? It's because we need to be reparenting. > - It'd be sufficient to allocate just for the current memcg. > - Possibly allocate ancestors upon reparenting (to simplify the > allocation from slab_pre_alloc_hook itself). I agree it is nice to only allocate for current memcg, but reparenting cannot handle failure of memory allocation. > > - What is the per-kmemcg_id lookup good for? > - I observe most calls of list_lru_from_memcg_idx() come from callers > that know memcg (or even objcg). > - The non-specific use case seems list_lru_walk_node() working with > per-node and not per-memcg projection. > - Consequently that is only used over all nodes anyway > (list_lru_walk(). > - The idea behind this question is -- attach the list_lrus to > obj_cgroup (and decommission the kmemcg_id completely). > (Not necessarily part of this series but independent approach.) > I have some questions about this thought. We would attach more than one list_lrus to obj_cgroup, right? How to arrange those list_lrus, array or linked-list? Thanks.