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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3271EC433FE for ; Fri, 21 Jan 2022 05:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348613AbiAUF2w (ORCPT ); Fri, 21 Jan 2022 00:28:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348556AbiAUF2p (ORCPT ); Fri, 21 Jan 2022 00:28:45 -0500 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35540C06173F for ; Thu, 20 Jan 2022 21:28:45 -0800 (PST) Received: by mail-yb1-xb30.google.com with SMTP id o80so24423109yba.6 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=NJnCGzv5PqkEq7Bd66/XJLqUQJpwyzOxhpc09IDFTFQHpBlVMjYYqHk9qgRJuRjtSD IU6OA6TiPxK5V4CqikKJ2XvwyrXOucDMWz9/ceVRjdLePok3SptygkwUIEkXSvBVTFWA AliR7s6KuG30MgwIJ5LD8FiZqLGXbIYKScw5D8tLLXK9KEEJPY2FLnrPpBLSMjgKnDh0 XgCDLV4a1GRpIp0c3bc1G0TYjvO9Wyvrsqo+LmaZlt01M84gFJpEDr5Jvcgs5KOkXjRc Ibdx83ujfLHiiEOXDFTAT+kTDfIthFO7+1MXYreXMc1u6y6HbObPE/wiIS6cgrcKwfri BPug== X-Gm-Message-State: AOAM533qsoRIQDEJamSBsakds3J5hxGhw2VJzLsD/m0mCqBPBTg5ssm1 hRHMqEhTFrXXheaCZWu0LBFyGzlYVz4HVVKBHZ0tpw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.