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 93BA0C433EF for ; Fri, 21 Jan 2022 05:28:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03E7E6B007D; Fri, 21 Jan 2022 00:28:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2D4E6B007E; Fri, 21 Jan 2022 00:28:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF5266B0080; Fri, 21 Jan 2022 00:28:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id CE14D6B007D for ; Fri, 21 Jan 2022 00:28:46 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7CD21180991FF for ; Fri, 21 Jan 2022 05:28:46 +0000 (UTC) X-FDA: 79053164652.29.4514437 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by imf23.hostedemail.com (Postfix) with ESMTP id 6C587140015 for ; Fri, 21 Jan 2022 05:28:45 +0000 (UTC) Received: by mail-yb1-f170.google.com with SMTP id p5so24276152ybd.13 for ; Thu, 20 Jan 2022 21:28:44 -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=69p5qudLsVAsA9IUYm15DH9gMvGjCOQG+XmgsHvKx14Wd7YG26X0X1jb+1b4pFoa/H 4u+pKD8yRowzk3xj5jyluFQQQj0maqyz58cIlJVnZmeqfRowJC09rZGjkDLp8usXY+RT LvcRs7qDjRMqAEvH3QR89J4ME8sB11TrWJJ5XKTOEakVv+KSiLxdimVtUsb1S7Hzj0FY Baq++lKVlrwHcLtTF8Lwxf3Db88k7zRCVVHfgh5ZKneuRGpWU2fbrLlIiyPj6T61Maag m2oQiNX++sTVBdfMC2F1eFzEtd3vcNRMzoMy3fSEpG5iwzhwMCJkxtbBr68Nc6Omk+i6 Wa7A== X-Gm-Message-State: AOAM531x14ClRiQC8VS5EXBZiaHOEPtc8bRw8UIx8N4ceofQ8kMtQppn yWqwWtVNe5bF/ZYLpwgLzuGFDZBBWg+sLJGuMq/foQ== X-Google-Smtp-Source: ABdhPJw4xKwty2ZweVj6NPuQV3OZbnRuxyMndGlPkKNDC99atTPudj3h6vdLwZZaESLpVyhSeONa9YZMWMdxCxOzFiM= 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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6C587140015 X-Stat-Signature: quaysq85rw5ycckbcza1tqou6d19orft Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=nYs10YR6; spf=pass (imf23.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1642742925-558659 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 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.