From: Ye Liu <ye.liu@linux.dev>
To: Miaohe Lin <linmiaohe@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Ye Liu <liuye@kylinos.cn>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/8] mm/memory-failure: convert process iterator to for_each_process_rcu
Date: Fri, 4 Sep 2026 16:29:56 +0800 [thread overview]
Message-ID: <20260904083001.553587-5-ye.liu@linux.dev> (raw)
In-Reply-To: <20260904083001.553587-1-ye.liu@linux.dev>
From: Ye Liu <liuye@kylinos.cn>
Replace the manual rcu_read_lock()/rcu_read_unlock() pairs combined
with for_each_process() loop in mm/memory-failure.c with
for_each_process_rcu().
No functional change.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
mm/memory-failure.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a8b03e2920ba..63a2ff08ee33 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -555,8 +555,7 @@ static void collect_procs_anon(const struct folio *folio,
return;
pgoff = page_pgoff(folio, page);
- rcu_read_lock();
- for_each_process(tsk) {
+ for_each_process_rcu(tsk) {
struct vm_area_struct *vma;
struct anon_vma_chain *vmac;
struct task_struct *t = task_early_kill(tsk, force_early);
@@ -572,7 +571,6 @@ static void collect_procs_anon(const struct folio *folio,
add_to_kill_anon_file(t, page, vma, to_kill, addr);
}
}
- rcu_read_unlock();
anon_vma_unlock_read(av);
}
@@ -589,9 +587,8 @@ static void collect_procs_file(const struct folio *folio,
pgoff_t pgoff;
i_mmap_lock_read(mapping);
- rcu_read_lock();
pgoff = page_pgoff(folio, page);
- for_each_process(tsk) {
+ for_each_process_rcu(tsk) {
struct task_struct *t = task_early_kill(tsk, force_early);
unsigned long addr;
@@ -611,7 +608,6 @@ static void collect_procs_file(const struct folio *folio,
add_to_kill_anon_file(t, page, vma, to_kill, addr);
}
}
- rcu_read_unlock();
i_mmap_unlock_read(mapping);
}
@@ -635,8 +631,7 @@ static void collect_procs_fsdax(const struct page *page,
struct task_struct *tsk;
i_mmap_lock_read(mapping);
- rcu_read_lock();
- for_each_process(tsk) {
+ for_each_process_rcu(tsk) {
struct task_struct *t = tsk;
/*
@@ -653,7 +648,6 @@ static void collect_procs_fsdax(const struct page *page,
add_to_kill_fsdax(t, page, vma, to_kill, pgoff);
}
}
- rcu_read_unlock();
i_mmap_unlock_read(mapping);
}
#endif /* CONFIG_FS_DAX */
@@ -2288,8 +2282,7 @@ static void collect_procs_pfn(struct pfn_address_space *pfn_space,
struct address_space *mapping = pfn_space->mapping;
i_mmap_lock_read(mapping);
- rcu_read_lock();
- for_each_process(tsk) {
+ for_each_process_rcu(tsk) {
struct task_struct *t = tsk;
t = task_early_kill(tsk, true);
@@ -2303,7 +2296,6 @@ static void collect_procs_pfn(struct pfn_address_space *pfn_space,
add_to_kill_pgoff(t, vma, to_kill, pgoff);
}
}
- rcu_read_unlock();
i_mmap_unlock_read(mapping);
}
--
2.25.1
next prev parent reply other threads:[~2026-09-04 8:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 8:29 [PATCH 0/8] mm: introduce for_each_process_rcu and for_each_thread_rcu Ye Liu
2026-09-04 8:29 ` [PATCH 1/8] " Ye Liu
2026-09-04 11:03 ` Michal Hocko
2026-09-04 16:25 ` Steven Rostedt
2026-09-04 21:17 ` Thomas Gleixner
2026-09-04 23:07 ` Steven Rostedt
2026-09-05 7:27 ` Thomas Gleixner
2026-09-04 8:29 ` [PATCH 2/8] mm/oom_kill: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:04 ` Michal Hocko
2026-09-05 0:32 ` SJ Park
2026-09-04 8:29 ` [PATCH 3/8] mm/ksm: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:04 ` Michal Hocko
2026-09-05 0:33 ` SJ Park
2026-09-04 8:29 ` Ye Liu [this message]
2026-09-04 11:05 ` [PATCH 4/8] mm/memory-failure: " Michal Hocko
2026-09-05 0:39 ` SJ Park
2026-09-04 8:29 ` [PATCH 5/8] kernel: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:06 ` Michal Hocko
2026-09-04 14:14 ` Günther Noack
2026-09-04 8:29 ` [PATCH 6/8] fs: " Ye Liu
2026-09-04 9:05 ` Oleg Nesterov
2026-09-04 9:22 ` Lorenzo Stoakes (ARM)
2026-09-04 11:06 ` Michal Hocko
2026-09-04 8:29 ` [PATCH 7/8] lib: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:09 ` Michal Hocko
2026-09-04 8:30 ` [PATCH 8/8] security/landlock: convert thread iterator to for_each_thread_rcu Ye Liu
2026-09-04 12:21 ` Justin Suess
2026-09-04 14:17 ` Günther Noack
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=20260904083001.553587-5-ye.liu@linux.dev \
--to=ye.liu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
--cc=nao.horiguchi@gmail.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
all inboxes | Powered by JetHome®