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 8459FC4332F for ; Wed, 15 Dec 2021 12:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242309AbhLOMJt (ORCPT ); Wed, 15 Dec 2021 07:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236954AbhLOMJr (ORCPT ); Wed, 15 Dec 2021 07:09:47 -0500 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F25C06173E for ; Wed, 15 Dec 2021 04:09:46 -0800 (PST) Received: by mail-yb1-xb2a.google.com with SMTP id 131so54506293ybc.7 for ; Wed, 15 Dec 2021 04:09:46 -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; bh=medD3Xi3kZKH5q7bagszydyhriMt4qJw4H1Wjw4BIeA=; b=hFy0KgQxd2bJci/Xd+n8sv+Gu5RmYMvEDhUBuj2Yrq8ctOAyB8hlUNmxpM2IiWLKGy GE3vvn8E0z4jskkFd9srdqyZ83G3qGSVOcrD2grWx5AMKa7YPQ48/Vv0KqUhJi54LfOy dD7WRE2C4pHHS/JIsZt35udpFpfLB/bfGhx9yBgUoW8bTi5myNlDaZXqEKI6Kx46FisJ 68kZKS3svXvUdYbK5/j6C34dFY+I1Rbbh4hEBrVj5Z8GkSaIoGT6INxX0WmFow5netem tEe/Dm5Fek5uzcugw8IodwEebZjX23z7LIjzHm5KAIPoJ2dg3exHdgGp4uP3a5We1NHj TTAw== 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; bh=medD3Xi3kZKH5q7bagszydyhriMt4qJw4H1Wjw4BIeA=; b=zuvnBXpN2FBRH4/3lbGRz/fZ+Hxmnr1AsklzlWP7fu6w+p9JUB/mF6NeR8WV8fy9OW 9xE2UeItEeCqffOXnA2KnIQLPYtQOExpAxzhjuj0IPgx947aBezhiSF6NLyFZG8aB9Ga bfjlnEjT1d2I4v8/UhQEMuauoSY0ffAFEk8HHSIBqHGTNqrPCBq9RHlMp9UEYG2xBG6w aSuSHQJRPJhhnKCsYUapv4hkKTlJjGGq2m+iQlNov5Cn/aQ/0IQfxYUn3RP0MSe5buwE C1+DzXvE4ExdqI6Aqvzcap4OWuixfExtI3D+ApRkjdJBjSyjeq0LX3Jw6dKcBaO2ZI9x wr0w== X-Gm-Message-State: AOAM530cctNwkTZmo7n8Ur+stJ0NlxCIb2ICzsiAG99SJUrD/9ts9Pgz icfkyo/5oV4l4g0NmLQs8AHVGTMN+5EB7UvHJMjDTg== X-Google-Smtp-Source: ABdhPJwQ0At3Bjn2QQCan5WHYT82Z/7G6PUgdH5xVAc30+lYih6V821vw+gn8W1jOKI1DU2w2zfhyVDYOnqoiKKOUGU= X-Received: by 2002:a05:6902:52b:: with SMTP id y11mr5529088ybs.199.1639570186129; Wed, 15 Dec 2021 04:09:46 -0800 (PST) MIME-Version: 1.0 References: <20211213165342.74704-1-songmuchun@bytedance.com> <20211213165342.74704-2-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Wed, 15 Dec 2021 20:09:10 +0800 Message-ID: Subject: Re: [PATCH v4 01/17] mm: list_lru: optimize memory consumption of arrays of per cgroup lists To: Johannes Weiner Cc: Matthew Wilcox , Andrew Morton , 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@bytedance.com, Muchun Song Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 14, 2021 at 9:38 PM Johannes Weiner wrote: > > On Tue, Dec 14, 2021 at 12:53:26AM +0800, Muchun Song wrote: > > The list_lru uses an array (list_lru_memcg->lru) to store pointers > > which point to the list_lru_one. And the array is per memcg per node. > > Therefore, the size of the arrays will be 10K * number_of_node * 8 ( > > a pointer size on 64 bits system) when we run 10k containers in the > > system. The memory consumption of the arrays becomes significant. The > > more numa node, the more memory it consumes. > > The complexity for the lists themselves is still nrmemcgs * nrnodes > right? But the rcu_head goes from that to nrmemcgs. Right. > > > I have done a simple test, which creates 10K memcg and mount point > > each in a two-node system. The memory consumption of the list_lru > > will be 24464MB. After converting the array from per memcg per node > > to per memcg, the memory consumption is going to be 21957MB. It is > > reduces by 2.5GB. In our AMD servers, there are 8 numa nodes in > > those system, the memory consumption could be more significant. > > The code looks good to me, but it would be useful to include a > high-level overview of the new scheme, explain that the savings come > from the rcu heads, that it simplifies the alloc/dealloc path etc. Will do in the next version. > > With that, > > > Signed-off-by: Muchun Song Thanks. > > Acked-by: Johannes Weiner