From patchwork Wed Aug 2 02:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13337540 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 00551EB64DD for ; Wed, 2 Aug 2023 02:56:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5221828011C; Tue, 1 Aug 2023 22:56:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D215280112; Tue, 1 Aug 2023 22:56:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3736928011C; Tue, 1 Aug 2023 22:56:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2559C280112 for ; Tue, 1 Aug 2023 22:56:27 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E797A1C9D80 for ; Wed, 2 Aug 2023 02:56:26 +0000 (UTC) X-FDA: 81077651172.02.A4CB688 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf01.hostedemail.com (Postfix) with ESMTP id 1E0CA40011 for ; Wed, 2 Aug 2023 02:56:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=NaC24ZAN; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 32MXJZAsKCLchXibpepfkdedlldib.Zljifkru-jjhsXZh.lod@flex--kaleshsingh.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=32MXJZAsKCLchXibpepfkdedlldib.Zljifkru-jjhsXZh.lod@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690944985; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/hIR85jBvXabpNDlh2e7xtBRwmCRiojtCshBAYjOX1Y=; b=TrECxDCe14Gn5aZpau9Jn1kGNqVlvmT7BXtFS2giU7QNpd/HSgGnHf9tM2yl0HwsZGe3Af gf28W0AWVuNDJJ5kEH8AiVD7z3FAYrvLxC71V4M6BmH1oGH+OEBi/uCP+CrdoecnG1MgxP jA8U+uiN7XxJjPnyHS67pP/oHmTcnfc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=NaC24ZAN; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 32MXJZAsKCLchXibpepfkdedlldib.Zljifkru-jjhsXZh.lod@flex--kaleshsingh.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=32MXJZAsKCLchXibpepfkdedlldib.Zljifkru-jjhsXZh.lod@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690944985; a=rsa-sha256; cv=none; b=pEeSJeWAc2Kf1WiHl6iklE6u+gFISEAQOt5EKkd0sCEBkP2Mn60trVxeWRk3QKKYQTxlV0 q3rPDCVOciuaNhg+b0ABHpeGFBUHA9dM3nF2AXREPTWNocxoo050iDNnQ/BAec0tK2i7gG 14JQ6iO/tgtJgu8ws1ewM/Au0tKGBW0= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-564fb1018bcso74364147b3.0 for ; Tue, 01 Aug 2023 19:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690944984; x=1691549784; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/hIR85jBvXabpNDlh2e7xtBRwmCRiojtCshBAYjOX1Y=; b=NaC24ZANDfp+9XAVYJ2zthvJ8rUBTQ6l5oOsseG6mfA3cvF+arl71fQG1qHAhLbqJ9 9qeh16JOmABIOlkWmOSbROyLEpFlmq9EQUA6/uFoeGgx/95B08yoDHueOaoh/i5155mY XVuhu3IiHZBf1PozmtFvavLXWlrDny3HMWCrGbcbi3wm/Avg9RqMK4JG4u4VTr67QtHd KbHI/PNLuqrNbAwO5JvECyVMzM5KsSmQk2W4uE2b/bpTqBDpICou5hRnR2Ky2iDO0WiX xNEzbL/OrqT3RifP1ne+1qALr+MKSfhXAnsSEvF0phJYNv0q7iAwZlhSP5UEXbHyOUib Cf7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690944984; x=1691549784; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/hIR85jBvXabpNDlh2e7xtBRwmCRiojtCshBAYjOX1Y=; b=He8nf/xJZHs5an9Qdn3tR+FKzd7aegJELxI03Bbu1F2fvnSoyMkZb+qZpllU4X8C3I YAlR58J9ZJYCdbYzC/OYe367K1ZvUrycwRRtp8vkNHoWbZ5qgTSuxuf44qTtwVSBBmjG boTjzeYp7N9fTGxb8Ic1qRMadc41qoqm53dBKj0reepqfO4cbHvot5wr7mJDEFNchnWB Xg+w+Ae7mofFDOPwW1nMuAu2R1VMbQ/ECszkhwytIsTuMGrhI0zbor9SV7ZtSF7zyaxi lig+1G7CYbNeyYlrRhcOC9dyFDAZjmC924Rjbh7QODJ2JDj4AWk6nEOiLdihNHixi0lp wpsA== X-Gm-Message-State: ABy/qLYCKY5lFjx79zhLIzUvXwPV48wj21uTd5Pe5Oqj6RiIAU2uChFU keoIOcoQLaRsymKoLs99E0wVg2j8uuNgiI8Ymw== X-Google-Smtp-Source: APBJJlHj0tBKgoeUZ7ci0leYLXMuHGiQZrYMbH4Cl/uWTIvoLc5trBzIvMofv2F1eZ7phbcd71NDee6Wx5e539GPkA== X-Received: from kalesh.mtv.corp.google.com ([2620:15c:211:201:aa5f:ff75:318:255]) (user=kaleshsingh job=sendgmr) by 2002:a81:a706:0:b0:583:4f82:b9d9 with SMTP id e6-20020a81a706000000b005834f82b9d9mr120587ywh.5.1690944984182; Tue, 01 Aug 2023 19:56:24 -0700 (PDT) Date: Tue, 1 Aug 2023 19:56:04 -0700 In-Reply-To: <20230802025606.346758-1-kaleshsingh@google.com> Mime-Version: 1.0 References: <20230802025606.346758-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230802025606.346758-3-kaleshsingh@google.com> Subject: [PATCH v2 3/3] mm-unstable: Multi-gen LRU: Fix can_swap in lru_gen_look_around() From: Kalesh Singh To: yuzhao@google.com, akpm@linux-foundation.org Cc: surenb@google.com, android-mm@google.com, kernel-team@android.com, Kalesh Singh , Matthias Brugger , AngeloGioacchino Del Regno , Suleiman Souhlal , Steven Barrett , Oleksandr Natalenko , "Jan Alexander Steffens (heftig)" , Qi Zheng , Brian Geffon , Barry Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org X-Rspamd-Queue-Id: 1E0CA40011 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: f6p5yefkd3r5zgnn1ehdxwcyj59c7t64 X-HE-Tag: 1690944984-186973 X-HE-Meta: U2FsdGVkX198YjRYsn0L8S07JWUiZmvPmqXdCggoLbMolua5pg/8AGAZphRg4D1dtGTk0i53lsv2nV7fYSFjyolX9ZK5nQBApGOdG1unIz/iRziaHutLdtk02rWXLefC7wVMdGJJ5zKJkhGEIMKXRHt//f/1mA9Ez0tMKMXWxU1N44GHBj0EXb4Tt1bqkEliN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9YFoDFEYgvRuNJVG9Bue3ec0dARxzAeT2jTDlgTOAVosWD1/89aeb77/txnEitBePAG6NJ6GbbvKcju9DZ+dLF36mW8X3+ClmuWRX2wmVcJCV1fyfFHk/GBiR9GYmv0ZtWa9t9srv5Y9hDZ7CPHcFoF+EkSDXwIbXU4HjOiJxeZmBB2+TZX1yKzB8lWEkFG2fLU3r1pCOTD1v8uff+kmkuNls3fdIqnzzyjlupKTBpM2XFOH/K42ph7ztVEgjrAWmodJANP281LOIqQUqTfsHBmYS49F2OS659KJdiFKByl/qLz+vSZ4gvaXjXHJ+y+HvgtZu0s8acl5DQtsjLzRTq+7mEWazq64nQ+6z4EA75XdpwMjgF6c1Dl5q1rUJURfSLBOCd0pNpemYeIn3uZF9xqrOYSmZtpDWxpRt9bQRsOOiUBqdByfX5BjHAPYPxULq0JuEPtarggqM9J9/2uXJFj5Deb37gvtbHM0fhEqMVaHMm6m/7WerBJehuRFpYgL9xmBsACsQf4L8+ZvKuCfV4XsMW06C 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: walk->can_swap might be invalid since it's not guaranteed to be initialized for the particular lruvec. Instead deduce it from the folio type (anon/file). Fixes: 018ee47f1489 ("mm: multi-gen LRU: exploit locality in rmap") Cc: Yu Zhao Cc: Andrew Morton Signed-off-by: Kalesh Singh --- Changes in v2: - Add Fixes tag mm/vmscan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 6eecd291756c..b4329f93a682 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4656,6 +4656,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) pte_t *pte = pvmw->pte; unsigned long addr = pvmw->address; struct folio *folio = pfn_folio(pvmw->pfn); + bool can_swap = !folio_is_file_lru(folio); struct mem_cgroup *memcg = folio_memcg(folio); struct pglist_data *pgdat = folio_pgdat(folio); struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat); @@ -4704,7 +4705,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) if (!pte_young(ptent)) continue; - folio = get_pfn_folio(pfn, memcg, pgdat, !walk || walk->can_swap); + folio = get_pfn_folio(pfn, memcg, pgdat, can_swap); if (!folio) continue;