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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41F1FC433F5 for ; Tue, 26 Apr 2022 23:42:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7823E6B0073; Tue, 26 Apr 2022 19:42:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 732906B0075; Tue, 26 Apr 2022 19:42:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D28C6B0078; Tue, 26 Apr 2022 19:42:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 4E4BC6B0073 for ; Tue, 26 Apr 2022 19:42:46 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 1DEA28117A for ; Tue, 26 Apr 2022 23:42:46 +0000 (UTC) X-FDA: 79400657532.18.8C420BC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 5BFB340048 for ; Tue, 26 Apr 2022 23:42:38 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E337619E5; Tue, 26 Apr 2022 23:42:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A33F6C385A0; Tue, 26 Apr 2022 23:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651016564; bh=rkWOOpymajYPINPF/6OKmwxFHU7UQnqmc3SblTgW3GI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dh/nLmQngZ0x60vGJBUI8w3qIcq8X5L3WO8oRG8EFdQ8xQS4HuEiC+0LmW+KdbPuS DAdi1MD0ubzM0Cd93Pc5pxiRX/9JMruLVwwOGe4+clWiHvKERN/AO93Lt08ZIKpY0E rtXOwE7HdtS4x9VHAAKpSVHkmmMAV0mO16pJ2Lb0= Date: Tue, 26 Apr 2022 16:42:41 -0700 From: Andrew Morton To: Yu Zhao Cc: Stephen Rothwell , Linux-MM , Andi Kleen , Aneesh Kumar , Barry Song <21cnbao@gmail.com>, Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Linus Torvalds , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , Mike Rapoport , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , Linux ARM , "open list:DOCUMENTATION" , linux-kernel , Kernel Page Reclaim v2 , "the arch/x86 maintainers" , Brian Geffon , Jan Alexander Steffens , Oleksandr Natalenko , Steven Barrett , Suleiman Souhlal , Daniel Byrne , Donald Carr , Holger =?ISO-8859-1?Q?Hoffst=E4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh , Vaibhav Jain Subject: Re: [PATCH v10 05/14] mm: multi-gen LRU: groundwork Message-Id: <20220426164241.99e6a283c371ed75fa5c12a0@linux-foundation.org> In-Reply-To: References: <20220407031525.2368067-1-yuzhao@google.com> <20220407031525.2368067-6-yuzhao@google.com> <20220411191615.a34959bdcc25ef3f9c16a7ce@linux-foundation.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5BFB340048 X-Stat-Signature: xktjwrpcbbxxmons7qszd1a1ahxcgp15 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="Dh/nLmQn"; spf=pass (imf17.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1651016558-148473 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 Tue, 26 Apr 2022 16:39:07 -0600 Yu Zhao wrote: > On Mon, Apr 11, 2022 at 8:16 PM Andrew Morton wrote: > > > > On Wed, 6 Apr 2022 21:15:17 -0600 Yu Zhao wrote: > > > > > Evictable pages are divided into multiple generations for each lruvec. > > > The youngest generation number is stored in lrugen->max_seq for both > > > anon and file types as they are aged on an equal footing. The oldest > > > generation numbers are stored in lrugen->min_seq[] separately for anon > > > and file types as clean file pages can be evicted regardless of swap > > > constraints. These three variables are monotonically increasing. > > > > > > ... > > > > > > +static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio, bool reclaiming) > > > > There's a lot of function inlining here. Fortunately the compiler will > > ignore it all, because some of it looks wrong. Please review (and > > remeasure!). If inlining is reqlly justified, use __always_inline, and > > document the reasons for doing so. > > I totally expect modern compilers to make better decisions than I do. > And personally, I'd never use __always_inline; instead, I'd strongly > recommend FDO/LTO. My (badly expressed) point is that there's a lot of inlining of large functions here. For example, lru_gen_add_folio() is huge and has 4(?) call sites. This may well produce slower code due to the icache footprint. Experiment: moving lru_gen_del_folio() into mm/vmscan.c shrinks that file's .text from 80612 bytes to 78956. I tend to think that out-of-line regular old C functions should be the default and that the code should be inlined only when a clear benefit is demonstrable, or has at least been seriously thought about. > > > --- a/mm/Kconfig > > > +++ b/mm/Kconfig > > > @@ -909,6 +909,14 @@ config ANON_VMA_NAME > > > area from being merged with adjacent virtual memory areas due to the > > > difference in their name. > > > > > > +config LRU_GEN > > > + bool "Multi-Gen LRU" > > > + depends on MMU > > > + # the following options can use up the spare bits in page flags > > > + depends on !MAXSMP && (64BIT || !SPARSEMEM || SPARSEMEM_VMEMMAP) > > > + help > > > + A high performance LRU implementation to overcommit memory. > > > + > > > source "mm/damon/Kconfig" > > > > This is a problem. I had to jump through hoops just to be able to > > compile-test this. Turns out I had to figure out how to disable > > MAXSMP. > > > > Can we please figure out a way to ensure that more testers are at least > > compile testing this? Allnoconfig, defconfig, allyesconfig, allmodconfig. > > > > Also, I suggest that we actually make MGLRU the default while in linux-next. > > The !MAXSMP is to work around [1], which I haven't had the time to > fix. That BUILD_BUG_ON() shouldn't assert sizeof(struct page) == 64 > since the true size depends on WANT_PAGE_VIRTUAL as well as > LAST_CPUPID_NOT_IN_PAGE_FLAGS. My plan is here [2]. > > [1] https://lore.kernel.org/r/20190905154603.10349-4-aneesh.kumar@linux.ibm.com/ > [2] https://lore.kernel.org/r/Ygl1Gf+ATBuI%2Fm2q@google.com/ OK, thanks. This is fairly urgent for -next and -rc inclusion. If practically nobody is compiling the feature then practically nobody is testing it. Let's come up with a way to improves the expected coverage by a lot.