Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4470465pxf; Tue, 16 Mar 2021 14:32:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN+Laf2S0L7EciRcjKve+pAMoV8vk8Ehl+2MUZgI+bmuJtW/9bkfsrZe4NcUtwfSNlNrXD X-Received: by 2002:a17:906:1182:: with SMTP id n2mr32389868eja.234.1615930329285; Tue, 16 Mar 2021 14:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615930329; cv=none; d=google.com; s=arc-20160816; b=Yrvy0DEQHmFmTUkLlbZXIIxYcV7FsyT8JbHkh3YtNMkiz+91Ln+iwMYe/ZrnEl5nXZ xNNC2Nw8ztLTrsNKo/jf65YLL1N9bC/zfjOpY1OfO94Z7Pr7C64KqyiT2f5Gy2VlrUWD JfvZFvvWqwScKOG1EFQ8s+KM+H+9JRP+Ivhr6Av0wfa952qXQWI1lmjLPAiBGoDPDZb9 y853Vy6oBaRI24pHTrsI585rCEcBYGm0PvWliZvchcQaAFjBhsTah+03yw3pTyidceLC kZDmjDYGyJw4CN8BC1Jy9TIGMHbndtIKr594jQhRVupeh8+GP1vRRudNq3mVMs08bl9y wnhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tzU2FBGLVgsAwsa24/PHLvin+0F6bwNLVKxARgFVukY=; b=V24OsKOGa/i5E4ZXi+N8qujuTppj4Kd5YZwNipj/SY7N9hKHFLHkrQi/OhadeIzG74 bkCbXjEn3Slcr0omMZil1S9nqVz4vcKNAntFLTpXjkr2XY9tfqHCnReT+HEJNHXATE82 SmoHiUZh5QmohAqJjZedH/mlLcBHD4nZCXiWlRNl+XMQaJQMkCcGaZgAREAjT9AFVkhm dPIk4+TA2WC1Lo8tu2cc/HacibgywcEGwhvLjKaISwupPH0XddCe4SObKQmyk1Y5ADP4 pvDO7OSdvMrqhxCrM0Q8IVvBK63aMP2cafiSPK9M4KbDo/kt51InMYe7HTGfbM8Pr8WA F02A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Iyz2Zs1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk14si14219613edb.548.2021.03.16.14.31.44; Tue, 16 Mar 2021 14:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Iyz2Zs1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229492AbhCPV3j (ORCPT + 99 others); Tue, 16 Mar 2021 17:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbhCPV31 (ORCPT ); Tue, 16 Mar 2021 17:29:27 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C719AC06174A for ; Tue, 16 Mar 2021 14:29:26 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id b5so14074273ilq.10 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=LeNxfLVInIUKBE6UyMRwYk+xbhDnr/u+zVpJLoyqUeKlYW7rJ0dQzRasMD7Sdow1og U0sAxDKYOJgtedYKTnuf8kOLuV9ocvxT7h9G+MoUTpv9S7FfDJKt+kp1L+mVWqsaZ+Py SfC1pdpkIKAFfr7vvOSN/cpMSqM3ySxoUlPW0ncWa2GLY5Uz8++redsdw2JTGNwfkpQX GQWbn8wytiEOr3SQ/gZaohLKS5gHzCpHWUGW+VnTOT3v0AFt3tgjxE5d6y4IZVF4aSkr Uowoc4AuLvn1z5FSLPn71OJBZ8XkS0d8eI6kKGEXN16lRV/+h1kidrRpsWynRG8C9lqf ATrw== X-Gm-Message-State: AOAM531VWZGCE+Ym/5b17qxKuZWvzELokRtym072ZeApUsnLi9+kikoi 12Js6GfJR1/Wlz0ol0Sm0MwREg== 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.)