From: Ye Liu <ye.liu@linux.dev>
To: akpm@linux-foundation.org, linmiaohe@huawei.com, nao.horiguchi@gmail.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Ye Liu <liuye@kylinos.cn>
Subject: [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites
Date: Fri, 18 Apr 2025 15:52:26 +0800 [thread overview]
Message-ID: <20250418075226.695014-4-ye.liu@linux.dev> (raw)
In-Reply-To: <20250418075226.695014-1-ye.liu@linux.dev>
From: Ye Liu <liuye@kylinos.cn>
The add_to_kill_anon_file() helper function only checked for -EFAULT
return values before calling __add_to_kill(). Removes the unnecessary
wrapper and moves the addr == -EFAULT checks directly into
collect_procs_anon() and collect_procs_file().
This ensures that error handling is performed close to where the address
is derived (via page_mapped_in_vma() or page_address_in_vma()), rather
than being obscured inside a helper function.
No functional changes are introduced.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
mm/memory-failure.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b91a33fb6c69..ec0041c95b27 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -486,15 +486,6 @@ static void __add_to_kill(struct task_struct *tsk, const struct page *p,
list_add_tail(&tk->nd, to_kill);
}
-static void add_to_kill_anon_file(struct task_struct *tsk, const struct page *p,
- struct vm_area_struct *vma, struct list_head *to_kill,
- unsigned long addr)
-{
- if (addr == -EFAULT)
- return;
- __add_to_kill(tsk, p, vma, to_kill, addr);
-}
-
#ifdef CONFIG_KSM
static bool task_in_to_kill_list(struct list_head *to_kill,
struct task_struct *tsk)
@@ -634,7 +625,8 @@ static void collect_procs_anon(const struct folio *folio,
if (vma->vm_mm != t->mm)
continue;
addr = page_mapped_in_vma(page, vma);
- add_to_kill_anon_file(t, page, vma, to_kill, addr);
+ if (addr != -EFAULT)
+ __add_to_kill(t, page, vma, to_kill, addr);
}
}
rcu_read_unlock();
@@ -674,7 +666,8 @@ static void collect_procs_file(const struct folio *folio,
if (vma->vm_mm != t->mm)
continue;
addr = page_address_in_vma(folio, page, vma);
- add_to_kill_anon_file(t, page, vma, to_kill, addr);
+ if (addr != -EFAULT)
+ __add_to_kill(t, page, vma, to_kill, addr);
}
}
rcu_read_unlock();
--
2.25.1
next prev parent reply other threads:[~2025-04-18 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 7:52 [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Ye Liu
2025-04-18 7:52 ` [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency Ye Liu
2025-04-18 9:14 ` Lorenzo Stoakes
2025-04-18 9:37 ` Harry Yoo
2025-04-18 9:42 ` Lorenzo Stoakes
2025-04-18 7:52 ` [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma Ye Liu
2025-04-18 9:14 ` Lorenzo Stoakes
2025-04-18 7:52 ` Ye Liu [this message]
2025-04-18 9:18 ` [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites Lorenzo Stoakes
2025-04-18 9:12 ` [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Lorenzo Stoakes
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=20250418075226.695014-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.