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 AD819C433EF for ; Tue, 22 Mar 2022 08:45:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40AC96B0072; Tue, 22 Mar 2022 04:45:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BA066B0073; Tue, 22 Mar 2022 04:45:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A9016B0074; Tue, 22 Mar 2022 04:45:38 -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 1C35A6B0072 for ; Tue, 22 Mar 2022 04:45:38 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id D53376152E for ; Tue, 22 Mar 2022 08:45:37 +0000 (UTC) X-FDA: 79271388714.03.97FD561 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf07.hostedemail.com (Postfix) with ESMTP id 7E99D40016 for ; Tue, 22 Mar 2022 08:45:37 +0000 (UTC) Received: by mail-yb1-f181.google.com with SMTP id l2so32380283ybe.8 for ; Tue, 22 Mar 2022 01:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+iR4cCSnBvYIEX8JGakAV745I2rgE58S9R2YY4Ged7c=; b=NIARtr2oBs7uLYQBYidFLx6MPr55F+lN7qAoql6P3hnq45R1mXdc9VfJ8mEFo9hZXB brCk27+g2z4tjCw+jNan4V813Fu7jvJb4vKphwkvh0ixkI/X0rAJUfH/PMx12sHVSi6I 5vB4YSwU7b7V0ZUbHVme3qC+0mM/LGF0as2ysi8L/04eTWPfCA1Tg/0GvoO3Q4Rh8W2i wRaNcLi/NQYckSD8SAv5+Ys0piFZrTv/qFor7iThwAjc1eu+sNNDfpwWobhd03+7bSEb xlYh+RuGpr0nY/ByJ43BeJNeSg8ECs3u6x9WvWLFjwaLpRQdNc+PxKPQPoAnjX0IxwBl n1Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+iR4cCSnBvYIEX8JGakAV745I2rgE58S9R2YY4Ged7c=; b=3N+7xYw3HDNhg87tDdtHi9ElrezpXQy1qAMUGDaVHIFJZip1zG0R1Y7azlyWhj8wuN 34NulXuKsfCI9WshbU7QiYab037S8vz4OtZLiOf/j0bkpWw61gpLieI18lIaj6bP7Lwm QfeHEFTFkc7omEjNyCP12SpXW+d1XTtmuhoo5LHXh/QVrRNsN2hfDCSRUCi2DC1KWkR6 DNKHn81r6vu4Hv9JgQB+zsHZQwhPimMNG88mFd5o7IdS8dSxL4FQeZWZKAK3EXnBvW/C QgFkfJzwWrl02U0LLnGPF52aZDRg+JwgQToVDYTewFNoXnPL2DZd6fADO0lX0gNuQ9AU kQDQ== X-Gm-Message-State: AOAM533WbB0R0CKQmnDi1HDJjEd/y+NRHU+K8YQ3UIPsXYCee4dTAfGD SDGRzArqOVMz7SjSuJ4j6mGBmrRFmgjIryZkpzw= X-Google-Smtp-Source: ABdhPJw6H/IKc8pB2tyJzweSxfHKCrXN2p8geLUHg4bnZl1ae8zz+b4V+A1AAXqfxr8U643fQljqZsv1xh/JqETo5gI= X-Received: by 2002:a25:4003:0:b0:633:8ab5:b93e with SMTP id n3-20020a254003000000b006338ab5b93emr26470634yba.387.1647938736779; Tue, 22 Mar 2022 01:45:36 -0700 (PDT) MIME-Version: 1.0 References: <20220309021230.721028-1-yuzhao@google.com> <20220309021230.721028-11-yuzhao@google.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Tue, 22 Mar 2022 21:45:23 +1300 Message-ID: Subject: Re: [PATCH v9 10/14] mm: multi-gen LRU: kill switch To: Yu Zhao Cc: Andrew Morton , Linus Torvalds , Andi Kleen , Aneesh Kumar , Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , Mike Rapoport , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , LAK , Linux Doc Mailing List , LKML , Linux-MM , Kernel Page Reclaim v2 , x86 , Brian Geffon , Jan Alexander Steffens , Oleksandr Natalenko , Steven Barrett , Suleiman Souhlal , Daniel Byrne , Donald Carr , =?UTF-8?Q?Holger_Hoffst=C3=A4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh , Vaibhav Jain Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7E99D40016 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=NIARtr2o; spf=pass (imf07.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.219.181 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 3bgkh1pkkw4wyj9smiy613ueox9d6ag3 X-HE-Tag: 1647938737-887158 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 22, 2022 at 9:20 PM Yu Zhao wrote: > > On Tue, Mar 22, 2022 at 1:47 AM Barry Song <21cnbao@gmail.com> wrote: > > > ... > > > +static bool drain_evictable(struct lruvec *lruvec) > > > +{ > > > + int gen, type, zone; > > > + int remaining = MAX_LRU_BATCH; > > > + > > > + for_each_gen_type_zone(gen, type, zone) { > > > + struct list_head *head = &lruvec->lrugen.lists[gen][type][zone]; > > > + > > > + while (!list_empty(head)) { > > > + bool success; > > > + struct folio *folio = lru_to_folio(head); > > > + > > > + VM_BUG_ON_FOLIO(folio_test_unevictable(folio), folio); > > > + VM_BUG_ON_FOLIO(folio_test_active(folio), folio); > > > + VM_BUG_ON_FOLIO(folio_is_file_lru(folio) != type, folio); > > > + VM_BUG_ON_FOLIO(folio_zonenum(folio) != zone, folio); > > > + > > > + success = lru_gen_del_folio(lruvec, folio, false); > > > + VM_BUG_ON(!success); > > > + lruvec_add_folio(lruvec, folio); > > > > for example, max_seq=4(GEN=0) and max_seq-1=3, then we are supposed to put > > max_seq in the head of active list. but your code seems to be putting max_seq-1 > > after putting max_seq, then max_seq is more likely to be evicted > > afterwards as it > > is in the tail of the active list. > > This is correct. maybe something like below can fix it: #define for_each_gen_type_zone(gen, type, zone) \ - for ((gen) = 0; (gen) < MAX_NR_GENS; (gen)++) \ + for (int seq = min_seq[type], (gen)=(seq_to_gen(seq)); seq <= max_seq ; seq++) \ for ((type) = 0; (type) < ANON_AND_FILE; (type)++) \ for ((zone) = 0; (zone) < MAX_NR_ZONES; (zone)++) but i am not quite sure it is worth it if we don't switch mglru/lru that often. so it is all up to you, either fix it or put a comment to describe we are not trying to make an active list with completely the same temperature (hot/cold) as pages were in mglru lists. > > > anyway, it might not be so important. I can't imagine we will > > frequently switch mglru > > with lru dynamically. will we? > > I certainly hope not :) me too. Thanks Barry