Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3239674pxb; Thu, 10 Feb 2022 16:07:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBHATziTiA9KajQ7gOliSp7flivBLUIfWZlJ3lapKjDd9keYs7S8yZb1mmB4DTEmoTdZrM X-Received: by 2002:a17:906:99c5:: with SMTP id s5mr8586273ejn.497.1644538074293; Thu, 10 Feb 2022 16:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644538074; cv=none; d=google.com; s=arc-20160816; b=HuS9gd9TVaqAoW3T+yTWStbcUSwDKcIFAZtF/C+aKIboDk6z5akZau4ImFPFV5wI5O xlSs3mb9+XK6+fAzu1YHXBfGxVCzIO+6t+8ZJMBT6AKWWbrZyhxfpfpwSK3Vwndg/yI2 vLmJago5ToAdiFrTIyq+7bKwBk7UH7wsha7bdPMGVR5QFyRtsQsIWXF7C3Nokh+JHkCk ifr7j/21N7O6opEEKuoGfZtdJXwd4Xz0/t0fnV/yOEXQxrNKHORGkbcj0VjlfNEIYYE2 jI7rTV5eMLw2YR2jbSlAyFBus0VrV0J7tCFF9hkLPY7Ilhk3FOf6i25vUtfEcrcvL/yE VubQ== 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=yiMGkSWaUlInyUsSv6Ymz5MFl5rNEExeyed6yGoVqQo=; b=HZ8l7/T7nwPQ54Mw33tCl95yQ1caE8aHAQnKcY/lM5XP8x2I1H/Zd6DclXhqRXCyG4 3ggIAudO/j04UlPdz0PEnnx+CaGp1jJy/M0NvNutbwY3Kg/m/TtftyG50kZVxxOetHdV Y//7vcQo0SpR05FHoNUB1KG3PYi3u//dc771DFSI3i3t3MJi6akt4qOtTjcXhQ/dQtGm jNq0ELl2SEDwgJBqADX2BKM8wMP7NfABmZeiLCKIC43xf595ZxEuIeVb5FeNtomGHvKz bgAtXLvhcHWDReDz4ZdB4QAag3Iy2MqtJuZnl+PullOhDbVtqGZhJXuY1TLO/PIjiqmF 1++w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=UIBM663W; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1si13449489ejo.829.2022.02.10.16.07.29; Thu, 10 Feb 2022 16:07:54 -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=@infradead.org header.s=casper.20170209 header.b=UIBM663W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344695AbiBJViL (ORCPT + 99 others); Thu, 10 Feb 2022 16:38:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240037AbiBJViK (ORCPT ); Thu, 10 Feb 2022 16:38:10 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED2BB80; Thu, 10 Feb 2022 13:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yiMGkSWaUlInyUsSv6Ymz5MFl5rNEExeyed6yGoVqQo=; b=UIBM663WVp45nBpTuklKQYIaOO qIqrGLpntoMuj+w0Zjrsb/3bZRZJHEEBxo01/e5j3RYuA16k+JKr4fXCfwg+B99MF5J+1bLJ+Jxsb 3k8e1hjG5sxhZ9+FHYVTUSLLfp6CtesC8oHLlIKQvubiwHmjfQp10vYPT10He77uRiHG23oMbvVaT hbtgH4yrj9vzhechikN/jUpAujlWHmSBPuF4DwpgNoDDB+kk0W8w+9iAabVzgoCun/4jStR/hmaq+ FafNBU3pb8iFAL7unJt95dvc82gwXZa10B2otIddSZzFA2j7wS3Y6c4RwzGAGaj0raGgYGzcSGNPG hk7iEN6w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIH81-009n2P-Of; Thu, 10 Feb 2022 21:37:25 +0000 Date: Thu, 10 Feb 2022 21:37:25 +0000 From: Matthew Wilcox To: Yu Zhao Cc: Andrew Morton , Johannes Weiner , Mel Gorman , Michal Hocko , Andi Kleen , Aneesh Kumar , Barry Song <21cnbao@gmail.com>, Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Jonathan Corbet , Linus Torvalds , Michael Larabel , Mike Rapoport , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, page-reclaim@google.com, x86@kernel.org, Brian Geffon , Jan Alexander Steffens , Oleksandr Natalenko , Steven Barrett , Suleiman Souhlal , Daniel Byrne , Donald Carr , Holger =?iso-8859-1?Q?Hoffst=E4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh Subject: Re: [PATCH v7 04/12] mm: multigenerational LRU: groundwork Message-ID: References: <20220208081902.3550911-1-yuzhao@google.com> <20220208081902.3550911-5-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220208081902.3550911-5-yuzhao@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Feb 08, 2022 at 01:18:54AM -0700, Yu Zhao wrote: > Evictable pages are divided into multiple generations for each lruvec. > The youngest generation number is stored in lrugen->max_seq for both > anon and file types as they're aged on an equal footing. The oldest > generation numbers are stored in lrugen->min_seq[] separately for anon > and file types as clean file pages can be evicted regardless of swap > constraints. These three variables are monotonically increasing. > > Generation numbers are truncated into order_base_2(MAX_NR_GENS+1) bits > in order to fit into the gen counter in folio->flags. Each truncated > generation number is an index to lrugen->lists[]. The sliding window > technique is used to track at least MIN_NR_GENS and at most > MAX_NR_GENS generations. The gen counter stores (seq%MAX_NR_GENS)+1 > while a page is on one of lrugen->lists[]. Otherwise it stores 0. > > There are two conceptually independent processes (as in the > manufacturing process): "the aging", which produces young generations, > and "the eviction", which consumes old generations. They form a > closed-loop system, i.e., "the page reclaim". Both processes can be > invoked from userspace for the purposes of working set estimation and > proactive reclaim. These features are required to optimize job > scheduling (bin packing) in data centers. The variable size of the > sliding window is designed for such use cases [1][2]. > > To avoid confusions, the terms "hot" and "cold" will be applied to the > multigenerational LRU, as a new convention; the terms "active" and > "inactive" will be applied to the active/inactive LRU, as usual. [...] > +++ b/include/linux/page-flags-layout.h > @@ -26,6 +26,14 @@ > > #define ZONES_WIDTH ZONES_SHIFT > > +#ifdef CONFIG_LRU_GEN > +/* LRU_GEN_WIDTH is generated from order_base_2(CONFIG_NR_LRU_GENS + 1). */ > +#define LRU_REFS_WIDTH (CONFIG_TIERS_PER_GEN - 2) > +#else > +#define LRU_GEN_WIDTH 0 > +#define LRU_REFS_WIDTH 0 > +#endif /* CONFIG_LRU_GEN */ I'm concerned about the number of bits being used in page->flags. It seems to me that we already have six bits in use to aid us in choosing which pages to reclaim: referenced, lru, active, workingset, reclaim, unevictable. What I was hoping to see from this patch set was reuse of those bits. That would give us 32 queues in total. Some would be special (eg pages cannot migrate out of the unevictable queue), but it seems to me that you effectively have 4 queues for active and 4 queues for inactive at this point (unless I misunderstood that). I think we need special numbers for: Not on the LRU and Unevictable, but that still leaves us with 30 generations to split between active & inactive. But maybe we still need some of those bits? Perhaps it's not OK to say that queue id 0 is !LRU, queue 1 is unevictable, queue #2 is workingset, queues 3-7 are active, queues 8-15 are various degrees of inactive. I'm assuming that it's not sensible to have a page that's marked as both "reclaim" and "workingset", but perhaps it is. Anyway, I don't understand this area well enough. I was just hoping for some simplification.