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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5957AC433EF for ; Fri, 15 Apr 2022 05:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbiDOF1g (ORCPT ); Fri, 15 Apr 2022 01:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343585AbiDOF1f (ORCPT ); Fri, 15 Apr 2022 01:27:35 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFDE49233E for ; Thu, 14 Apr 2022 22:25:06 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id f5so4325884ilj.13 for ; Thu, 14 Apr 2022 22:25:06 -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=L+9PwRwxAOH1Mg2qf7uyf326MX2+3tpgbGJqOX1obhw=; b=ikrPxUBOlq0l84T9KUCmPb1Dso9glrpW4pHENs1lllPfIu5SM48kjcjZkPGMrTqRab gh/IC05IWtF77az/lKxuNa3D0X55vsQ+bMGWXg5ypgS+C7ab8E4x0HRr8UnNYDqVHrWL xSaYWfmy31jI93loGb5PhHppDwjovao1m0URYzeiQVHfV3sXvkaPzgiJ4mXdE+SHlBqG ko5a1HlW0V/5Z/brlwszjKQfDwHwuDM1WXgO1oG5mtJekWlYeMrVUx4fw+E7DJi90sp3 pRcL7Cl5N985MFtbCJQQ4ycRVLqegQ2markt+DzYaySEZ4P3TILJFJTy1QiSdJt78XD8 oDAQ== 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=L+9PwRwxAOH1Mg2qf7uyf326MX2+3tpgbGJqOX1obhw=; b=iRDzBq8qDgoz4NtUHV49VXoOdehDLJr9fj/hrHygSebOTpOZYEK5GPQUhYSeHtaWiz iP2A+Ad1CzUoteFUnky+7bM0IWYAU/KZMmxET8ORyltUOD3k9DcWNKoPWqiTJidQ/9Pv PSZ5j1lvnNpqK9lAELXSJ06M4aHf7gyMXoo1RllFb0OOgP9XFRn30tKXruOmT5uEPxJm LCp/5F9bezNqoZ8pgH8oKw45/ig0YB+NMRiwig57yc28/cOUhM0zVUCj8+nzrmJQQHpo YaF+oa4Pcl949JxEpbS0ZwL3v68zswh4btOYuVmBCpu/FobjJCl1mDSQ8Z/+xP9p9nuA ULew== X-Gm-Message-State: AOAM531p14mPkJWlLa5/pYNCEm3BA1b++zpIsihK44GY8TRQePMZWi+3 bdaELz9ySQgc6c2PdlGCUrkFRg== X-Google-Smtp-Source: ABdhPJxwK0O9V9eItDsXmWepGDGd15nU87HCouhVO3FNKAtTXKXhS4qqzoLcN8wv1Qkc0ZXdB+azMw== X-Received: by 2002:a05:6e02:20c4:b0:2c9:a514:6a99 with SMTP id 4-20020a056e0220c400b002c9a5146a99mr2719338ilq.50.1650000305951; Thu, 14 Apr 2022 22:25:05 -0700 (PDT) Received: from google.com ([2620:15c:183:200:e02:decc:64d3:b1d3]) by smtp.gmail.com with ESMTPSA id h24-20020a6bfb18000000b006497692016bsm2386879iog.15.2022.04.14.22.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 22:25:05 -0700 (PDT) Date: Thu, 14 Apr 2022 23:25:00 -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> <4c416f09-5304-07fd-cb53-5c9c8c75f6fa@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4c416f09-5304-07fd-cb53-5c9c8c75f6fa@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Fri, Apr 15, 2022 at 10:23:18AM +0800, Chen Wandun wrote: > > 在 2022/4/15 4:53, Yu Zhao 写道: > > 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]. > > Can lrugen->lists[max_seq+1]  also be non-empty for file LRU? On reclaim path, no. But it can be forced to do so via debugfs. > such as in dont reclaim mapped file page case(isolation will fail). You mean may_unmap=false? Pages stays in the same generation if isolation fails. So lrugen->lists[min_seq] won't be empty in this case. > If so, after aging, eviction will reclaim memory start from > lrugen->lists[min_seq+1], but some oldest file page still > remain in lrugen->lists[max_seq+1]. > > sort_folio can help to put misplaced pages to the right > LRU list, but in this case, it does't help, because sort_folio > only sort lrugen->lists[min_seq+1]. On reclaim path, inc_max_seq() is only called when need_aging=true, and this guarantees max_seq-min_seq[LRU_GEN_FILE]+1 < MAX_NR_GENS.