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 79DDEC433EF for ; Fri, 11 Mar 2022 00:37:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8E518D0002; Thu, 10 Mar 2022 19:37:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D3DA78D0001; Thu, 10 Mar 2022 19:37:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDE7A8D0002; Thu, 10 Mar 2022 19:37:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id AE1BF8D0001 for ; Thu, 10 Mar 2022 19:37:49 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 80CA1604D7 for ; Fri, 11 Mar 2022 00:37:49 +0000 (UTC) X-FDA: 79230242658.11.AE5ADE5 Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) by imf10.hostedemail.com (Postfix) with ESMTP id D60ACC001C for ; Fri, 11 Mar 2022 00:37:48 +0000 (UTC) Received: by mail-vs1-f54.google.com with SMTP id a186so7938722vsc.3 for ; Thu, 10 Mar 2022 16:37:48 -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=F0hZGjhrGiVvpf8eZ80FSPAVfqOvCn8cVSDk4eFNdw1XlDi+0ZH+Ni8SMKR+K5TI5I Y1Cr4sebzjvlZD/PZXJJAznUDrNdKAkg1t2wcy6HAxR8BcNfSNC+vnL8uB1kkXU0UziA 631p/PTLtOhHE2ljdFFBeUqRlDudVzu3LW5Ipi/UMPVEVVQk09vd5RHv/mSXAayFX6R3 Xzx+6cqdynHTLSt7BGrnvzr0wsJtfm/ySLZ11Bk62kxHXvNz9nASG1ZS+FuB1BCOwM6L HvKOcGMawJMzfVYdUf2jFW68xdtXSDMQeF5ZFBs1QrlkKI4nBlVZ/4RtA1opJOEDD6NH dcYg== X-Gm-Message-State: AOAM530ZkB30Uah7uFwD7PIoG+Zgtw4/RmoUu5Lim8y7091xG8wYE+0v FhtsClOMtflh6VAQVisasjYstnohGp2iv41cTjvJcA== X-Google-Smtp-Source: ABdhPJwEZjiPQbHIsygGqzPp3H8aq0we/iEyH5B93eTNUR7mxTEl549bv+jWAgmUn9+GF3xxu2xt236nKnjQsePTdzc= 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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D60ACC001C X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=mty1HpxR; spf=pass (imf10.hostedemail.com: domain of yuzhao@google.com designates 209.85.217.54 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 94ruskr1mu1ti8yp6fq5pew1o37uj7q9 X-HE-Tag: 1646959068-818272 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 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.