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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48D70C43460 for ; Sat, 1 May 2021 03:28:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1297D61073 for ; Sat, 1 May 2021 03:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbhEAD3Z (ORCPT ); Fri, 30 Apr 2021 23:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbhEAD3Y (ORCPT ); Fri, 30 Apr 2021 23:29:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98579C06174A; Fri, 30 Apr 2021 20:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=pCVpEmSBNkHbA2xrBVXJgYpV5Pdig67bJUCkTSad33Y=; b=HNQVUXqFNihjOn1gK2a+jWUJ52 8sH4dGp5W5Ok9alYuoGDlG7K4N7e5UHqIZkkRmvb6F7+0qdiQ8wdKKufTxNnl7dcTCzSXfOmXse3d 35KqSQw6HHQpLk2ZRQWtHDbbYzWSq7t8aI/03gBf5KnxSgs4JH/e28nYLyfUtr7jL8CEIEay+N9P3 x9q0TQdjpyJuhYJrPLyjoCD7ksBuqlJiTjIoaQJ17Gn9Z9mixbjcuftGo32sSKhuPI9tIxaJ6TrTU AEJM9Y0RdWYczLhQ0PlGUigNn9I9xIzx5VYfgI3XU3OrXCTPeLi6GZdqg9UuLBwj7GwIEXhKeg0zW aRZrKAxQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lcgIH-00BuPw-3b; Sat, 01 May 2021 03:27:59 +0000 Date: Sat, 1 May 2021 04:27:49 +0100 From: Matthew Wilcox To: Muchun Song Cc: Dave Chinner , Roman Gushchin , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Yang Shi , alexs@kernel.org, Alexander Duyck , Wei Yang , linux-fsdevel , LKML , Linux Memory Management List Subject: Re: [External] Re: [PATCH 0/9] Shrink the list lru size on memory cgroup removal Message-ID: <20210501032749.GQ1847222@casper.infradead.org> References: <20210428094949.43579-1-songmuchun@bytedance.com> <20210430004903.GF1872259@dread.disaster.area> <20210430032739.GG1872259@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Apr 30, 2021 at 04:32:39PM +0800, Muchun Song wrote: > Before start, we should know about the following rules of list lrus. > > - Only objects allocated with __GFP_ACCOUNT need to allocate > the struct list_lru_node. > - The caller of allocating memory must know which list_lru the > object will insert. > > So we can allocate struct list_lru_node when allocating the > object instead of allocating it when list_lru_add(). It is easy, because > we already know the list_lru and memcg which the object belongs > to. So we can introduce a new helper to allocate the object and > list_lru_node. Like below. I feel like there may be a simpler solution, although I'm not really familiar with the list_lru situation. The three caches you mention: > I have looked at the code closely. There are 3 different kmem_caches that > need to use this new API to allocate memory. They are inode_cachep, > dentry_cache and radix_tree_node_cachep. I think that it is easy to migrate. are all filesystem. So if there's a way of knowing which filesystems are exposed to each container, we can allocate the list_lru structures at "mount" time rather than at first allocation for a given cache/lru/memcg combination.