linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/2] mm: make lru_gen_eviction() to handle folios without memcg info
Date: Wed, 10 Jul 2024 10:37:46 +0930	[thread overview]
Message-ID: <e1036b9cc8928be9a7dec150ab3a0317bd7180cf.1720572937.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1720572937.git.wqu@suse.com>

Currently lru_gen_eviction() fully relies on folio_memcg() to grab the
memcg.
It's fine for now as only file folios can enter workingset_eviction().

But for the incoming change which will skip memcg for certain address
space, we will hit folios without an memcg info in the future.

In that case, mem_cgroup_id() would lead to NULL pointer dereference.
Enhance lru_gen_eviction() to handle such situatioin by calling
lruvec_memcg() instead of using folio_memcg() directly.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 mm/workingset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/workingset.c b/mm/workingset.c
index c22adb93622a..449042d10803 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -253,7 +253,7 @@ static void *lru_gen_eviction(struct folio *folio)
 	hist = lru_hist_from_seq(min_seq);
 	atomic_long_add(delta, &lrugen->evicted[hist][type][tier]);
 
-	return pack_shadow(mem_cgroup_id(memcg), pgdat, token, refs);
+	return pack_shadow(mem_cgroup_id(lruvec_memcg(lruvec)), pgdat, token, refs);
 }
 
 /*
-- 
2.45.2


  reply	other threads:[~2024-07-10  1:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10  1:07 [PATCH 0/2] mm: skip memcg for certain address space Qu Wenruo
2024-07-10  1:07 ` Qu Wenruo [this message]
2024-07-10  1:07 ` [PATCH 2/2] mm: allow certain address space to be not accounted by memcg Qu Wenruo
2024-07-17  7:42 ` [PATCH 0/2] mm: skip memcg for certain address space Qu Wenruo
2024-07-17 15:55 ` Vlastimil Babka (SUSE)
2024-07-17 16:14   ` Michal Hocko
2024-07-17 22:38     ` Qu Wenruo
2024-07-18  7:17       ` Vlastimil Babka (SUSE)
2024-07-18  7:25         ` Michal Hocko
2024-07-18  7:57           ` Qu Wenruo
2024-07-18  8:09             ` Michal Hocko
2024-07-18  8:10               ` Michal Hocko
2024-07-18  8:52               ` Qu Wenruo
2024-07-18  9:25                 ` Michal Hocko
2024-07-18  7:52         ` Qu Wenruo
2024-07-18  8:28           ` Vlastimil Babka (SUSE)
2024-07-18  8:50             ` Qu Wenruo
2024-07-18  9:19               ` Vlastimil Babka (SUSE)
2024-07-25  9:00   ` Qu Wenruo

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=e1036b9cc8928be9a7dec150ab3a0317bd7180cf.1720572937.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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;
as well as URLs for NNTP newsgroup(s).