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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4508C433EF for ; Wed, 27 Apr 2022 01:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344391AbiD0BWL (ORCPT ); Tue, 26 Apr 2022 21:22:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356601AbiD0BWI (ORCPT ); Tue, 26 Apr 2022 21:22:08 -0400 Received: from mail-ua1-x932.google.com (mail-ua1-x932.google.com [IPv6:2607:f8b0:4864:20::932]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25114174430 for ; Tue, 26 Apr 2022 18:18:59 -0700 (PDT) Received: by mail-ua1-x932.google.com with SMTP id w21so92431uan.3 for ; Tue, 26 Apr 2022 18:18:59 -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=k/FmqkevWdHvE8MkA0TGJF9vIpUv3U8V0aZFDtaH3BWhzGGc5bXKsNIbXetnQ32ega bnusnzXdQ55+TtjWfNRm73FBTAQZVLERuafESWdJ4HM7vamrJaFHka5DlHIrHcmKxXV0 Qmc3wfRb36bSo8k77/+v8JTLTw1d6rv2SWuBMz2mxxSKIRi3ty3tPwLHAJD8jOecjHiy 44rsMcXgkteAm7QVaPo78ElscFEFbxbgQy4p4PDIdndUqBjxjrPl/Pe1lGZgrHscJ8rA gYOxz8Fx4vdl+gC/qdUpl9MP0szuRFv+3kCIa1tvH6hocsd2GtV6t/Lwk8FForzV4qew jI3w== X-Gm-Message-State: AOAM531IQ1SB2rPBlA/LgyGO8ybl4xtujyaHCBNGDqoH0+02p7hwxF8i XheTW2f/5ddD2UYi+PgFB1lB+ibEfqvuFTfdm1MEMQ== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A153C433F5 for ; Wed, 27 Apr 2022 01:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lsXNZ4yQL2jEnDc+bmwQcnUZzJlU+TyeBM/rJbsyYxg=; b=FnhpesBFiyQYCt wRbfoGv2k42GaKRZXc6K8ziwEshlJxCEWazMQSiskHtamFpeaoBHx+4rOZ4kkJbPZfvMNHTxvfscc uyNy3HgR5qM2A/ynNhheQHw6OMnqXh51D8khHd2gi2PsC1nFFGCAYa5W2C7oCOXrFyINKPUvL4+ip 9yaw1H+zYzCM5Bbu+TgPt0C+fID7ERcv+tqpbvveqpakgz0qrvJ7Skfbrk4YDH0MSCNBdEE/abdfb vtGEkROfGESDPIL6CBAJmJml8vUtVI9dEVDWhQi50wCLGKl/1nllXKz1MMWE16zpfEmiAZUyesyRA 4nq2z2jIf9IJdb84fDQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njWKg-00GsZp-Cj; Wed, 27 Apr 2022 01:19:06 +0000 Received: from mail-ua1-x92c.google.com ([2607:f8b0:4864:20::92c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njWKc-00GsXi-4x for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 01:19:04 +0000 Received: by mail-ua1-x92c.google.com with SMTP id g22so80195uam.12 for ; Tue, 26 Apr 2022 18:18:59 -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=ZT+f3uxgftD/bVm77nsPRuvC0tztZ5A2JY9+uy8rl4A7Jf+74HaEGyHqmolgPjiB9m 56ebwwITJl78ZXmCCKxFpwkUrwvrvVN2TlajQrB6sJm1zgWPmASZqxKNV6a+LNIRihAO bAVF9oqwwWwYg/dy0MFJici60t/kOSfFleVozYpAldu6DkDwNu7ve6YJziqm9prqZ/FO zQ1zLAYjOS0mnFX8crf/KLm4H4JV4FCfJTgIqjA5kv2JEkKVhhjJKTM+dE1F1T7eP8Ks qh9fPEDAvA1B/CCN6UgVHtoL9v71BQ0IyBGebZ/18mx/JCgnZGBqu7eeM55GFmRYLUHC f2kg== X-Gm-Message-State: AOAM531pKKbGBJ9qntBiX18l947JAKuxLF3c6GYRw0pfNxiAEpN2dvfp G0/2n8MItIaDdUCGRTbW0fOO8WY9iz4iYIxT0aV1Bw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220426_181902_258786_0609F61B X-CRM114-Status: GOOD ( 36.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel