Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp475250pxp; Fri, 11 Mar 2022 08:02:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfVG86aV4a9MGzfYOKvwNBwl+uEelFXQ1JEbA9F1MANl22CH8tSCBBU35w48+3UEXhoCzk X-Received: by 2002:a05:6a00:1a0a:b0:4f6:ecc6:1173 with SMTP id g10-20020a056a001a0a00b004f6ecc61173mr10325641pfv.74.1647014521383; Fri, 11 Mar 2022 08:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647014521; cv=none; d=google.com; s=arc-20160816; b=Q7uicxDNzVBFTJy+09fvuLoLCZ6+Xfg7VIm4/oZ8+wQpPQEWnxluU0XynMvnlmZ7S/ 89/rzBddCH74DCAVxMpEMLjTmCackRVW3+TRAj2FYmQhyz7JpAJf9aXn7jNGHOmmTKqj oT6KreT4izAjUXmIGR2dRXKy1u5FosYdtcvI7eRmI8NzELcw4f8nszDHw/OK748v+G0l p22gjREi+neolj11vnGqxcQkfrmapMT9s6VltYAMKFK139xY97c5Mh4LQJrbDUOcnv7a bAhZQwW5VDjSy8foDvQl/9Rp4XwhKmUvG4a+w6OYX7dtyHedw5oAC75rZqNNz9tZrCHL S9hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2LimIffJ+2+Hyyt6gnHQ4aWXqCPLYzM2e759iW7Bjvs=; b=JT7eSw/74vTRTYx2NqjwNhWQnev1LxtxBz9srVAt6K6nPQ6YjvrczIbO7LyRvlz7nA UrnVyaqJ1FvSrZIg4y6Btk5/b24N3rSvy2CecjYi8CdyJMvLNgsb8MkXxSJmWh9zOU0u SeVqKnTSXJwc2aQlYlmcgi+HSF2IUa+Q6fNsbFpfBO3WI3rY+DWRAUxJuvRKjGm0dluU uQZOSTGNWmKQoQs7UFVlicjNUgsOQk32hJgWPv5W7D1SJPZ9yQpfx7JPjIuRfwgX8hSj KS8CXAnNQRuiA9al9sfjpTf5XeDvUVwCc+/aNkAXNXUm2xzNZOkYxresmdqT/5cuqmNO jX4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mty1HpxR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a170902dac200b00151e02d9710si8887735plx.37.2022.03.11.08.01.30; Fri, 11 Mar 2022 08:02:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mty1HpxR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235249AbiCKAiy (ORCPT + 99 others); Thu, 10 Mar 2022 19:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbiCKAiv (ORCPT ); Thu, 10 Mar 2022 19:38:51 -0500 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EFB813CDA for ; Thu, 10 Mar 2022 16:37:49 -0800 (PST) Received: by mail-vs1-xe33.google.com with SMTP id v62so7955030vsv.1 for ; Thu, 10 Mar 2022 16:37:49 -0800 (PST) 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:content-transfer-encoding; bh=2LimIffJ+2+Hyyt6gnHQ4aWXqCPLYzM2e759iW7Bjvs=; b=mty1HpxRPn8/WTH88zZr9s6Y/9AXI8+ZtcAXwR/9jYzMRHoIgkazky9PnIXWRBLL6l a/S/hZsKCU0Nk0IRq/Rv5fahGNUE+EenmVeNpzrbcXsNf2AtS3gZyedkIpAYS1gYXqKL zinynolnVzRXP6jgATvA8yuhMPWBZ/ZlTL9PKGP0ODk3aMdgbmX/MU66KZ3dw0fyrYHR YI7ZkrsASQv6OLRNQ8beTXmxnJ+5zu22EipsaenH6yvjYgmXGW4alIKYyGYfMLmTe/ZQ m3DQKDMT0v3vSvOALsG4dN9ZvTfxewswnTzQjahtAr3WrfEuvSfXAo5u7d3Sep3EwoEx 7Yqg== 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:content-transfer-encoding; bh=2LimIffJ+2+Hyyt6gnHQ4aWXqCPLYzM2e759iW7Bjvs=; b=1B22wmgZ8w18URDz1N4vvapXMmSEH7rqq0c7C1FgdnGFdMsK2gN4Blpx1xjXN+yV2x MVAlbpI7i8r1LPLGqPMu7GGgzqwoHEZTk0UFqtc3r3BawPSPnse8gXA1fZewBwGLSCbD atr+GsnK1Wun81Sv9JigYLZrvMPgfvBefgnDf4QXvgg+nr0SrBxrKmRz4opYf+3NvpBS k5hf6a0RyfV4+UbvRWypJuwaacG1NszXlcNA33CsTwPbmYJkM1e7qdUg7t08hGuX/6m8 pljky2+De7FDQ/aimY/Jm8KG0R9/Mo5M3jHNIXJm3zKYNXUR7iqsRR8+RLJI9i47kO3b 3wXg== X-Gm-Message-State: AOAM5315T3L0X6e8ekIbjM2HUjNB8DLQRBQEejTMGUHptMbA9VbBRJN7 ffIxkJASXFw0VGkw+E9kZToO/yU6u+QMC+Bs+gJ3tw== X-Received: by 2002:a05:6102:3a06:b0:31b:d9c6:c169 with SMTP id b6-20020a0561023a0600b0031bd9c6c169mr3806840vsu.22.1646959067809; Thu, 10 Mar 2022 16:37:47 -0800 (PST) MIME-Version: 1.0 References: <20220309021230.721028-1-yuzhao@google.com> <20220309021230.721028-14-yuzhao@google.com> In-Reply-To: From: Yu Zhao Date: Thu, 10 Mar 2022 17:37:36 -0700 Message-ID: Subject: Re: [PATCH v9 13/14] mm: multi-gen LRU: admin guide To: Mike Rapoport Cc: Andrew Morton , Linus Torvalds , Andi Kleen , Aneesh Kumar , Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , Linux ARM , "open list:DOCUMENTATION" , linux-kernel , Linux-MM , 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 10, 2022 at 5:30 AM Mike Rapoport wrote: > > Hi, > > On Tue, Mar 08, 2022 at 07:12:30PM -0700, Yu Zhao wrote: > > Add an admin guide. > > > > Signed-off-by: Yu Zhao > > Acked-by: Brian Geffon > > Acked-by: Jan Alexander Steffens (heftig) > > Acked-by: Oleksandr Natalenko > > Acked-by: Steven Barrett > > Acked-by: Suleiman Souhlal > > Tested-by: Daniel Byrne > > Tested-by: Donald Carr > > Tested-by: Holger Hoffst=C3=A4tte > > Tested-by: Konstantin Kharlamov > > Tested-by: Shuang Zhai > > Tested-by: Sofia Trinh > > Tested-by: Vaibhav Jain > > --- > > Documentation/admin-guide/mm/index.rst | 1 + > > Documentation/admin-guide/mm/multigen_lru.rst | 146 ++++++++++++++++++ > > mm/Kconfig | 3 +- > > 3 files changed, 149 insertions(+), 1 deletion(-) > > create mode 100644 Documentation/admin-guide/mm/multigen_lru.rst > > > > diff --git a/Documentation/admin-guide/mm/index.rst b/Documentation/adm= in-guide/mm/index.rst > > index c21b5823f126..2cf5bae62036 100644 > > --- a/Documentation/admin-guide/mm/index.rst > > +++ b/Documentation/admin-guide/mm/index.rst > > @@ -32,6 +32,7 @@ the Linux memory management. > > idle_page_tracking > > ksm > > memory-hotplug > > + multigen_lru > > nommu-mmap > > numa_memory_policy > > numaperf > > diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentat= ion/admin-guide/mm/multigen_lru.rst > > new file mode 100644 > > index 000000000000..4ea6a801dc56 > > --- /dev/null > > +++ b/Documentation/admin-guide/mm/multigen_lru.rst > > @@ -0,0 +1,146 @@ > > +.. SPDX-License-Identifier: GPL-2.0 > > + > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +Multi-Gen LRU > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > I'm still missing an opening paragraph the explains what is Multi-gen LRU > and why users would want it. > > Something like > > Multi-gen LRU is an efficient mechanism for page reclamation. > > More details are of course welcome :) I've add the following for the next spin: +Page reclaim decides the kernel's caching policy and ability to +overcommit memory. It directly impacts the kswapd CPU usage and RAM +efficiency. Multi-gen LRU aims to optimize page reclaim and improve +performance under memory pressure. > > +Quick start > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +Build the kernel with the following configurations. > > + > > +* ``CONFIG_LRU_GEN=3Dy`` > > +* ``CONFIG_LRU_GEN_ENABLED=3Dy`` > > + > > +All set! > > + > > +Runtime options > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +``/sys/kernel/mm/lru_gen/`` contains stable ABIs described in the > > +following subsections. > > + > > +Kill switch > > +----------- > > +``enable`` accepts different values to enable or disabled the > > ^ disable Good catch. Will fix it up. > > +following components. The default value of this file depends on > > +``CONFIG_LRU_GEN_ENABLED``. All the components should be enabled > > +unless some of them have unforeseen side effects. Writing to > > +``enable`` has no effect when a component is not supported by the > > +hardware, and valid values will be accepted even when the main switch > > +is off. > > + > > +=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +Values Components > > +=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +0x0001 The main switch for the multi-gen LRU. > > +0x0002 Clearing the accessed bit in leaf page table entries in large > > + batches, when MMU sets it (e.g., on x86). This behavior can > > + theoretically worsen lock contention (mmap_lock). If it is > > + disabled, the multi-gen LRU will suffer a minor performance > > + degradation. > > +0x0004 Clearing the accessed bit in non-leaf page table entries as > > + well, when MMU sets it (e.g., on x86). This behavior was not > > + verified on x86 varieties other than Intel and AMD. If it is > > + disabled, the multi-gen LRU will suffer a negligible > > + performance degradation. > > +[yYnN] Apply to all the components above. > > +=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +E.g., > > +:: > > + > > + echo y >/sys/kernel/mm/lru_gen/enabled > > + cat /sys/kernel/mm/lru_gen/enabled > > + 0x0007 > > + echo 5 >/sys/kernel/mm/lru_gen/enabled > > + cat /sys/kernel/mm/lru_gen/enabled > > + 0x0005 > > + > > +Thrashing prevention > > +-------------------- > > +Personal computers are more sensitive to thrashing because it can > > +cause janks (lags when rendering UI) and negatively impact user > > +experience. The multi-gen LRU offers thrashing prevention to the > > +majority of laptop and desktop users who do not have ``oomd``. > > + > > +Users can write ``N`` to ``min_ttl_ms`` to prevent the working set of > > +``N`` milliseconds from getting evicted. The OOM killer is triggered > > +if this working set cannot be kept in memory. In other words, this > > +option works as an adjustable pressure relief valve, and when open, it > > +terminates applications that are hopefully not being used. > > + > > +Based on the average human detectable lag (~100ms), ``N=3D1000`` usual= ly > > +eliminates intolerable janks due to thrashing. Larger values like > > +``N=3D3000`` make janks less noticeable at the risk of premature OOM > > +kills. > > What is the default value of min_ttl_ms? Right. I've added the following for the next spin: +The default value ``0`` means disabled.