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 175C1C433EF for ; Wed, 19 Jan 2022 09:33:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C78C6B0071; Wed, 19 Jan 2022 04:33:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6506B6B0073; Wed, 19 Jan 2022 04:33:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F16A6B0074; Wed, 19 Jan 2022 04:33:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 3B82F6B0071 for ; Wed, 19 Jan 2022 04:33:15 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E2FDA951A8 for ; Wed, 19 Jan 2022 09:33:14 +0000 (UTC) X-FDA: 79046523108.29.6B24CD8 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf16.hostedemail.com (Postfix) with ESMTP id 5C312180005 for ; Wed, 19 Jan 2022 09:33:14 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 126B21F38B; Wed, 19 Jan 2022 09:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642584793; h=from:from:reply-to: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=sBwHHJ1ePgsQCKzWB+AeBOf9B49vrtvnggHlWqo57lQ=; b=OhjQ5S+3jTKJtj13rH9+qcQS7K/pNbNNrkUDRiTRiKXztA2+TX7pFRQuzZnM5Qo6ll+iJv Fxz10ktEKFl55pu8bOYGyyKDSWT5W4HQikdMgrCfIhGaMnwdqU5JM9Bt6jpCfoB37JNh2x +Yinoc8i+oeJm9NOrEgqEyVgEYGukcM= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BCD4C13E11; Wed, 19 Jan 2022 09:33:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Xr98Ldja52FOKAAAMHmgww (envelope-from ); Wed, 19 Jan 2022 09:33:12 +0000 Date: Wed, 19 Jan 2022 10:33:11 +0100 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Muchun Song 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 Subject: Re: [PATCH v5 10/16] mm: list_lru: allocate list_lru_one only when needed Message-ID: <20220119093311.GD15686@blackbody.suse.cz> References: <20211220085649.8196-1-songmuchun@bytedance.com> <20211220085649.8196-11-songmuchun@bytedance.com> <20220106110051.GA470@blackbody.suse.cz> <20220113133213.GA28468@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 5C312180005 X-Stat-Signature: uuztrox93mmtdm4deqzxg5pfm6xqm8hn Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=OhjQ5S+3; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf16.hostedemail.com: domain of mkoutny@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mkoutny@suse.com X-Rspamd-Server: rspam06 X-HE-Tag: 1642584794-669853 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 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. > 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'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). - 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 decomission the kmemcg_id completely). (Not necessarily part of this series but independent approach.) Thanks, Michal