Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp894902pxy; Fri, 30 Apr 2021 20:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5XIK5lWQwh95xRYV/Ns9wtgIwUDYx0MpNNytXKphVVQWc15A/AAjtdpPu44s1GfqDGUTz X-Received: by 2002:a62:ea1a:0:b029:27a:bcea:5d3d with SMTP id t26-20020a62ea1a0000b029027abcea5d3dmr8014936pfh.69.1619839801617; Fri, 30 Apr 2021 20:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619839801; cv=none; d=google.com; s=arc-20160816; b=ScdZQKTwhqUtPcv2aQM0hFhlVrSX7zvAc6Y/lQ8OgDcqATQdGeZA2luDZT9VM/9uHN qcm4Cb1er7/MEd30CXNjtrKFxXUIg3TDbie99JiQOE7vAJP2plDqDwJrL5YOern6P8m/ ZsWQk9hu8oMeOo5797bEnFyWnGxMUOo35s38dutUK31BLZbYYIUVdu/YoRQJZvW+4iWn yHg58RV9bMm9Y8HaJnxK4K55pRo+SOEgIS8GBG1sS9hZ3wCso1VauGSyrqObRp4B2K4X oOvjHVVKX98hcl4q7xHOyndWZ07n9EFS8alJ9fcM7eus5IDcj315Y7xpz5/ex6CgO/m8 6u/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pCVpEmSBNkHbA2xrBVXJgYpV5Pdig67bJUCkTSad33Y=; b=SJ2H1oAPlxKlnGNjEhsQkMSCE4tV/ZSJG5DlYX7fHuHNUFgx899DSJFWRtqw7tJI+w R9a9ST8XcpvJPSLDrXN7K0t7ilXK+iFQJkcW/wgXMmvZ+ejBcFeDUM7VaL/CPnFIbdYr dydKtXs9EwTYZPDj/GEtrDL+kOXNVqUD27XhAsM+kevNoK/WkbWAD7K6eQdMBK+t5zZl 4XBcKJkcwBzfM30OpionrYTnREmKMVXWrO4z4uQFQvUO+m0QCRfTtSSEe/fcK7VZklZ8 W0tFlB1BiSiw7hCYUPAV+u/4k6Kuj//J+47LTZNb+ak6JE4IRhA/AFAd0Ipx/g5dOJLl nE/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HNQVUXqF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si5470124plr.71.2021.04.30.20.29.48; Fri, 30 Apr 2021 20:30:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HNQVUXqF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231509AbhEAD3Z (ORCPT + 99 others); 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-kernel@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.