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 69598C433EF for ; Mon, 21 Mar 2022 11:47:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB2106B0072; Mon, 21 Mar 2022 07:47:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D61DE6B0073; Mon, 21 Mar 2022 07:47:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2AAD6B0074; Mon, 21 Mar 2022 07:47:37 -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 B5C766B0072 for ; Mon, 21 Mar 2022 07:47:37 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 6B2DB12148E for ; Mon, 21 Mar 2022 11:47:37 +0000 (UTC) X-FDA: 79268218554.12.6530C8A Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 1E6F414000B for ; Mon, 21 Mar 2022 11:47:36 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id o5so27535590ybe.2 for ; Mon, 21 Mar 2022 04:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=88d829WnB79xpVGm1h0821EVQqb5oWwm0bb9EwNJMDo=; b=qhGeg5cKrVFOw2yjKtU+GQcTq/4SPpNyUWoLrArrXPKczeCKtnrtpPcY+bo/QzhXx8 cz2PbSvznBni6+X1UQZSEakm1Ol9znZz1TpkwHZqJtBYMxBezuuIf6+Gzjz0XROP1vso xXADlcbnv+8RWGxu1mG+cYH3kVfR72gVxF8nuiMGHKs722ZBmObGn9pAtyGmMRQu6pVB I42OdbIkrTIH+V8YoTztNOfm8ItTILuxMqkNNxPalgLdJ/f+DAQWj1t/xTE7tUtlPt+S WftMZe7Ebmeht1nx8P0v1nm7Qy1u9A7Mew3JGe6ClwSoBOrB+a72EEKz9XkAXy5xTGQv vzMg== 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=88d829WnB79xpVGm1h0821EVQqb5oWwm0bb9EwNJMDo=; b=SvkVdUSZRGhnPKlNYPJFS5mVAdRuCO7vY6bjqcxiLHK+2jL7Jj8wenKT0bWAKuJ2Gs 6mU+dnnzT7AXetwdZCh07wpdiSp33hOAv51S2AfJ/iF78GfE5fXWCUhGln1bT2s9mLXy m0zPY3bJHLXuz1omEc6d1dFdGrHGrKhExCELXUSLGuUFE4GGZ2DrNVXrs0bVgJyLiPUA m3turFXxKivm9n5JRyFUrX7g1Q5RuGhUzFf8+nkoOhncpdBwAUyW169ID6Bbl+ST0pD5 BBMc+77EaAgjEWjQxjQuRtwhmAIP+4VbfuQHcVDVjNfJ4z/o7pjNfAWaihWQPmveGkV+ w35Q== X-Gm-Message-State: AOAM531zZOnHn7yQ0Jff12YtN5x3aRwO30ba3NwLOq7Kql7+8jt0YlzO iVyt9z0/QnwqRCkAtA/i29dWKDrDtZH4Hms76gI= X-Google-Smtp-Source: ABdhPJy4mCfB7UbhQkgDYhKqu0gWC3hL0WsSLUBqsXIk8w/CzUnJZKCMh6+zrUsxA/j/tMtD4xdz6T/C5TwrjaDLkbo= X-Received: by 2002:a5b:807:0:b0:633:747:c7d1 with SMTP id x7-20020a5b0807000000b006330747c7d1mr22101647ybp.294.1647863256380; Mon, 21 Mar 2022 04:47:36 -0700 (PDT) MIME-Version: 1.0 References: <20220309021230.721028-1-yuzhao@google.com> <20220309021230.721028-6-yuzhao@google.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Tue, 22 Mar 2022 00:47:25 +1300 Message-ID: Subject: Re: [PATCH v9 05/14] mm: multi-gen LRU: groundwork To: Yu Zhao 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 , Mike Rapoport , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , LAK , Linux Doc Mailing List , LKML , Linux-MM , Kernel Page Reclaim v2 , x86 , 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-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1E6F414000B X-Stat-Signature: 5ozxeosdrexcbg6xdz5raj7con7nfeza Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qhGeg5cK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com X-HE-Tag: 1647863256-57058 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 Mon, Mar 21, 2022 at 10:04 PM Yu Zhao wrote: > > On Wed, Mar 16, 2022 at 5:25 PM Barry Song <21cnbao@gmail.com> wrote: > > > ... > > > +static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio, bool reclaiming) > > > +{ > > > + int gen; > > > + unsigned long old_flags, new_flags; > > > + int type = folio_is_file_lru(folio); > > > + int zone = folio_zonenum(folio); > > > + struct lru_gen_struct *lrugen = &lruvec->lrugen; > > > + > > > + if (folio_test_unevictable(folio)) > > > + return false; > > > + /* > > > + * There are three common cases for this page: > > > + * 1. If it's hot, e.g., freshly faulted in or previously hot and > > > + * migrated, add it to the youngest generation. > > > > usually, one page is not active when it is faulted in. till its second > > access is detected, it can be active. > > The active/inactive LRU *assumes* this; MGLRU *assumes* the opposite, > and there is no "active" in MGLRU -- we call it hot to avoid confusion > :) yep. > > > > + * 2. If it's cold but can't be evicted immediately, i.e., an anon page > > > + * not in swapcache or a dirty page pending writeback, add it to the > > > + * second oldest generation. > > > + * 3. Everything else (clean, cold) is added to the oldest generation. > > > + */ > ... > > > +#define LRU_GEN_MASK ((BIT(LRU_GEN_WIDTH) - 1) << LRU_GEN_PGOFF) > > > +#define LRU_REFS_MASK ((BIT(LRU_REFS_WIDTH) - 1) << LRU_REFS_PGOFF) > > > > The commit log said nothing about REFS flags and tiers. > > but the code is here. either the commit log lacks something > > or the code should belong to the next patch? > > It did: > A few macros, i.e., LRU_REFS_*, used later are added in this patch > to make the patchset less diffy. sorry for missing that. > > > > @@ -462,6 +462,11 @@ void folio_add_lru(struct folio *folio) > > > VM_BUG_ON_FOLIO(folio_test_active(folio) && folio_test_unevictable(folio), folio); > > > VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); > > > > > > + /* see the comment in lru_gen_add_folio() */ > > > + if (lru_gen_enabled() && !folio_test_unevictable(folio) && > > > + lru_gen_in_fault() && !(current->flags & PF_MEMALLOC)) > > > + folio_set_active(folio); > > > > So here is our magic to make folio active as long as it is > > faulted in? i really don't think the below comment is good, > > could we say our purpose directly and explicitly? > > > > /* see the comment in lru_gen_add_folio() */ > > I generally keep comments in a few major locations and reference them > from many other minior locations so that it's easier to manage in the > long run. It is a hassle for reviews but once in the tree you can jump > to lru_gen_add_folio() with ctags/cscope or find all places that > reference it by grepping. Assuming we state the purpose, which is to > make lru_gen_add_folio() add the page to the youngest generation, you > still want to go to lru_gen_add_folio() to check if this is really the > case. So why bother :) well understood though my pain was that I needed to email you to get confirmed this is really the case. Thanks Barry