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 3F2A0C433F5 for ; Tue, 22 Mar 2022 04:03:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 547916B0072; Tue, 22 Mar 2022 00:03:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D0606B0073; Tue, 22 Mar 2022 00:03:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 398D66B0074; Tue, 22 Mar 2022 00:03:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 2BBDD6B0072 for ; Tue, 22 Mar 2022 00:03:10 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EFF0AE8F for ; Tue, 22 Mar 2022 04:03:09 +0000 (UTC) X-FDA: 79270676898.06.B9FF72B Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) by imf21.hostedemail.com (Postfix) with ESMTP id 7CA991C0007 for ; Tue, 22 Mar 2022 04:03:09 +0000 (UTC) Received: by mail-vk1-f169.google.com with SMTP id q85so1722097vkq.4 for ; Mon, 21 Mar 2022 21:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=U1WDVkBMGb1UWaUiP/BMa1bimDceuIIYF6DsrMPvkIE=; b=S0qxjRqltQsnLpu+b9uTdJ1ZzChP2TnUXVIzPiQtTKv7rlk1UWjMjpE3h3bJ1v9sW5 huKNUHAUPdXtj83a+494lrok1KWMjxoILFSd5pHwf9iQmsFVDC1eRjvLfix18amc27kO MsjP26xdR64RX1aD6Hw91Gd0LUTxfC6mxTRGSBJ99LzE7YFS5Z9RjF5ytt9aaGyHf81w sz+tauM57ujRXoLkISPTzAxt18Hgulk2BRNjkFZj9kKAWXZw37XWQVAZvAPw/rP+8Jg7 rcHa715+9N1drYanKpzpnvhAK+KvRyfiowz/VQuifj507DPS+Fq82rZrypJidfABzyVr plzA== 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=U1WDVkBMGb1UWaUiP/BMa1bimDceuIIYF6DsrMPvkIE=; b=dM2I1u1/EoihZF89KaebTdYOhVU8VVV5BUgLIkbisS7G9lqcUlLRrw/UYKtQ/TyBHY CyDalg2KsaNRrGY4E64JtxIyPasa6pnpISbg0nC2CjD1R9vRhvv7XEHybP6EaYNUGkB3 e4DNacKhBZlw1+mh/ZYWNUf2cxM/UaRrCy++aKTaggWV73Hq0qa0nGrY6pCubcolpBi1 CxkT4Kr2DyQ10sq4LH4OvGCTD1uQsOBMVsvTAyCZvUJTpNiOSnyV1vqUELSakPf9b1Ja d5C8ZR2VlGceoXDEk+yWeor5QkeAcvvAdFGogsqYiFrhEAYHwyqrCFA8iOmLz5dwRUp+ 69mw== X-Gm-Message-State: AOAM532jv9DilK5HQuicpZfyM7JVu2FT205DSuZzubtgxm9Ki/57gXZL wq0wWC1LY/E8nAHd1W9MmX5kFBEcY5MWbddVyWcZKg== X-Google-Smtp-Source: ABdhPJxtzx4fQPL53yxR2Z+LZ1DoZuKamA0ncWy8RZCGDsKAcQCH9+DROmoF8tqhSlZxwTp/BlxCUFz+Sjx0CpOrPd0= X-Received: by 2002:a05:6122:20a1:b0:33e:e79d:25c2 with SMTP id i33-20020a05612220a100b0033ee79d25c2mr3933628vkd.14.1647921788539; Mon, 21 Mar 2022 21:03:08 -0700 (PDT) MIME-Version: 1.0 References: <20220309021230.721028-1-yuzhao@google.com> <20220309021230.721028-7-yuzhao@google.com> <87czif79k2.fsf@linux.ibm.com> In-Reply-To: <87czif79k2.fsf@linux.ibm.com> From: Yu Zhao Date: Mon, 21 Mar 2022 22:02:57 -0600 Message-ID: Subject: Re: [PATCH v9 06/14] mm: multi-gen LRU: minimal implementation To: "Aneesh Kumar K.V" Cc: Andrew Morton , Linus Torvalds , Andi Kleen , 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 , Linux ARM , "open list:DOCUMENTATION" , linux-kernel , Linux-MM , Kernel Page Reclaim v2 , "the arch/x86 maintainers" , 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" Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=S0qxjRql; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of yuzhao@google.com designates 209.85.221.169 as permitted sender) smtp.mailfrom=yuzhao@google.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7CA991C0007 X-Stat-Signature: psds61ixqc9j1715byt6xn3fu1r45haa X-HE-Tag: 1647921789-111905 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 Mon, Mar 21, 2022 at 6:52 AM Aneesh Kumar K.V wrote: > > + > > +static long get_nr_evictable(struct lruvec *lruvec, unsigned long max_seq, > > + unsigned long *min_seq, bool can_swap, bool *need_aging) > > +{ > > + int gen, type, zone; > > + long old = 0; > > + long young = 0; > > + long total = 0; > > + struct lru_gen_struct *lrugen = &lruvec->lrugen; > > + > > + for (type = !can_swap; type < ANON_AND_FILE; type++) { > > + unsigned long seq; > > + > > + for (seq = min_seq[type]; seq <= max_seq; seq++) { > > + long size = 0; > > + > > + gen = lru_gen_from_seq(seq); > > + > > + for (zone = 0; zone < MAX_NR_ZONES; zone++) > > + size += READ_ONCE(lrugen->nr_pages[gen][type][zone]); > > + > > + total += size; > > + if (seq == max_seq) > > + young += size; > > + if (seq + MIN_NR_GENS == max_seq) > > + old += size; > > + } > > + } > > + > > + /* try to spread pages out across MIN_NR_GENS+1 generations */ > > + if (min_seq[LRU_GEN_FILE] + MIN_NR_GENS > max_seq) > > + *need_aging = true; > > + else if (min_seq[LRU_GEN_FILE] + MIN_NR_GENS < max_seq) > > + *need_aging = false; > > Can you explain/document the reason for the considering the below > conditions for ageing? > > > + else if (young * MIN_NR_GENS > total) > > + *need_aging = true; > > Are we trying to consdier the case of more than half the total pages > young as needing ageing? If so should MIN_NR_GENS be 2 instead of using > that #define? Or > > > + else if (old * (MIN_NR_GENS + 2) < total) > > + *need_aging = true; > > What is the significance of '+ 2' ? Will improve the comment according to my previous reply here [1]. [1] https://lore.kernel.org/linux-mm/CAOUHufYmUPZY0gCC+wYk6Vr1L8KEx+tJeEAhjpBfUnLJsAHq5A@mail.gmail.com/