linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Oscar Salvador <osalvador@suse.de>
Subject: [PATCH 4/5] memory-failure: Reorganise get_huge_page_for_hwpoison()
Date: Fri,  1 Mar 2024 21:47:09 +0000	[thread overview]
Message-ID: <20240301214712.2853147-5-willy@infradead.org> (raw)
In-Reply-To: <20240301214712.2853147-1-willy@infradead.org>

There's no need to split this function across hugetlb.c and
memory-failure.c now that hugetlb_lock is visible outside hugetlb.c
(since 2012).

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/hugetlb.h |  8 --------
 include/linux/mm.h      |  8 --------
 mm/hugetlb.c            | 11 -----------
 mm/memory-failure.c     |  8 ++++++--
 4 files changed, 6 insertions(+), 29 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index c1d23ab53752..89f4b90eec68 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -165,8 +165,6 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
 bool isolate_hugetlb(struct folio *folio, struct list_head *list);
 struct folio *hugetlb_pfn_folio(unsigned long pfn);
 int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison);
-int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
-				bool *migratable_cleared);
 void folio_putback_active_hugetlb(struct folio *folio);
 void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason);
 void hugetlb_fix_reserve_counts(struct inode *inode);
@@ -452,12 +450,6 @@ static inline int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb,
 	return 0;
 }
 
-static inline int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
-					bool *migratable_cleared)
-{
-	return 0;
-}
-
 static inline void folio_putback_active_hugetlb(struct folio *folio)
 {
 }
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0436b919f1c7..cfbf2bbc6200 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3978,8 +3978,6 @@ extern int soft_offline_page(unsigned long pfn, int flags);
  */
 extern const struct attribute_group memory_failure_attr_group;
 extern void memory_failure_queue(unsigned long pfn, int flags);
-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);
@@ -3988,12 +3986,6 @@ static inline void memory_failure_queue(unsigned long pfn, int flags)
 {
 }
 
-static inline int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
-					bool *migratable_cleared)
-{
-	return 0;
-}
-
 static inline void num_poisoned_pages_inc(unsigned long pfn)
 {
 }
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 0895debc36f3..2e6ebedb75a8 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -7674,17 +7674,6 @@ int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison
 	return ret;
 }
 
-int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
-				bool *migratable_cleared)
-{
-	int ret;
-
-	spin_lock_irq(&hugetlb_lock);
-	ret = __get_huge_page_for_hwpoison(pfn, flags, migratable_cleared);
-	spin_unlock_irq(&hugetlb_lock);
-	return ret;
-}
-
 void folio_putback_active_hugetlb(struct folio *folio)
 {
 	spin_lock_irq(&hugetlb_lock);
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e42d0cd7888d..fe9d2a0cb962 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1984,13 +1984,15 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio)
  *   -EBUSY        - the hugepage is busy (try to retry)
  *   -EHWPOISON    - the hugepage is already hwpoisoned
  */
-int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
+static int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
 				 bool *migratable_cleared)
 {
 	struct folio *folio;
 	int ret = 2;	/* fallback to normal page handling */
 	bool count_increased = false;
 
+	spin_lock_irq(&hugetlb_lock);
+
 	folio = hwpoison_pfn_folio(pfn);
 	if (!folio)
 		goto out;
@@ -2024,10 +2026,12 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
 		*migratable_cleared = true;
 	}
 
-	return ret;
+	goto unlock;
 out:
 	if (count_increased)
 		folio_put(folio);
+unlock:
+	spin_unlock_irq(&hugetlb_lock);
 	return ret;
 }
 
-- 
2.43.0



  parent reply	other threads:[~2024-03-01 21:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 21:47 [PATCH 0/5] Remove some races around folio_test_hugetlb Matthew Wilcox (Oracle)
2024-03-01 21:47 ` [PATCH 1/5] hugetlb: Make folio_test_hugetlb safer to call Matthew Wilcox (Oracle)
2024-03-05  6:43   ` Oscar Salvador
2024-03-05  8:39   ` David Hildenbrand
2024-03-01 21:47 ` [PATCH 2/5] hugetlb: Add hugetlb_pfn_folio Matthew Wilcox (Oracle)
2024-03-05  6:58   ` Oscar Salvador
2024-03-01 21:47 ` [PATCH 3/5] memory-failure: Use hugetlb_pfn_folio Matthew Wilcox (Oracle)
2024-03-01 21:47 ` Matthew Wilcox (Oracle) [this message]
2024-03-01 21:47 ` [PATCH 5/5] compaction: Use hugetlb_pfn_folio in isolate_migratepages_block Matthew Wilcox (Oracle)
2024-03-04  9:09 ` [PATCH 0/5] Remove some races around folio_test_hugetlb Miaohe Lin
2024-03-04 17:08   ` Matthew Wilcox
2024-03-06  7:58     ` Miaohe Lin
2024-03-07 21:16       ` Matthew Wilcox
2024-03-05  9:10 ` David Hildenbrand
2024-03-05 20:35   ` Matthew Wilcox
2024-03-06 15:18     ` David Hildenbrand
2024-03-07  4:31       ` Matthew Wilcox
2024-03-07  9:20         ` David Hildenbrand
2024-03-07 21:14           ` Matthew Wilcox
2024-03-07 21:38             ` David Hildenbrand
2024-03-08  4:31             ` Matthew Wilcox
2024-03-08  8:46               ` David Hildenbrand

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=20240301214712.2853147-5-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    /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).