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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 278F5C433ED for ; Sat, 1 May 2021 03:28:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B38AB61073 for ; Sat, 1 May 2021 03:28:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B38AB61073 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 459196B0070; Fri, 30 Apr 2021 23:28:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F64A6B0071; Fri, 30 Apr 2021 23:28:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2961C6B0072; Fri, 30 Apr 2021 23:28:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 116AC6B0070 for ; Fri, 30 Apr 2021 23:28:41 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C218AD38 for ; Sat, 1 May 2021 03:28:40 +0000 (UTC) X-FDA: 78091230000.07.E705718 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 3E6CBC0007C9 for ; Sat, 1 May 2021 03:28:34 +0000 (UTC) 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: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HNQVUXqF; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3E6CBC0007C9 X-Stat-Signature: 9k81tedzkp38nyeayns3cpdfstrqgrx1 Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619839714-825659 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 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.