Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp444266rwo; Tue, 1 Aug 2023 21:05:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlFNi4Qeu8/QvJ4g3ze13a5Gfp3bHfQmWTAGNVkr8Qudbsbo+WR7RcycbCb3c9Wy+YZBZn5B X-Received: by 2002:a05:6402:1a29:b0:522:1d9e:221 with SMTP id be9-20020a0564021a2900b005221d9e0221mr3536982edb.38.1690949106314; Tue, 01 Aug 2023 21:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690949106; cv=none; d=google.com; s=arc-20160816; b=P0BD8k1eigaQqvIqvDgPtwjOdM7MkPGkMHeF7tD88DAi2yye8De1i6JupagHbd0dWJ /fWM+0LDl6eSDCO+YuRAEKHiotp8+6hT0VkhBvduXFU/SIROdxwVHWcXW3k/MV3p1MN1 56NcyBDOh1Mw5e0lzLr/1PGVkCblFIOCvZyEU+awVWNUXWZgZXvl45duSqOIZwQ/enhz P2SdCGzEuwbymbv5CJasmavg0K5MiJSdayjKBwiD9RA0LDBG2farTkv+1Oh2fLBuTexe ANzYutqxjrmXV3zWJkpgeCRC7gj911yvpthiKao+KP89tqJVJCRfWBxQNeKWivtjsabK T7yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=RlAKMW2hhyEGf7EbQoDjxae+sXt59ciz5L61y3xkpbo=; fh=UScpqJLIebN67JXKpN6mOwxjoYAqhB0uBA+OR2hoSYs=; b=Yo7kaX5FfOwt41s/bGkNfRszNcVQrftwbOIg/p71bykeFDRq4I8szH94+/Pzoc9/Wt fDoMYLFBATuthyc0p5OUlu12veE9yi/7rkC2KNPoA0IfsnpZUFKODDYSJlWMOA6YeAiA N0v0tvMNKlOuuZcgvnXb1GASaZ/ONFzXpdf2OHLp9K4eU3U1C8WGaSCZmok/mxj8TxZo x4nu11FdriDBk23uCcaRsOaiRlfKzTp/XT6Jo6EKkvw5mp3/8zxZ/9t79oZ1oTN/suyQ Unbh78GkKNtOWuXEE2dEfE32E75J7rvDs1ifYXc6Fd9ZTYlwmxru4jUImTifRaHfFL1k Mzsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vQJAOG12; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a50fc15000000b005218bb04994si9291305edr.624.2023.08.01.21.04.42; Tue, 01 Aug 2023 21:05:06 -0700 (PDT) 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=@google.com header.s=20221208 header.b=vQJAOG12; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231851AbjHBDBP (ORCPT + 99 others); Tue, 1 Aug 2023 23:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbjHBDBK (ORCPT ); Tue, 1 Aug 2023 23:01:10 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4903F2735 for ; Tue, 1 Aug 2023 20:00:34 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe32ec7201so7145e9.1 for ; Tue, 01 Aug 2023 20:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690945233; x=1691550033; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RlAKMW2hhyEGf7EbQoDjxae+sXt59ciz5L61y3xkpbo=; b=vQJAOG12dWe2jHunL4c0y4nkGH47MCyLHObcx3wytIGo7cJbUOCvivyIOYUfF+wrFO unrIYujYnkF+ySOaIF+/kcNOKmOBLJwGwj82XBbWwBb4288Zuc617LPlcbAkRHKXxyc5 rQZH0wA/4bJp316IZY7q/iIlBwVwzQoknehVtxOnQF9lE4ooLuTLpS3sAyHviJqQTGml CUIsHiFKJHycqolab+QqPxjMe5wacy98j7JS/gsZ7WJMly20mExGGR5QswsxqfNN6H8z b1QZLQZMBTSFcRd6AW/jY+z3nqiiHzg9EFUz6rDPVjnkT4UfpTVHJzZLPg+mdXbypAn9 E6iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690945233; x=1691550033; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RlAKMW2hhyEGf7EbQoDjxae+sXt59ciz5L61y3xkpbo=; b=QDCXlYuNzgTTf68gqk0kJZ17C7UTZwZHa347I/895s13p50354NYyyDKtENq39+c72 YcCtUaKEYFzhYNyEIxEwBenmIeKmv3gkMvTizrMwci/5IbsL/pihPfRl6Xjkw1gY4AMn 2rPTnmQp9cuqEunEsEkyp6QxyyeRscignk6yw4EhI4QDaokeFRQJvM709F9RqofjCJJ7 FEYicgc1bqipp13hzJP13najJDmbtMY9VUPnqDVVd3lbn37WBEqCGDaaGnjuBM9KejW1 C81PT1+WLSCRlFbssgjOyB5J950hE41bBvN4s4hlNPsnKQFlx/yT4IPqRmaycXBp/o0R QOEA== X-Gm-Message-State: ABy/qLbuXWfv9/DIPi9Fkj4H24+wObnyG6EfD9K8X03DSLArLvpnUHMT Zd/RYGrmwdvqSiOD0nwlVuiA5vxhD+aUoC+wfuHELQ== X-Received: by 2002:a05:600c:1f0a:b0:3f7:e59f:2183 with SMTP id bd10-20020a05600c1f0a00b003f7e59f2183mr310158wmb.5.1690945232638; Tue, 01 Aug 2023 20:00:32 -0700 (PDT) MIME-Version: 1.0 References: <20230802001938.3913174-1-kaleshsingh@google.com> In-Reply-To: From: Kalesh Singh Date: Tue, 1 Aug 2023 20:00:20 -0700 Message-ID: Subject: Re: [PATCH 1/3] mm-unstable: Multi-gen LRU: Fix per-zone reclaim To: Yu Zhao Cc: akpm@linux-foundation.org, surenb@google.com, android-mm@google.com, kernel-team@android.com, Charan Teja Kalla , Lecopzer Chen , Matthias Brugger , AngeloGioacchino Del Regno , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Aug 1, 2023 at 7:08=E2=80=AFPM Yu Zhao wrote: > > On Tue, Aug 1, 2023 at 6:19=E2=80=AFPM Kalesh Singh wrote: > > > > MGLRU has a LRU list for each zone for each type (anon/file) in each > > generation: > > > > long nr_pages[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]; > > > > The min_seq (oldest generation) can progress independently for each > > type but the max_seq (youngest generation) is shared for both anon and > > file. This is to maintain a common frame of reference. > > > > In order for eviction to advance the min_seq of a type, all the per-zon= e > > lists in the oldest generation of that type must be empty. > > > > The eviction logic only considers pages from eligible zones for > > eviction or promotion. > > > > scan_folios() { > > ... > > for (zone =3D sc->reclaim_idx; zone >=3D 0; zone--) { > > ... > > sort_folio(); // Promote > > ... > > isolate_folio(); // Evict > > } > > ... > > } > > > > Consider the system has the movable zone configured and default 4 > > generations. The current state of the system is as shown below > > (only illustrating one type for simplicity): > > > > Type: ANON > > > > Zone DMA32 Normal Movable Device > > > > Gen 0 0 0 4GB 0 > > > > Gen 1 0 1GB 1MB 0 > > > > Gen 2 1MB 4GB 1MB 0 > > > > Gen 3 1MB 1MB 1MB 0 > > > > Now consider there is a GFP_KERNEL allocation request (eligible zone > > index <=3D Normal), evict_folios() will return without doing any work > > since there are no pages to scan in the eligible zones of the oldest > > generation. Reclaim won't make progress until triggered from a ZONE_MOV= ABLE > > allocation request; which may not happen soon if there is a lot of free > > memory in the movable zone. This can lead to OOM kills, although there > > is 1GB pages in the Normal zone of Gen 1 that we have not yet tried to > > reclaim. > > > > This issue is not seen in the conventional active/inactive LRU since > > there are no per-zone lists. > > > > If there are no (not enough) folios to scan in the eligible zones, move > > folios from ineligible zone (zone_index > reclaim_index) to the next > > generation. This allows for the progression of min_seq and reclaiming > > from the next generation (Gen 1). > > > > Qualcomm, Mediatek and raspberrypi [1] discovered this issue independen= tly. > > > > [1] https://github.com/raspberrypi/linux/issues/5395 > > > > Cc: Yu Zhao > > Cc: Andrew Morton > > Reported-by: Charan Teja Kalla > > Reported-by: Lecopzer Chen > > Signed-off-by: Kalesh Singh > > LGTM. But I think we need the Fixes tag and Cc stable. I've reposted the patches with fixes tag and stable cc'ed at: https://lore.kernel.org/lkml/20230802025606.346758-1-kaleshsingh@google.com= /#t Thanks, Kalesh