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 9953FC433F5 for ; Wed, 27 Apr 2022 01:19:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF47B6B0073; Tue, 26 Apr 2022 21:18:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA1E16B0075; Tue, 26 Apr 2022 21:18:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C44A86B0078; Tue, 26 Apr 2022 21:18:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id B0A4E6B0073 for ; Tue, 26 Apr 2022 21:18:59 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 829BD27F26 for ; Wed, 27 Apr 2022 01:18:59 +0000 (UTC) X-FDA: 79400899998.12.87CB305 Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) by imf23.hostedemail.com (Postfix) with ESMTP id 8DF16140046 for ; Wed, 27 Apr 2022 01:18:53 +0000 (UTC) Received: by mail-ua1-f41.google.com with SMTP id i16so90573uat.5 for ; Tue, 26 Apr 2022 18:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dkaom6jGHiqXJJvzANNgQPiwnUpwsfzq/QVSUZefRFM=; b=CNABcSddX5b6n+TQdqiZuhToeSYgN8qqRcrhLTf2cbtNpqOpITOw0HoUW1VxeheSqr +kIHNlxEm7JA7PbBw9bvynk3vAS1zjmQEequdqIu7eonYeGOKX1RbYd4eXS4EL7Cnlm7 Wi8acyLCuqs+uqGQDo0rBN9uQkgZ45oK5xeF1xKHiAeYfZZu4409vPwkLv8mkEOmuhRN gxvSR+Fa/kK898TJTUuGLY5PaLuM7wYYzf5ZxA16B0IMmvu8tPBoxRFky8sOUqW9+Xyz 04/FOMsq62xn0mP4AjRhUQRea/OIEEJpkItR6Q3DMQikK/BMkmfkfFRsGadzVE77x5+x 1sIg== 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=dkaom6jGHiqXJJvzANNgQPiwnUpwsfzq/QVSUZefRFM=; b=S19O82EtYc0CbvEVGTSUasQ3rFWCAYfTK9v59YAmVceMqvlzAmxc7948L6tziSKfcK 2QvoaNWG4rQPvCRS1cg+iXcbXC21rn6S1W7LRc/dIKnMBAf1VOIg1ltZtGMGX+8bKsik O8MNOMG6eOssABfPCu2YtSP81XGoogBS4/Mo5gkc9tjMqoNlU/HWIbbeIUelbOSQsUTb hyBy5u4TyRmX0cQU6Umpz46A1yKpk+FkWxKSsNsnNtdpgrt1e2vf/MrazqoUkfPInjdh w6mV/5JHrolKQAlEWpaXqZsLkrTt1N0Lu+VF7TSuLoeArA914o20NrrcVBekLwavDk0G hIqw== X-Gm-Message-State: AOAM5324sguOK9FpQf/Fsk7Oa+RX318gz+piT6zLbhvT2KisIuTipNvX sqwbQEd8oOBf46A0vs3RRUuc2C90/5P7Za7LMjP8dA== X-Google-Smtp-Source: ABdhPJwdvDGouIH2ciLL1gxZrezu13HylZKO7y/rVDTnJd8+6pCaQT17EsqSX68jOcxM2tD03lALxOCQHXmVvOnDW5M= X-Received: by 2002:ab0:2695:0:b0:352:5fc9:4132 with SMTP id t21-20020ab02695000000b003525fc94132mr7877586uao.29.1651022338107; Tue, 26 Apr 2022 18:18:58 -0700 (PDT) MIME-Version: 1.0 References: <20220407031525.2368067-1-yuzhao@google.com> <20220407031525.2368067-6-yuzhao@google.com> <20220411191615.a34959bdcc25ef3f9c16a7ce@linux-foundation.org> <20220426164241.99e6a283c371ed75fa5c12a0@linux-foundation.org> In-Reply-To: <20220426164241.99e6a283c371ed75fa5c12a0@linux-foundation.org> From: Yu Zhao Date: Tue, 26 Apr 2022 19:18:21 -0600 Message-ID: Subject: Re: [PATCH v10 05/14] mm: multi-gen LRU: groundwork To: Andrew Morton 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 , =?UTF-8?Q?Holger_Hoffst=C3=A4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh , Vaibhav Jain Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: zy8qqj1f8cehhbxm6d1tg1x4kopjec6s X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8DF16140046 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CNABcSdd; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of yuzhao@google.com designates 209.85.222.41 as permitted sender) smtp.mailfrom=yuzhao@google.com X-HE-Tag: 1651022333-138031 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, Apr 26, 2022 at 5:42 PM Andrew Morton wrote: > > 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. I can move those functions to vmscan.c if you think it would improve performance. I don't have a strong opinion here -- I was able to measure the bloat but not the performance impact. > > > > --- 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. Let me just remove !MAXSMP, since I wasn't able to reproduce this build error [1] anymore. [1] https://lore.kernel.org/r/1792f0b2e29.d72f70c9807100.8179330337708563324@xanmod.org/