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 6005EC433EF for ; Thu, 14 Apr 2022 20:53:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AED316B0071; Thu, 14 Apr 2022 16:53:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9DC46B0073; Thu, 14 Apr 2022 16:53:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 917536B0074; Thu, 14 Apr 2022 16:53:40 -0400 (EDT) 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 8090A6B0071 for ; Thu, 14 Apr 2022 16:53:40 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 597CB636C3 for ; Thu, 14 Apr 2022 20:53:40 +0000 (UTC) X-FDA: 79356685800.06.8A70E24 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf24.hostedemail.com (Postfix) with ESMTP id D31EE180009 for ; Thu, 14 Apr 2022 20:53:39 +0000 (UTC) Received: by mail-il1-f174.google.com with SMTP id h14so2937224ila.5 for ; Thu, 14 Apr 2022 13:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=pa6LgTwJKoCyDm1ouvnQaXSj0XUnafk1B7DnI+4ds5E=; b=YOLOl3QdEGf0HeVT/Gn6X9mQ4SlNVFfW1B2wWZPnauNvYBjdx92phALVWtyhmtOUiy /YckdceI2rkicz7tfSi3vOI586pm3t2iq/JoeQOCht91JmDq4gRXbBayAilFIiGC/9oc EyOw2zrv9r2uvnPxtAk+pi2ObkQUJqxEqPdSVks5sFBB/TP7HwujPSZT6cOxUxKxNNh5 stc1Q2d7THmA3eb9ZUjFDh4AWcUNjj7PGCngcv/EpLd9vhEniIpbuZYm8GxfJNTvD8Wd Ka64OYy+PHR3cj3VeNKrERCvIj3UTCgN6YDX5zWT0DYYbnMNw/s1rsBDQnv17C9gsDg/ ZZfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=pa6LgTwJKoCyDm1ouvnQaXSj0XUnafk1B7DnI+4ds5E=; b=LghOe71nxAgytjk07wNmO8Bt8KQn8Dl7LgAcSIa/+BPvEXxP4qkJVUBycDFGi5prNw Hu4Tdu7U9/he6eAhQjBlqCMyC7unvpVl73sc/XucnADp9GShQ9wVictjdG68xZqXqNPb 4uHUFiWvVivbtlQJdsj1355NUqqq4yxNNQ0EbIxjDJLr0yDs4m3WLKg+id8hBDuXfdW8 hboCVRbMBHO0ZOSon64P0z81IAmscI5yLqYQKPt3NmXPQJu6vZZT8R+W8ABja4NUqJwC nHeLsXZTSogAXmXqMykKwNpro1k7TCjRzO41B0uCDI0hjyVmSeRBifJ9OgJagBlJt2Qv nF3A== X-Gm-Message-State: AOAM531XKvTHdwNRS//RAmnJIdZ+ApiwTpfUnJaS/Cv9W5s9PjaRqjIL LrDf9PGimjvhgwLSt4WW7ctbQg== X-Google-Smtp-Source: ABdhPJyyDgmPB1FgemJ0ZnKu90qzgVNnbgA76O0ajimJW0cemV0EzujLhLiFOctL5zYuKP5jxsTu8g== X-Received: by 2002:a92:d18b:0:b0:2c6:675:807c with SMTP id z11-20020a92d18b000000b002c60675807cmr1744365ilz.33.1649969618981; Thu, 14 Apr 2022 13:53:38 -0700 (PDT) Received: from google.com ([2620:15c:183:200:e02:decc:64d3:b1d3]) by smtp.gmail.com with ESMTPSA id v18-20020a6b5b12000000b00645bd8bd288sm1764416ioh.47.2022.04.14.13.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 13:53:38 -0700 (PDT) Date: Thu, 14 Apr 2022 14:53:34 -0600 From: Yu Zhao To: Chen Wandun Cc: Stephen Rothwell , linux-mm@kvack.org, Andi Kleen , Andrew Morton , Aneesh Kumar , Barry Song <21cnbao@gmail.com>, Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Linus Torvalds , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , 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, 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 , Vaibhav Jain Subject: Re: [PATCH v10 06/14] mm: multi-gen LRU: minimal implementation Message-ID: References: <20220407031525.2368067-1-yuzhao@google.com> <20220407031525.2368067-7-yuzhao@google.com> <71af92d2-0777-c318-67fb-8f7d52c800bb@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <71af92d2-0777-c318-67fb-8f7d52c800bb@huawei.com> Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=YOLOl3Qd; spf=pass (imf24.hostedemail.com: domain of yuzhao@google.com designates 209.85.166.174 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: qxzmjn3jbfkbekdccfi4yfhk1zxk9um8 X-Rspamd-Queue-Id: D31EE180009 X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1649969619-783917 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, Apr 14, 2022 at 07:47:54PM +0800, Chen Wandun wrote: > > On 2022/4/7 11:15, Yu Zhao wrote: > > +static void inc_min_seq(struct lruvec *lruvec) > > +{ > > + int type; > > + struct lru_gen_struct *lrugen = &lruvec->lrugen; > > + > > + VM_BUG_ON(!seq_is_valid(lruvec)); > > + > > + for (type = 0; type < ANON_AND_FILE; type++) { > > + if (get_nr_gens(lruvec, type) != MAX_NR_GENS) > > + continue; > I'm confused about relation between aging and LRU list operation. > > In function inc_max_seq,  both min_seq and max_seq will increase, > the lrugen->lists[] indexed by lru_gen_from_seq(max_seq + 1) may > be non-empty? Yes. > for example, > before inc_max_seq: > min_seq == 0, lrugen->lists[0][type][zone] > max_seq ==3, lrugen->lists[3][type][zone] > > after inc_max_seq: > min_seq ==1, lrugen->lists[1][type][zone] > max_seq ==4, lrugen->lists[0][type][zone] > > If lrugen->lists[0][type][zone] is not empty before inc_max_seq and it is > the most inactive list,however lurgen->lists[0][type][zone] will become > the most active list after inc_max_seq. Correct. > So,  in this place, > > if (get_nr_gens(lruvec, type) != MAX_NR_GENS) > continue; > > should change to > > if (get_nr_gens(lruvec, type) == MAX_NR_GENS) > continue; No, because max/min_seq will overlap if we do so. lrugen->lists[max_seq+1] can only be non-empty for anon LRU, for a couple of reasons: 1. We can't swap at all. 2. Swapping is constrained, e.g., swapfile is full. Both cases are similar to a producer (the aging) overrunning a consumer (the eviction). We used to handle them, but I simplified the code because I don't feel they are worth handling [1]. [1] https://lore.kernel.org/r/CAOUHufbDfwgm8PgCGkhCjbhMbm=fekfjgRR56NL-j+5iUGfVuw@mail.gmail.com/