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: 13337551 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71373EB64DD for ; Wed, 2 Aug 2023 02:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RakYEJxzwAT4IEFFV9jneV7D+O7+AtKp7c2tCX9Yjvc=; b=o2JOj7jO18RjTwNVYae98kew+Z z4Ty0bZN67TO5CnHummuBB0KVWuTMRyMXndU9axRRfQPz1nGh5bC9z5MFuOVeC+jvVz9Nr/bGjlx6 +rj0jllYVYBh0FTqO248vYXv1vh3SJ/tu4sv0rxzxuB4BaXCuv7S6d07I4S5qJNG+ciaRYssX6ZUN XCbDl60TOCDwOK0vlTptbv6dDFIUkzA6CZ+RXqE4Z2e2j8U7ZG8MydA8RiQhx7CUpq1YzAOunb5qB iMZ4iuf2lkdjI5LJsRndTQ79k4ycY3i/wgCFWcZ0CeVvSLuQD2RpXOeOqLKd9fg878bRzRqfJyXRF 4zTsuV8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qR22I-003pD1-0C; Wed, 02 Aug 2023 02:56:30 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qR22E-003p9l-3A for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2023 02:56:28 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-583c1903ad3so74215767b3.2 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=k0PeL1K9yUb5mq8I+Pg9ZsYx1njdVS8MeEXuxWrPqnOlNc6Y/UZIlNhnpayFOVaFPp stmiE+eSnnGEnzdmw0XQAOUOlh8zUyJ4HCgg/fUa3CZNnAFy8g6lEhKyAipvJqsw6JY7 c4TUB+BaJCwo8SPKBJwIYdQbVRGq+Nbi7RUnc8xsU+H9GILJwy6UJYFMc3n8vKvG6Phh 9dGBDkMKJmODzpw/FTB36YZVBf98M3VlGE53JE1D0moCPhO+YmMLgSMnAxVDBhNH2DzW oj5c9SslVAyfS7NzgkF8Rj8rwXRI0efb5hFMMWAjZYs2cFVzpgWxzMpGn/+351qm2lb4 FY4g== X-Gm-Message-State: ABy/qLbzF4rs0WQNu0VroOKyXBdapvAm2kE+85YVKRk2Y2i7v1hjFWtG 1zxF4axlmuWhrSK9tfCrtkgJqWoXXp4pkWU+Jw== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_195627_017078_8253C424 X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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;