linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kalesh Singh <kaleshsingh@google.com>
To: yuzhao@google.com, akpm@linux-foundation.org
Cc: surenb@google.com, android-mm@google.com,
	kernel-team@android.com,  Kalesh Singh <kaleshsingh@google.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	 Suleiman Souhlal <suleiman@google.com>,
	Steven Barrett <steven@liquorix.net>,
	 Oleksandr Natalenko <oleksandr@natalenko.name>,
	 "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>,
	Qi Zheng <zhengqi.arch@bytedance.com>,
	 Brian Geffon <bgeffon@google.com>,
	Barry Song <baohua@kernel.org>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	 linux-mediatek@lists.infradead.org
Subject: [PATCH v2 3/3] mm-unstable: Multi-gen LRU: Fix can_swap in lru_gen_look_around()
Date: Tue,  1 Aug 2023 19:56:04 -0700	[thread overview]
Message-ID: <20230802025606.346758-3-kaleshsingh@google.com> (raw)
In-Reply-To: <20230802025606.346758-1-kaleshsingh@google.com>

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 <yuzhao@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
---

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;
 
-- 
2.41.0.255.g8b1d071c50-goog



  parent reply	other threads:[~2023-08-02  2:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02  2:56 [PATCH v2 1/3] mm-unstable: Multi-gen LRU: Fix per-zone reclaim Kalesh Singh
2023-08-02  2:56 ` [PATCH v2 2/3] mm-unstable: Multi-gen LRU: Avoid race in inc_min_seq() Kalesh Singh
2023-08-02  2:56 ` Kalesh Singh [this message]
2023-08-02 10:32 ` [PATCH v2 1/3] mm-unstable: Multi-gen LRU: Fix per-zone reclaim AngeloGioacchino Del Regno
2023-08-02 11:41 ` Charan Teja Kalla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230802025606.346758-3-kaleshsingh@google.com \
    --to=kaleshsingh@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=android-mm@google.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=baohua@kernel.org \
    --cc=bgeffon@google.com \
    --cc=heftig@archlinux.org \
    --cc=kernel-team@android.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=oleksandr@natalenko.name \
    --cc=steven@liquorix.net \
    --cc=suleiman@google.com \
    --cc=surenb@google.com \
    --cc=yuzhao@google.com \
    --cc=zhengqi.arch@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox