linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] Some cleanups for memory-failure
@ 2024-05-24  9:12 Miaohe Lin
  2024-05-24  9:12 ` [PATCH 01/13] mm/memory-failure: simplify put_ref_page() Miaohe Lin
                   ` (12 more replies)
  0 siblings, 13 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:12 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Hi everyone,
This series contains a few cleanup patches to remove unneeded function
variant, add helper macro, fix some obsolete comments and so on. More
details can be found in the respective changelogs.
Thanks!

Miaohe Lin (13):
  mm/memory-failure: simplify put_ref_page()
  mm/memory-failure: remove MF_MSG_SLAB
  mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM
  mm/memory-failure: save a page_folio() call
  mm/memory-failure: remove unneeded empty string
  mm/memory-failure: remove confusing initialization to count
  mm/memory-failure: remove unneeded hwpoison_filter() variant
  mm/memory-failure: use helper macro task_pid_nr()
  mm/memory-failure: remove obsolete comment in unpoison_memory()
  mm/memory-failure: move some function declarations into internal.h
  mm/memory-failure: fix comment of get_hwpoison_page()
  mm/memory-failure: remove obsolete comment in kill_proc()
  mm/memory-failure: correct comment in me_swapcache_dirty

 include/linux/mm.h         | 14 ------------
 include/linux/page-flags.h |  5 ----
 include/linux/rmap.h       |  2 --
 include/ras/ras_event.h    |  1 -
 mm/internal.h              | 16 +++++++++++++
 mm/memory-failure.c        | 47 +++++++++++++-------------------------
 6 files changed, 32 insertions(+), 53 deletions(-)

-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 01/13] mm/memory-failure: simplify put_ref_page()
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
@ 2024-05-24  9:12 ` Miaohe Lin
  2024-05-24  9:12 ` [PATCH 02/13] mm/memory-failure: remove MF_MSG_SLAB Miaohe Lin
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:12 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Remove unneeded page != NULL check. pfn_to_page() won't return NULL.
No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index ac030061eda0..922c902a7229 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2150,14 +2150,10 @@ static inline unsigned long folio_free_raw_hwp(struct folio *folio, bool flag)
 /* Drop the extra refcount in case we come from madvise() */
 static void put_ref_page(unsigned long pfn, int flags)
 {
-	struct page *page;
-
 	if (!(flags & MF_COUNT_INCREASED))
 		return;
 
-	page = pfn_to_page(pfn);
-	if (page)
-		put_page(page);
+	put_page(pfn_to_page(pfn));
 }
 
 static int memory_failure_dev_pagemap(unsigned long pfn, int flags,
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 02/13] mm/memory-failure: remove MF_MSG_SLAB
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
  2024-05-24  9:12 ` [PATCH 01/13] mm/memory-failure: simplify put_ref_page() Miaohe Lin
@ 2024-05-24  9:12 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 03/13] mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM Miaohe Lin
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:12 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Since commit 46df8e73a4a3 ("mm: free up PG_slab"), MF_MSG_SLAB becomes
unused. Remove it. No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 include/linux/mm.h      | 1 -
 include/ras/ras_event.h | 1 -
 mm/memory-failure.c     | 1 -
 3 files changed, 3 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3aa1b6889bcc..4bc97ae25ade 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4099,7 +4099,6 @@ enum mf_result {
 enum mf_action_page_type {
 	MF_MSG_KERNEL,
 	MF_MSG_KERNEL_HIGH_ORDER,
-	MF_MSG_SLAB,
 	MF_MSG_DIFFERENT_COMPOUND,
 	MF_MSG_HUGE,
 	MF_MSG_FREE_HUGE,
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index b3f6832a94fe..3fe77ba2cdd5 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -356,7 +356,6 @@ TRACE_EVENT(aer_event,
 #define MF_PAGE_TYPE		\
 	EM ( MF_MSG_KERNEL, "reserved kernel page" )			\
 	EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" )	\
-	EM ( MF_MSG_SLAB, "kernel slab page" )				\
 	EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \
 	EM ( MF_MSG_HUGE, "huge page" )					\
 	EM ( MF_MSG_FREE_HUGE, "free huge page" )			\
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 922c902a7229..9c23adceee75 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -911,7 +911,6 @@ static const char *action_name[] = {
 static const char * const action_page_types[] = {
 	[MF_MSG_KERNEL]			= "reserved kernel page",
 	[MF_MSG_KERNEL_HIGH_ORDER]	= "high-order kernel page",
-	[MF_MSG_SLAB]			= "kernel slab page",
 	[MF_MSG_DIFFERENT_COMPOUND]	= "different compound page after locking",
 	[MF_MSG_HUGE]			= "huge page",
 	[MF_MSG_FREE_HUGE]		= "free huge page",
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 03/13] mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
  2024-05-24  9:12 ` [PATCH 01/13] mm/memory-failure: simplify put_ref_page() Miaohe Lin
  2024-05-24  9:12 ` [PATCH 02/13] mm/memory-failure: remove MF_MSG_SLAB Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 04/13] mm/memory-failure: save a page_folio() call Miaohe Lin
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Add helper macro GET_PAGE_MAX_RETRY_NUM to replace magic number 3.
No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 9c23adceee75..b571aaf987a2 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1446,6 +1446,8 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags)
 	return 0;
 }
 
+#define GET_PAGE_MAX_RETRY_NUM 3
+
 static int get_any_page(struct page *p, unsigned long flags)
 {
 	int ret = 0, pass = 0;
@@ -1460,12 +1462,12 @@ static int get_any_page(struct page *p, unsigned long flags)
 		if (!ret) {
 			if (page_count(p)) {
 				/* We raced with an allocation, retry. */
-				if (pass++ < 3)
+				if (pass++ < GET_PAGE_MAX_RETRY_NUM)
 					goto try_again;
 				ret = -EBUSY;
 			} else if (!PageHuge(p) && !is_free_buddy_page(p)) {
 				/* We raced with put_page, retry. */
-				if (pass++ < 3)
+				if (pass++ < GET_PAGE_MAX_RETRY_NUM)
 					goto try_again;
 				ret = -EIO;
 			}
@@ -1491,7 +1493,7 @@ static int get_any_page(struct page *p, unsigned long flags)
 		 * A page we cannot handle. Check whether we can turn
 		 * it into something we can handle.
 		 */
-		if (pass++ < 3) {
+		if (pass++ < GET_PAGE_MAX_RETRY_NUM) {
 			put_page(p);
 			shake_page(p);
 			count_increased = false;
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 04/13] mm/memory-failure: save a page_folio() call
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (2 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 03/13] mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24 15:06   ` David Hildenbrand
  2024-05-24  9:13 ` [PATCH 05/13] mm/memory-failure: remove unneeded empty string Miaohe Lin
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Use local variable folio directly to save a page_folio() call.
No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b571aaf987a2..73878ecdec22 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1658,7 +1658,7 @@ static bool hwpoison_user_mappings(struct folio *folio, struct page *p,
 	unmap_success = !page_mapped(p);
 	if (!unmap_success)
 		pr_err("%#lx: failed to unmap page (folio mapcount=%d)\n",
-		       pfn, folio_mapcount(page_folio(p)));
+		       pfn, folio_mapcount(folio));
 
 	/*
 	 * try_to_unmap() might put mlocked page in lru cache, so call
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 05/13] mm/memory-failure: remove unneeded empty string
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (3 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 04/13] mm/memory-failure: save a page_folio() call Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 06/13] mm/memory-failure: remove confusing initialization to count Miaohe Lin
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Remove unneeded empty string in definition of macro pr_fmt. No functional
change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 73878ecdec22..c09e1bf83682 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2549,7 +2549,7 @@ static int __init memory_failure_init(void)
 core_initcall(memory_failure_init);
 
 #undef pr_fmt
-#define pr_fmt(fmt)	"" fmt
+#define pr_fmt(fmt)	fmt
 #define unpoison_pr_info(fmt, pfn, rs)			\
 ({							\
 	if (__ratelimit(rs))				\
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 06/13] mm/memory-failure: remove confusing initialization to count
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (4 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 05/13] mm/memory-failure: remove unneeded empty string Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant Miaohe Lin
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

It's meaningless and confusing to init local variable count to 1.
Remove it. No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index c09e1bf83682..be9bda281d91 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2573,7 +2573,7 @@ int unpoison_memory(unsigned long pfn)
 	struct folio *folio;
 	struct page *p;
 	int ret = -EBUSY, ghp;
-	unsigned long count = 1;
+	unsigned long count;
 	bool huge = false;
 	static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL,
 					DEFAULT_RATELIMIT_BURST);
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (5 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 06/13] mm/memory-failure: remove confusing initialization to count Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24 15:38   ` kernel test robot
  2024-05-24 15:59   ` kernel test robot
  2024-05-24  9:13 ` [PATCH 08/13] mm/memory-failure: use helper macro task_pid_nr() Miaohe Lin
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

When CONFIG_HWPOISON_INJECT is not enabled, there is no user of the
hwpoison_filter(). Remove it.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index be9bda281d91..2c3ecbfc2134 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -294,14 +294,8 @@ int hwpoison_filter(struct page *p)
 
 	return 0;
 }
-#else
-int hwpoison_filter(struct page *p)
-{
-	return 0;
-}
-#endif
-
 EXPORT_SYMBOL_GPL(hwpoison_filter);
+#endif
 
 /*
  * Kill all processes that have a poisoned page mapped and then isolate
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 08/13] mm/memory-failure: use helper macro task_pid_nr()
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (6 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 09/13] mm/memory-failure: remove obsolete comment in unpoison_memory() Miaohe Lin
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Use helper macro task_pid_nr() to get the pid of a task. No functional
change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 2c3ecbfc2134..19d338e83e43 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -338,7 +338,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
 	int ret = 0;
 
 	pr_err("%#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
-			pfn, t->comm, t->pid);
+			pfn, t->comm, task_pid_nr(t));
 
 	if ((flags & MF_ACTION_REQUIRED) && (t == current))
 		ret = force_sig_mceerr(BUS_MCEERR_AR,
@@ -356,7 +356,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
 				      addr_lsb, t);
 	if (ret < 0)
 		pr_info("Error sending signal to %s:%d: %d\n",
-			t->comm, t->pid, ret);
+			t->comm, task_pid_nr(t), ret);
 	return ret;
 }
 
@@ -518,7 +518,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill,
 		if (forcekill) {
 			if (tk->addr == -EFAULT) {
 				pr_err("%#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
-				       pfn, tk->tsk->comm, tk->tsk->pid);
+				       pfn, tk->tsk->comm, task_pid_nr(tk->tsk));
 				do_send_sig_info(SIGKILL, SEND_SIG_PRIV,
 						 tk->tsk, PIDTYPE_PID);
 			}
@@ -531,7 +531,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill,
 			 */
 			else if (kill_proc(tk, pfn, flags) < 0)
 				pr_err("%#lx: Cannot send advisory machine check signal to %s:%d\n",
-				       pfn, tk->tsk->comm, tk->tsk->pid);
+				       pfn, tk->tsk->comm, task_pid_nr(tk->tsk));
 		}
 		list_del(&tk->nd);
 		put_task_struct(tk->tsk);
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 09/13] mm/memory-failure: remove obsolete comment in unpoison_memory()
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (7 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 08/13] mm/memory-failure: use helper macro task_pid_nr() Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24 15:06   ` David Hildenbrand
  2024-05-24  9:13 ` [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h Miaohe Lin
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Since commit 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to
allow larger rcu_head"), folio->_mapcount is not overloaded with SLAB.
Update corresponding comment.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 19d338e83e43..e4252f297d41 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2610,10 +2610,6 @@ int unpoison_memory(unsigned long pfn)
 	    folio_test_reserved(folio) || folio_test_offline(folio))
 		goto unlock_mutex;
 
-	/*
-	 * Note that folio->_mapcount is overloaded in SLAB, so the simple test
-	 * in folio_mapped() has to be done after folio_test_slab() is checked.
-	 */
 	if (folio_mapped(folio)) {
 		unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n",
 				 pfn, &unpoison_rs);
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (8 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 09/13] mm/memory-failure: remove obsolete comment in unpoison_memory() Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-25  2:39   ` kernel test robot
  2024-05-24  9:13 ` [PATCH 11/13] mm/memory-failure: fix comment of get_hwpoison_page() Miaohe Lin
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

There are some functions only used inside mm. Move them into internal.h.
No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 include/linux/mm.h         | 13 -------------
 include/linux/page-flags.h |  5 -----
 include/linux/rmap.h       |  2 --
 mm/internal.h              | 16 ++++++++++++++++
 4 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4bc97ae25ade..d5174b3b792b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1330,12 +1330,6 @@ static inline unsigned long page_size(struct page *page)
 	return PAGE_SIZE << compound_order(page);
 }
 
-/* Returns the number of bits needed for the number of bytes in a page */
-static inline unsigned int page_shift(struct page *page)
-{
-	return PAGE_SHIFT + compound_order(page);
-}
-
 /**
  * thp_order - Order of a transparent huge page.
  * @page: Head page of a transparent huge page.
@@ -4032,7 +4026,6 @@ extern int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
 					bool *migratable_cleared);
 void num_poisoned_pages_inc(unsigned long pfn);
 void num_poisoned_pages_sub(unsigned long pfn, long i);
-struct task_struct *task_early_kill(struct task_struct *tsk, int force_early);
 #else
 static inline void memory_failure_queue(unsigned long pfn, int flags)
 {
@@ -4053,12 +4046,6 @@ static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
 }
 #endif
 
-#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_KSM)
-void add_to_kill_ksm(struct task_struct *tsk, struct page *p,
-		     struct vm_area_struct *vma, struct list_head *to_kill,
-		     unsigned long ksm_addr);
-#endif
-
 #if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
 extern void memblk_nr_poison_inc(unsigned long pfn);
 extern void memblk_nr_poison_sub(unsigned long pfn, long i);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 104078afe0b1..00c33a6ea367 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -616,11 +616,6 @@ PAGEFLAG_FALSE(Uncached, uncached)
 PAGEFLAG(HWPoison, hwpoison, PF_ANY)
 TESTSCFLAG(HWPoison, hwpoison, PF_ANY)
 #define __PG_HWPOISON (1UL << PG_hwpoison)
-#define MAGIC_HWPOISON	0x48575053U	/* HWPS */
-extern void SetPageHWPoisonTakenOff(struct page *page);
-extern void ClearPageHWPoisonTakenOff(struct page *page);
-extern bool take_page_off_buddy(struct page *page);
-extern bool put_page_back_buddy(struct page *page);
 #else
 PAGEFLAG_FALSE(HWPoison, hwpoison)
 #define __PG_HWPOISON 0
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 5cb0d419a1d7..ece0515ee21c 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -733,8 +733,6 @@ int pfn_mkclean_range(unsigned long pfn, unsigned long nr_pages, pgoff_t pgoff,
 
 void remove_migration_ptes(struct folio *src, struct folio *dst, bool locked);
 
-unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma);
-
 /*
  * rmap_walk_control: To control rmap traversing for specific needs
  *
diff --git a/mm/internal.h b/mm/internal.h
index bbec99cc9d9d..188e292d2a77 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1061,6 +1061,22 @@ extern u64 hwpoison_filter_flags_mask;
 extern u64 hwpoison_filter_flags_value;
 extern u64 hwpoison_filter_memcg;
 extern u32 hwpoison_filter_enable;
+#define MAGIC_HWPOISON	0x48575053U	/* HWPS */
+extern void SetPageHWPoisonTakenOff(struct page *page);
+extern void ClearPageHWPoisonTakenOff(struct page *page);
+extern bool take_page_off_buddy(struct page *page);
+extern bool put_page_back_buddy(struct page *page);
+struct task_struct *task_early_kill(struct task_struct *tsk, int force_early);
+void add_to_kill_ksm(struct task_struct *tsk, struct page *p,
+		     struct vm_area_struct *vma, struct list_head *to_kill,
+		     unsigned long ksm_addr);
+unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma);
+
+/* Returns the number of bits needed for the number of bytes in a page */
+static inline unsigned int page_shift(struct page *page)
+{
+	return PAGE_SHIFT + compound_order(page);
+}
 
 extern unsigned long  __must_check vm_mmap_pgoff(struct file *, unsigned long,
         unsigned long, unsigned long,
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 11/13] mm/memory-failure: fix comment of get_hwpoison_page()
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (9 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 12/13] mm/memory-failure: remove obsolete comment in kill_proc() Miaohe Lin
  2024-05-24  9:13 ` [PATCH 13/13] mm/memory-failure: correct comment in me_swapcache_dirty Miaohe Lin
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

When return value is 0, it could also means the page is free hugetlb
page or free buddy page. Fix the corresponding comment.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e4252f297d41..705cd0bbb603 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1549,7 +1549,7 @@ static int __get_unpoison_page(struct page *page)
  * the given page has PG_hwpoison. So it's never reused for other page
  * allocations, and __get_unpoison_page() never races with them.
  *
- * Return: 0 on failure,
+ * Return: 0 on failure or free buddy (hugetlb) page,
  *         1 on success for in-use pages in a well-defined state,
  *         -EIO for pages on which we can not handle memory errors,
  *         -EBUSY when get_hwpoison_page() has raced with page lifecycle
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 12/13] mm/memory-failure: remove obsolete comment in kill_proc()
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (10 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 11/13] mm/memory-failure: fix comment of get_hwpoison_page() Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  2024-05-24  9:13 ` [PATCH 13/13] mm/memory-failure: correct comment in me_swapcache_dirty Miaohe Lin
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

When user sets SIGBUS to SIG_IGN, it won't cause loop now. For action
required mce error, SIGBUS cannot be blocked. Also when a hwpoisoned
page is re-accessed, kill_accessing_process() will be called to kill
the process.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 705cd0bbb603..b6bdb4e2834a 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -349,8 +349,6 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
 		 * PF_MCE_EARLY set.
 		 * Don't use force here, it's convenient if the signal
 		 * can be temporarily blocked.
-		 * This could cause a loop when the user sets SIGBUS
-		 * to SIG_IGN, but hopefully no one will do that?
 		 */
 		ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr,
 				      addr_lsb, t);
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 13/13] mm/memory-failure: correct comment in me_swapcache_dirty
  2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
                   ` (11 preceding siblings ...)
  2024-05-24  9:13 ` [PATCH 12/13] mm/memory-failure: remove obsolete comment in kill_proc() Miaohe Lin
@ 2024-05-24  9:13 ` Miaohe Lin
  12 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-24  9:13 UTC (permalink / raw)
  To: akpm, tony.luck, bp
  Cc: nao.horiguchi, linmiaohe, linux-mm, linux-kernel, linux-edac

Dirty swap cache page could live both in page table (not page cache) and
swap cache when freshly swapped in. Correct comment.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b6bdb4e2834a..16bf67ffa56a 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1150,7 +1150,7 @@ static int me_pagecache_dirty(struct page_state *ps, struct page *p)
  * Clean and dirty swap cache.
  *
  * Dirty swap cache page is tricky to handle. The page could live both in page
- * cache and swap cache(ie. page is freshly swapped in). So it could be
+ * table and swap cache(ie. page is freshly swapped in). So it could be
  * referenced concurrently by 2 types of PTEs:
  * normal PTEs and swap PTEs. We try to handle them consistently by calling
  * try_to_unmap(!TTU_HWPOISON) to convert the normal PTEs to swap PTEs,
-- 
2.33.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 04/13] mm/memory-failure: save a page_folio() call
  2024-05-24  9:13 ` [PATCH 04/13] mm/memory-failure: save a page_folio() call Miaohe Lin
@ 2024-05-24 15:06   ` David Hildenbrand
  2024-05-25  1:34     ` Miaohe Lin
  0 siblings, 1 reply; 22+ messages in thread
From: David Hildenbrand @ 2024-05-24 15:06 UTC (permalink / raw)
  To: Miaohe Lin, akpm, tony.luck, bp
  Cc: nao.horiguchi, linux-mm, linux-kernel, linux-edac

On 24.05.24 11:13, Miaohe Lin wrote:
> Use local variable folio directly to save a page_folio() call.
> No functional change intended.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>   mm/memory-failure.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index b571aaf987a2..73878ecdec22 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1658,7 +1658,7 @@ static bool hwpoison_user_mappings(struct folio *folio, struct page *p,
>   	unmap_success = !page_mapped(p);

We should be using folio_mapped() here.

>   	if (!unmap_success)
>   		pr_err("%#lx: failed to unmap page (folio mapcount=%d)\n",
> -		       pfn, folio_mapcount(page_folio(p)));
> +		       pfn, folio_mapcount(folio));

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 09/13] mm/memory-failure: remove obsolete comment in unpoison_memory()
  2024-05-24  9:13 ` [PATCH 09/13] mm/memory-failure: remove obsolete comment in unpoison_memory() Miaohe Lin
@ 2024-05-24 15:06   ` David Hildenbrand
  0 siblings, 0 replies; 22+ messages in thread
From: David Hildenbrand @ 2024-05-24 15:06 UTC (permalink / raw)
  To: Miaohe Lin, akpm, tony.luck, bp
  Cc: nao.horiguchi, linux-mm, linux-kernel, linux-edac

On 24.05.24 11:13, Miaohe Lin wrote:
> Since commit 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to
> allow larger rcu_head"), folio->_mapcount is not overloaded with SLAB.
> Update corresponding comment.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>   mm/memory-failure.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 19d338e83e43..e4252f297d41 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2610,10 +2610,6 @@ int unpoison_memory(unsigned long pfn)
>   	    folio_test_reserved(folio) || folio_test_offline(folio))
>   		goto unlock_mutex;
>   
> -	/*
> -	 * Note that folio->_mapcount is overloaded in SLAB, so the simple test
> -	 * in folio_mapped() has to be done after folio_test_slab() is checked.
> -	 */
>   	if (folio_mapped(folio)) {
>   		unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n",
>   				 pfn, &unpoison_rs);

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
  2024-05-24  9:13 ` [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant Miaohe Lin
@ 2024-05-24 15:38   ` kernel test robot
  2024-05-24 15:59   ` kernel test robot
  1 sibling, 0 replies; 22+ messages in thread
From: kernel test robot @ 2024-05-24 15:38 UTC (permalink / raw)
  To: Miaohe Lin, akpm, tony.luck, bp
  Cc: oe-kbuild-all, nao.horiguchi, linmiaohe, linux-mm, linux-kernel,
	linux-edac

Hi Miaohe,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master next-20240523]
[cannot apply to v6.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Miaohe-Lin/mm-memory-failure-simplify-put_ref_page/20240524-171903
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240524091310.1430048-8-linmiaohe%40huawei.com
patch subject: [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
config: i386-buildonly-randconfig-003-20240524 (https://download.01.org/0day-ci/archive/20240524/202405242320.8nUwcaQN-lkp@intel.com/config)
compiler: gcc-9 (Ubuntu 9.5.0-4ubuntu2) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405242320.8nUwcaQN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405242320.8nUwcaQN-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: mm/memory-failure.o: in function `memory_failure':
>> memory-failure.c:(.text+0x2635): undefined reference to `hwpoison_filter'
>> ld: memory-failure.c:(.text+0x283d): undefined reference to `hwpoison_filter'
   ld: mm/memory-failure.o: in function `soft_offline_page':
   memory-failure.c:(.text+0x2e12): undefined reference to `hwpoison_filter'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
  2024-05-24  9:13 ` [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant Miaohe Lin
  2024-05-24 15:38   ` kernel test robot
@ 2024-05-24 15:59   ` kernel test robot
  2024-05-25  1:52     ` Miaohe Lin
  1 sibling, 1 reply; 22+ messages in thread
From: kernel test robot @ 2024-05-24 15:59 UTC (permalink / raw)
  To: Miaohe Lin, akpm, tony.luck, bp
  Cc: oe-kbuild-all, nao.horiguchi, linmiaohe, linux-mm, linux-kernel,
	linux-edac

Hi Miaohe,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master next-20240523]
[cannot apply to v6.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Miaohe-Lin/mm-memory-failure-simplify-put_ref_page/20240524-171903
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240524091310.1430048-8-linmiaohe%40huawei.com
patch subject: [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
config: i386-randconfig-005-20240524 (https://download.01.org/0day-ci/archive/20240524/202405242336.o1NEOrln-lkp@intel.com/config)
compiler: gcc-11 (Ubuntu 11.4.0-4ubuntu1) 11.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405242336.o1NEOrln-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405242336.o1NEOrln-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: mm/memory-failure.o: in function `try_memory_failure_hugetlb':
>> mm/memory-failure.c:2098:(.text+0x28a8): undefined reference to `hwpoison_filter'
   ld: mm/memory-failure.o: in function `memory_failure':
   mm/memory-failure.c:2321:(.text+0x2a98): undefined reference to `hwpoison_filter'
   ld: mm/memory-failure.o: in function `soft_offline_page':
   mm/memory-failure.c:2841:(.text+0x3217): undefined reference to `hwpoison_filter'


vim +2098 mm/memory-failure.c

405ce051236cc6 Naoya Horiguchi         2022-04-21  2057  
405ce051236cc6 Naoya Horiguchi         2022-04-21  2058  /*
405ce051236cc6 Naoya Horiguchi         2022-04-21  2059   * Taking refcount of hugetlb pages needs extra care about race conditions
405ce051236cc6 Naoya Horiguchi         2022-04-21  2060   * with basic operations like hugepage allocation/free/demotion.
405ce051236cc6 Naoya Horiguchi         2022-04-21  2061   * So some of prechecks for hwpoison (pinning, and testing/setting
405ce051236cc6 Naoya Horiguchi         2022-04-21  2062   * PageHWPoison) should be done in single hugetlb_lock range.
405ce051236cc6 Naoya Horiguchi         2022-04-21  2063   */
405ce051236cc6 Naoya Horiguchi         2022-04-21  2064  static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb)
0348d2ebec9b00 Naoya Horiguchi         2017-07-10  2065  {
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2066  	int res;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2067  	struct page *p = pfn_to_page(pfn);
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2068  	struct folio *folio;
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2069  	unsigned long page_flags;
e591ef7d96d6ea Naoya Horiguchi         2022-10-24  2070  	bool migratable_cleared = false;
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2071  
405ce051236cc6 Naoya Horiguchi         2022-04-21  2072  	*hugetlb = 1;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2073  retry:
e591ef7d96d6ea Naoya Horiguchi         2022-10-24  2074  	res = get_huge_page_for_hwpoison(pfn, flags, &migratable_cleared);
405ce051236cc6 Naoya Horiguchi         2022-04-21  2075  	if (res == 2) { /* fallback to normal page handling */
405ce051236cc6 Naoya Horiguchi         2022-04-21  2076  		*hugetlb = 0;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2077  		return 0;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2078  	} else if (res == -EHWPOISON) {
96f96763de26d6 Kefeng Wang             2022-07-26  2079  		pr_err("%#lx: already hardware poisoned\n", pfn);
405ce051236cc6 Naoya Horiguchi         2022-04-21  2080  		if (flags & MF_ACTION_REQUIRED) {
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2081  			folio = page_folio(p);
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2082  			res = kill_accessing_process(current, folio_pfn(folio), flags);
38fe2f81155c0e Jane Chu                2024-05-21  2083  			action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED);
38fe2f81155c0e Jane Chu                2024-05-21  2084  			return res;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2085  		}
405ce051236cc6 Naoya Horiguchi         2022-04-21  2086  		return res;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2087  	} else if (res == -EBUSY) {
38f6d29397ccb9 Naoya Horiguchi         2022-07-14  2088  		if (!(flags & MF_NO_RETRY)) {
38f6d29397ccb9 Naoya Horiguchi         2022-07-14  2089  			flags |= MF_NO_RETRY;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2090  			goto retry;
405ce051236cc6 Naoya Horiguchi         2022-04-21  2091  		}
38fe2f81155c0e Jane Chu                2024-05-21  2092  		return action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED);
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2093  	}
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2094  
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2095  	folio = page_folio(p);
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2096  	folio_lock(folio);
405ce051236cc6 Naoya Horiguchi         2022-04-21  2097  
e37e7b0b3bd52e Naoya Horiguchi         2021-12-24 @2098  	if (hwpoison_filter(p)) {
2ff6cecee669bf Sidhartha Kumar         2023-01-12  2099  		folio_clear_hugetlb_hwpoison(folio);
e591ef7d96d6ea Naoya Horiguchi         2022-10-24  2100  		if (migratable_cleared)
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2101  			folio_set_hugetlb_migratable(folio);
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2102  		folio_unlock(folio);
f36a5543a74883 Miaohe Lin              2022-08-18  2103  		if (res == 1)
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2104  			folio_put(folio);
f36a5543a74883 Miaohe Lin              2022-08-18  2105  		return -EOPNOTSUPP;
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2106  	}
405ce051236cc6 Naoya Horiguchi         2022-04-21  2107  
405ce051236cc6 Naoya Horiguchi         2022-04-21  2108  	/*
405ce051236cc6 Naoya Horiguchi         2022-04-21  2109  	 * Handling free hugepage.  The possible race with hugepage allocation
405ce051236cc6 Naoya Horiguchi         2022-04-21  2110  	 * or demotion can be prevented by PageHWPoison flag.
405ce051236cc6 Naoya Horiguchi         2022-04-21  2111  	 */
405ce051236cc6 Naoya Horiguchi         2022-04-21  2112  	if (res == 0) {
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2113  		folio_unlock(folio);
f40962a5b0bca2 Miaohe Lin              2024-05-23  2114  		if (__page_handle_poison(p) > 0) {
a8b2c2ce89d4e0 Oscar Salvador          2020-12-14  2115  			page_ref_inc(p);
a8b2c2ce89d4e0 Oscar Salvador          2020-12-14  2116  			res = MF_RECOVERED;
ceaf8fbea79a85 Naoya Horiguchi         2022-07-14  2117  		} else {
ceaf8fbea79a85 Naoya Horiguchi         2022-07-14  2118  			res = MF_FAILED;
a8b2c2ce89d4e0 Oscar Salvador          2020-12-14  2119  		}
b66d00dfebe79e Kefeng Wang             2022-10-21  2120  		return action_result(pfn, MF_MSG_FREE_HUGE, res);
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2121  	}
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2122  
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2123  	page_flags = folio->flags;
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2124  
03468a0f52893b Matthew Wilcox (Oracle  2024-04-12  2125) 	if (!hwpoison_user_mappings(folio, p, pfn, flags)) {
bc1cfde1946752 Sidhartha Kumar         2023-01-12  2126  		folio_unlock(folio);
38fe2f81155c0e Jane Chu                2024-05-21  2127  		return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED);
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2128  	}
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2129  
ea6d0630100b28 Naoya Horiguchi         2021-06-24  2130  	return identify_page_state(pfn, p, page_flags);
761ad8d7c7b548 Naoya Horiguchi         2017-07-10  2131  }
00cc790e003693 Shiyang Ruan            2022-06-03  2132  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 04/13] mm/memory-failure: save a page_folio() call
  2024-05-24 15:06   ` David Hildenbrand
@ 2024-05-25  1:34     ` Miaohe Lin
  0 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-25  1:34 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: nao.horiguchi, linux-mm, linux-kernel, linux-edac, akpm, tony.luck, bp

On 2024/5/24 23:06, David Hildenbrand wrote:
> On 24.05.24 11:13, Miaohe Lin wrote:
>> Use local variable folio directly to save a page_folio() call.
>> No functional change intended.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>   mm/memory-failure.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index b571aaf987a2..73878ecdec22 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -1658,7 +1658,7 @@ static bool hwpoison_user_mappings(struct folio *folio, struct page *p,
>>       unmap_success = !page_mapped(p);
> 
> We should be using folio_mapped() here.

Will fix this.

> 
>>       if (!unmap_success)
>>           pr_err("%#lx: failed to unmap page (folio mapcount=%d)\n",
>> -               pfn, folio_mapcount(page_folio(p)));
>> +               pfn, folio_mapcount(folio));
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>

Thanks for your comment.
.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
  2024-05-24 15:59   ` kernel test robot
@ 2024-05-25  1:52     ` Miaohe Lin
  0 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-25  1:52 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-kbuild-all, nao.horiguchi, linux-mm, linux-kernel, linux-edac,
	akpm, tony.luck, bp

On 2024/5/24 23:59, kernel test robot wrote:
> Hi Miaohe,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on akpm-mm/mm-everything]
> [also build test ERROR on linus/master next-20240523]
> [cannot apply to v6.9]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Miaohe-Lin/mm-memory-failure-simplify-put_ref_page/20240524-171903
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link:    https://lore.kernel.org/r/20240524091310.1430048-8-linmiaohe%40huawei.com
> patch subject: [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant
> config: i386-randconfig-005-20240524 (https://download.01.org/0day-ci/archive/20240524/202405242336.o1NEOrln-lkp@intel.com/config)
> compiler: gcc-11 (Ubuntu 11.4.0-4ubuntu1) 11.4.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405242336.o1NEOrln-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202405242336.o1NEOrln-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>    ld: mm/memory-failure.o: in function `try_memory_failure_hugetlb':
>>> mm/memory-failure.c:2098:(.text+0x28a8): undefined reference to `hwpoison_filter'
>    ld: mm/memory-failure.o: in function `memory_failure':
>    mm/memory-failure.c:2321:(.text+0x2a98): undefined reference to `hwpoison_filter'
>    ld: mm/memory-failure.o: in function `soft_offline_page':
>    mm/memory-failure.c:2841:(.text+0x3217): undefined reference to `hwpoison_filter'

Thanks for building and reporting. I will fix this in next version.
Thanks.
.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h
  2024-05-24  9:13 ` [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h Miaohe Lin
@ 2024-05-25  2:39   ` kernel test robot
  2024-05-25  6:39     ` Miaohe Lin
  0 siblings, 1 reply; 22+ messages in thread
From: kernel test robot @ 2024-05-25  2:39 UTC (permalink / raw)
  To: Miaohe Lin, akpm, tony.luck, bp
  Cc: oe-kbuild-all, nao.horiguchi, linmiaohe, linux-mm, linux-kernel,
	linux-edac

Hi Miaohe,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master next-20240523]
[cannot apply to v6.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Miaohe-Lin/mm-memory-failure-simplify-put_ref_page/20240524-171903
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240524091310.1430048-11-linmiaohe%40huawei.com
patch subject: [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240525/202405251049.hxjwX7zO-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240525/202405251049.hxjwX7zO-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405251049.hxjwX7zO-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/vfio/vfio_iommu_spapr_tce.c: In function 'tce_page_is_contained':
>> drivers/vfio/vfio_iommu_spapr_tce.c:195:16: error: implicit declaration of function 'page_shift'; did you mean 'page_size'? [-Werror=implicit-function-declaration]
     195 |         return page_shift(compound_head(page)) >= it_page_shift;
         |                ^~~~~~~~~~
         |                page_size
   cc1: some warnings being treated as errors
--
   arch/powerpc/mm/book3s64/iommu_api.c: In function 'mm_iommu_do_alloc':
>> arch/powerpc/mm/book3s64/iommu_api.c:155:45: error: implicit declaration of function 'page_shift'; did you mean 'page_size'? [-Werror=implicit-function-declaration]
     155 |                                 pageshift = page_shift(compound_head(page));
         |                                             ^~~~~~~~~~
         |                                             page_size
   cc1: some warnings being treated as errors
--
   drivers/net/ethernet/ibm/ehea/ehea_qmr.c: In function 'ehea_is_hugepage':
>> drivers/net/ethernet/ibm/ehea/ehea_qmr.c:676:13: error: implicit declaration of function 'page_shift'; did you mean 'page_size'? [-Werror=implicit-function-declaration]
     676 |         if (page_shift(pfn_to_page(pfn)) != EHEA_HUGEPAGESHIFT)
         |             ^~~~~~~~~~
         |             page_size
   cc1: some warnings being treated as errors


vim +195 drivers/vfio/vfio_iommu_spapr_tce.c

2157e7b82f3b81 Alexey Kardashevskiy    2015-06-05  179  
c10c21efa4bcca Alexey Kardashevskiy    2018-12-19  180  static bool tce_page_is_contained(struct mm_struct *mm, unsigned long hpa,
94ad9338109fe9 Matthew Wilcox (Oracle  2019-09-23  181) 		unsigned int it_page_shift)
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  182  {
c10c21efa4bcca Alexey Kardashevskiy    2018-12-19  183  	struct page *page;
c10c21efa4bcca Alexey Kardashevskiy    2018-12-19  184  	unsigned long size = 0;
c10c21efa4bcca Alexey Kardashevskiy    2018-12-19  185  
94ad9338109fe9 Matthew Wilcox (Oracle  2019-09-23  186) 	if (mm_iommu_is_devmem(mm, hpa, it_page_shift, &size))
94ad9338109fe9 Matthew Wilcox (Oracle  2019-09-23  187) 		return size == (1UL << it_page_shift);
c10c21efa4bcca Alexey Kardashevskiy    2018-12-19  188  
c10c21efa4bcca Alexey Kardashevskiy    2018-12-19  189  	page = pfn_to_page(hpa >> PAGE_SHIFT);
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  190  	/*
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  191  	 * Check that the TCE table granularity is not bigger than the size of
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  192  	 * a page we just found. Otherwise the hardware can get access to
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  193  	 * a bigger memory chunk that it should.
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  194  	 */
94ad9338109fe9 Matthew Wilcox (Oracle  2019-09-23 @195) 	return page_shift(compound_head(page)) >= it_page_shift;
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  196  }
e432bc7e15d802 Alexey Kardashevskiy    2015-06-05  197  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h
  2024-05-25  2:39   ` kernel test robot
@ 2024-05-25  6:39     ` Miaohe Lin
  0 siblings, 0 replies; 22+ messages in thread
From: Miaohe Lin @ 2024-05-25  6:39 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-kbuild-all, nao.horiguchi, linux-mm, linux-kernel, linux-edac,
	akpm, tony.luck, bp

On 2024/5/25 10:39, kernel test robot wrote:
> Hi Miaohe,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on akpm-mm/mm-everything]
> [also build test ERROR on linus/master next-20240523]
> [cannot apply to v6.9]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Miaohe-Lin/mm-memory-failure-simplify-put_ref_page/20240524-171903
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link:    https://lore.kernel.org/r/20240524091310.1430048-11-linmiaohe%40huawei.com
> patch subject: [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h
> config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240525/202405251049.hxjwX7zO-lkp@intel.com/config)
> compiler: powerpc64-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240525/202405251049.hxjwX7zO-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202405251049.hxjwX7zO-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>    drivers/vfio/vfio_iommu_spapr_tce.c: In function 'tce_page_is_contained':
>>> drivers/vfio/vfio_iommu_spapr_tce.c:195:16: error: implicit declaration of function 'page_shift'; did you mean 'page_size'? [-Werror=implicit-function-declaration]
>      195 |         return page_shift(compound_head(page)) >= it_page_shift;
>          |                ^~~~~~~~~~
>          |                page_size
>    cc1: some warnings being treated as errors
> --
>    arch/powerpc/mm/book3s64/iommu_api.c: In function 'mm_iommu_do_alloc':
>>> arch/powerpc/mm/book3s64/iommu_api.c:155:45: error: implicit declaration of function 'page_shift'; did you mean 'page_size'? [-Werror=implicit-function-declaration]
>      155 |                                 pageshift = page_shift(compound_head(page));
>          |                                             ^~~~~~~~~~
>          |                                             page_size
>    cc1: some warnings being treated as errors
> --
>    drivers/net/ethernet/ibm/ehea/ehea_qmr.c: In function 'ehea_is_hugepage':
>>> drivers/net/ethernet/ibm/ehea/ehea_qmr.c:676:13: error: implicit declaration of function 'page_shift'; did you mean 'page_size'? [-Werror=implicit-function-declaration]
>      676 |         if (page_shift(pfn_to_page(pfn)) != EHEA_HUGEPAGESHIFT)
>          |             ^~~~~~~~~~
>          |             page_size
>    cc1: some warnings being treated as errors

Will fix this too. Thanks for testing and reporting.
Thanks.
.



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-05-25  6:39 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24  9:12 [PATCH 00/13] Some cleanups for memory-failure Miaohe Lin
2024-05-24  9:12 ` [PATCH 01/13] mm/memory-failure: simplify put_ref_page() Miaohe Lin
2024-05-24  9:12 ` [PATCH 02/13] mm/memory-failure: remove MF_MSG_SLAB Miaohe Lin
2024-05-24  9:13 ` [PATCH 03/13] mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM Miaohe Lin
2024-05-24  9:13 ` [PATCH 04/13] mm/memory-failure: save a page_folio() call Miaohe Lin
2024-05-24 15:06   ` David Hildenbrand
2024-05-25  1:34     ` Miaohe Lin
2024-05-24  9:13 ` [PATCH 05/13] mm/memory-failure: remove unneeded empty string Miaohe Lin
2024-05-24  9:13 ` [PATCH 06/13] mm/memory-failure: remove confusing initialization to count Miaohe Lin
2024-05-24  9:13 ` [PATCH 07/13] mm/memory-failure: remove unneeded hwpoison_filter() variant Miaohe Lin
2024-05-24 15:38   ` kernel test robot
2024-05-24 15:59   ` kernel test robot
2024-05-25  1:52     ` Miaohe Lin
2024-05-24  9:13 ` [PATCH 08/13] mm/memory-failure: use helper macro task_pid_nr() Miaohe Lin
2024-05-24  9:13 ` [PATCH 09/13] mm/memory-failure: remove obsolete comment in unpoison_memory() Miaohe Lin
2024-05-24 15:06   ` David Hildenbrand
2024-05-24  9:13 ` [PATCH 10/13] mm/memory-failure: move some function declarations into internal.h Miaohe Lin
2024-05-25  2:39   ` kernel test robot
2024-05-25  6:39     ` Miaohe Lin
2024-05-24  9:13 ` [PATCH 11/13] mm/memory-failure: fix comment of get_hwpoison_page() Miaohe Lin
2024-05-24  9:13 ` [PATCH 12/13] mm/memory-failure: remove obsolete comment in kill_proc() Miaohe Lin
2024-05-24  9:13 ` [PATCH 13/13] mm/memory-failure: correct comment in me_swapcache_dirty Miaohe Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox