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 X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B760AC433DB for ; Tue, 16 Mar 2021 21:29:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4636664F90 for ; Tue, 16 Mar 2021 21:29:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4636664F90 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B5F676B0036; Tue, 16 Mar 2021 17:29:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B0ECA6B006C; Tue, 16 Mar 2021 17:29:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 961536B006E; Tue, 16 Mar 2021 17:29:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 774BA6B0036 for ; Tue, 16 Mar 2021 17:29:27 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2BB44181AEF30 for ; Tue, 16 Mar 2021 21:29:27 +0000 (UTC) X-FDA: 77927028774.16.AA094E4 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf10.hostedemail.com (Postfix) with ESMTP id AF1A7407F8FF for ; Tue, 16 Mar 2021 21:29:26 +0000 (UTC) Received: by mail-il1-f182.google.com with SMTP id z9so14110843iln.1 for ; Tue, 16 Mar 2021 14:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tzU2FBGLVgsAwsa24/PHLvin+0F6bwNLVKxARgFVukY=; b=Iyz2Zs1s28Fl10igpCVQyq6ndVLdYNk6mPsmV3FwXdNPfiRN0FBiGQarEo4oH7RscU 4TkyWXtlMyPudsn/OCsnQkGfYqxEQSO8Fmbhu8HHNWcoq4Z7jVkgCZrl4Z8DKjX/TGdZ V2kASyslsKMVlWSDu/KB9gfs0VopOGsItsU2JNPyDmN6Do8muARVKDD1Yn+Ch7kjP6WR jOr7y/xo9X5TO83g5wavYLgmj/cyABZeSp+04slQZSxqIQa9Sd2JBpiWJzoiNCnUkRbi E28S9luOXIq5FJjeVqm+X+nYFXIfWnsA/ifeNT2kHweUYGEuZsb4XbTyHer6ef1vvEjF io/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tzU2FBGLVgsAwsa24/PHLvin+0F6bwNLVKxARgFVukY=; b=qmyxgrb7H4YPJVsDmujJw3lVsw/UiJO5l46SqXg6KRF2hEFx2tmyGsiCnXxDVIwoEE FmIn3THBks8YVoZt2+kMUfkkWme9+d0+QIiwNoV2q4W/Xcz7KWta9e+MHkjrpCQ/k4sL 1AS7UXUvV26afPTSa9HcCaREqjB3fNvEnItCQP5I1rSjo37kSAyNNNJRTjmVNu30j37N rmsrU3Wfmi9HDQfrfhSE6bkw7E7FVdYO2/hwk+32cMgh9j+XW8EphZxI9Ug6UPX4JLMS YFMkHpEJ5/S/wsZCvK6rCt/1jd2jnnER1EQt8k/P2GLm7tdsdsj3jxWmq4i8OtcWqOaG EnjQ== X-Gm-Message-State: AOAM530+Dc7v9vuI1hgwMFJemZehRtt5ntf25Iui4V3VnGoRZLZ3Lh5R dU3W6p7nJ0Tjr3ourVvxiUL9qQ== X-Google-Smtp-Source: ABdhPJyEKrKhe5XXeDVQv7JPQKsd1QHmrjTmuHKTJS+x8m8ZEtoBVhwNXiT5smUnWhRmJbIzzyLBqA== X-Received: by 2002:a92:7306:: with SMTP id o6mr5508056ilc.2.1615930165923; Tue, 16 Mar 2021 14:29:25 -0700 (PDT) Received: from google.com ([2620:15c:183:200:85db:6a0d:7a4d:5606]) by smtp.gmail.com with ESMTPSA id t14sm9971955ilq.13.2021.03.16.14.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:29:25 -0700 (PDT) Date: Tue, 16 Mar 2021 15:29:20 -0600 From: Yu Zhao To: Matthew Wilcox Cc: linux-mm@kvack.org, Alex Shi , Andrew Morton , Dave Hansen , Hillf Danton , Johannes Weiner , Joonsoo Kim , Mel Gorman , Michal Hocko , Roman Gushchin , Vlastimil Babka , Wei Yang , Yang Shi , Ying Huang , linux-kernel@vger.kernel.org, page-reclaim@google.com Subject: Re: [PATCH v1 11/14] mm: multigenerational lru: page activation Message-ID: References: <20210313075747.3781593-1-yuzhao@google.com> <20210313075747.3781593-12-yuzhao@google.com> <20210316163437.GB3420@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210316163437.GB3420@casper.infradead.org> X-Stat-Signature: fyu18r31k1c1c1yu8tw4bkypewednuzi X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AF1A7407F8FF Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mail-il1-f182.google.com; client-ip=209.85.166.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615930166-318514 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, Mar 16, 2021 at 04:34:37PM +0000, Matthew Wilcox wrote: > On Sat, Mar 13, 2021 at 12:57:44AM -0700, Yu Zhao wrote: > > In the page fault path, we want to add pages to the per-zone lists > > index by max_seq as they cannot be evicted without going through > > the aging first. For anon pages, we rename > > lru_cache_add_inactive_or_unevictable() to lru_cache_add_page_vma() > > and add a new parameter, which is set to true in the page fault path, > > to indicate whether they should be added to the per-zone lists index > > by max_seq. For page/swap cache, since we cannot differentiate the > > page fault path from the read ahead path at the time we call > > lru_cache_add() in add_to_page_cache_lru() and > > __read_swap_cache_async(), we have to add a new function > > lru_gen_activate_page(), which is essentially activate_page(), to move > > pages to the per-zone lists indexed by max_seq at a later time. > > Hopefully we would find pages we want to activate in lru_pvecs.lru_add > > and simply set PageActive() on them without having to actually move > > them. > > > > In the reclaim path, pages mapped around a referenced PTE may also > > have been referenced due to spatial locality. We add a new function > > lru_gen_scan_around() to scan the vicinity of such a PTE. > > > > In addition, we add a new function page_is_active() to tell whether a > > page is active. We cannot use PageActive() because it is only set on > > active pages while they are not on multigenerational lru. It is > > cleared while pages are on multigenerational lru, in order to spare > > the aging the trouble of clearing it when an active generation becomes > > inactive. Internally, page_is_active() compares the generation number > > of a page with max_seq and max_seq-1, which are active generations and > > protected from the eviction. Other generations, which may or may not > > exist, are inactive. > > If we go with this multi-LRU approach, it feels like PageActive and > PageInactive should go away as tests. We should have a LRU field in > the page flags with some special values: > > - Not managed through LRU list > - Not currently on any LRU list > - Unevictable > - Active list 1 > - Active list 2 > - ... > - Active list 5 > > Now you don't need any extra bits in the page flags. Or if you want to > have 13 lists instead of 5, you can use just one extra bit. I'm not > quite sure whether it makes sense to have that many lists, so I need > to try to understand that better. Yes, and this would be a lot cleaner. PG_{lru,unevictable,active, referenced,reclaim,workingset,young,idle} could all go away. Look how many bits we've added just for page reclaim. Sigh... > I'd like to echo the comments from others that it'd be nice to split apart > the multigenerational part of this and the physical scanning part of this. > It's possible they don't make performance sense without each other, > but from a review point of view, they seem entirely separate things. Thanks for noticing. I do plan to see if the page table scanning part could be better refactored. (I cut some corners by squashing it while rebasing to latest kernel.)