From patchwork Wed Aug 2 00:19:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13337420 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 8B6ECEB64DD for ; Wed, 2 Aug 2023 00:20:33 +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=lGkQm28wUD8EuuByaEZKz5LGMM+tCs7hfeDXEeyvWpI=; b=xMXYgbv/SvUnYOQymascirDDyt Si9dC85O24o+cmFbZZeYv2LZQP6SOH1UeAl01YsvCaHSTz7RfUvIr6AiQLwWbQlplDsXciY2iYQYH y+xZkrFcClrdgQOBL89xHi149GMeUyZjP2CToaxVhIu6ymevqY4fMRydyoIkFNHuDzC7io+dCzAoZ 1TDCug/VMFqJP7eYcxqOSy6d9F9RDC/3xX5RfNUHwAfCA+QKlfo/tOEWhMX4n2dip+0v2b5b3rh87 I+icnpubkfvHa+C4NLZhyZEDmF+lNEcCVG/b2dC43SbGqWU59rf4V+jw2rQjGuS1ANh3RdflIjjim aAf8rnHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQzax-003ayB-1J; Wed, 02 Aug 2023 00:20:07 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQzav-003aww-0I for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2023 00:20:06 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d052f58b7deso6401738276.2 for ; Tue, 01 Aug 2023 17:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690935604; x=1691540404; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sQqMGlFvgvQ3yvXEv1c3TG8Zu+eyY93FF0SWidKY8Dg=; b=sjS9Sd/96ChnfQYaR1cO5sk2N9oknVX/qJB2yXG052CqPpTjyq29z2og4PvyAUfuFb BbtTttNXygAAyEGj4VDc+gc5Tv/jJm9VVufAhbVnxD9d2fZv9SEDE3pJ6CmBfTmsJ7/M 30pcgTpZEa5b5WZTWX8yFJI4winvc57m0RSu8uswlhLrD88MgHDJlMnwkJUHOUbaDiEX XFB8o/mR1Hsb5CgE+Zf1jutf81sOk0xLQ2PlXcTmJRipNCPc6eQScIC9DvSTQlXma76v y6rPEG/+3EoY9yWeyWMpqj6nc4br7aYthBDJY27Nv4jLmE5k9Zm7VQi5fBGYNijEtZwE qVdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690935604; x=1691540404; 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=sQqMGlFvgvQ3yvXEv1c3TG8Zu+eyY93FF0SWidKY8Dg=; b=MwhGbeLQQLJsdxYfhapumTXerDhaJjDwSBu0VDY/zHpkdfVgdTaeCRd8ZhFOBB45Ed 2H2TBlojAyodSeh9f0SUdjasOaz4KzLuY9wWUsALKyijY1tbYDfASDV3XHIkVyKab1o4 zM46bcNEMadF5Ib3qd5GxkFmp3utCWFVyy3+EoWo4LQQqlXARBLEBvtsXlLYnSMt61sF MN1DbQAAJb11ayUub4X8udgfHATbehfnponelhzftGo9He1f27xf4vpZuR/aVI2RdBd6 Il9qbMy6+0pUgklxsgkameywHGS3xJjOFt81g0u+m3ofg0R74CCS2g+aulHTSUgeJOg0 Cj0A== X-Gm-Message-State: ABy/qLYMQERUfNFOMBj5T9LtTIp6OaYWItCBEzJmsiSF4d7/itJdKm21 WUmIWZH4btJNV4vqpt83QIaLu1J3FVbFTOFk5g== X-Google-Smtp-Source: APBJJlEf7/u2/Z616hvXFPIg4IjabnaZmfD7pavvMQxNa0+Yi7QX2OhFnd4BlpzLjlUWlOxu9nZ4P/MXGt70cu1ftA== X-Received: from kalesh.mtv.corp.google.com ([2620:15c:211:201:aa5f:ff75:318:255]) (user=kaleshsingh job=sendgmr) by 2002:a25:48a:0:b0:d37:353:b7eb with SMTP id 132-20020a25048a000000b00d370353b7ebmr33827ybe.11.1690935603866; Tue, 01 Aug 2023 17:20:03 -0700 (PDT) Date: Tue, 1 Aug 2023 17:19:37 -0700 In-Reply-To: <20230802001938.3913174-1-kaleshsingh@google.com> Mime-Version: 1.0 References: <20230802001938.3913174-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230802001938.3913174-3-kaleshsingh@google.com> Subject: [PATCH 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 , 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_172005_136619_21EE6245 X-CRM114-Status: GOOD ( 12.83 ) 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). Cc: Yu Zhao Cc: Andrew Morton Signed-off-by: Kalesh Singh --- 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;