Skip to contentSkip to conversation

mm: remove arch_make_page_accessible()

PATCH Applied David Hildenbrand 4 participants 7 messages Jul 29, 2024 – Jul 30, 2024

Subsystems (6)
Memory management KVM MM core s390 +2 more subsystems
lore
Share & tools
lore
#0 lore raw

cover mm: remove arch_make_page_accessible()

Now that s390x implements arch_make_folio_accessible(), let's convert remaining users to use arch_make_folio_accessible() instead so we can remove arch_make_page_accessible().

Cc Andrew Morton <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Alexander Gordeev <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Janosch Frank <[email protected]>
Cc Claudio Imbrenda <[email protected]>

David Hildenbrand (3):
mm: simplify arch_make_folio_accessible()
mm/gup: convert to arch_make_folio_accessible()
s390/uv: drop arch_make_page_accessible()

 arch/s390/include/asm/page.h |  2 --
 arch/s390/kernel/uv.c        |  5 -----
 include/linux/mm.h           | 18 +-----------------
 mm/gup.c                     |  8 +++++---
 4 files changed, 6 insertions(+), 27 deletions(-)

base-commit: 3bb434b9ff9bfeacf7f4aef6ae036146ae3c40cc

Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/3 mm: simplify arch_make_folio_accessible()

Now that s390x implements HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE, let's turn generic arch_make_folio_accessible() into a NOP: there are no other targets that implement HAVE_ARCH_MAKE_PAGE_ACCESSIBLE but not HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE.

---
 include/linux/mm.h | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
include/linux/mm.h +1 -10
index 381750f41767a..bab689ec77f94 100644
@@ -2215,16 +2215,7 @@ static inline int arch_make_page_accessible(struct page *page)
 #ifndef HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE
 static inline int arch_make_folio_accessible(struct folio *folio)
 {
-	int ret;
-	long i, nr = folio_nr_pages(folio);
-
-	for (i = 0; i < nr; i++) {
-		ret = arch_make_page_accessible(folio_page(folio, i));
-		if (ret)
-			break;
-	}
-
-	return ret;
+	return 0;
 }
 #endif
 
Signature · 1 line
2.45.2
#2 lore raw

PATCH 2/3 mm/gup: convert to arch_make_folio_accessible()

In reply to David Hildenbrand

Let's use arch_make_folio_accessible() instead so we can get rid of arch_make_page_accessible().

---
 mm/gup.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
mm/gup.c +5 -3
index 120740cf5a348..3e8484c893aa8 100644
@@ -819,6 +819,7 @@ static struct page *follow_page_pte(struct vm_area_struct *vma,
 		struct dev_pagemap **pgmap)
 {
 	struct mm_struct *mm = vma->vm_mm;
+	struct folio *folio;
 	struct page *page;
 	spinlock_t *ptl;
 	pte_t *ptep, pte;
@@ -876,6 +877,7 @@ static struct page *follow_page_pte(struct vm_area_struct *vma,
 			goto out;
 		}
 	}
+	folio = page_folio(page);
 
 	if (!pte_write(pte) && gup_must_unshare(vma, flags, page)) {
 		page = ERR_PTR(-EMLINK);
@@ -886,7 +888,7 @@ static struct page *follow_page_pte(struct vm_area_struct *vma,
 		       !PageAnonExclusive(page), page);
 
 	/* try_grab_folio() does nothing unless FOLL_GET or FOLL_PIN is set. */
-	ret = try_grab_folio(page_folio(page), 1, flags);
+	ret = try_grab_folio(folio, 1, flags);
 	if (unlikely(ret)) {
 		page = ERR_PTR(ret);
 		goto out;
@@ -898,7 +900,7 @@ static struct page *follow_page_pte(struct vm_area_struct *vma,
 	 * Documentation/core-api/pin_user_pages.rst for details.
 	 */
 	if (flags & FOLL_PIN) {
-		ret = arch_make_page_accessible(page);
+		ret = arch_make_folio_accessible(folio);
 		if (ret) {
 			unpin_user_page(page);
 			page = ERR_PTR(ret);
@@ -2919,7 +2921,7 @@ static int gup_fast_pte_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr,
 		 * details.
 		 */
 		if (flags & FOLL_PIN) {
-			ret = arch_make_page_accessible(page);
+			ret = arch_make_folio_accessible(folio);
 			if (ret) {
 				gup_put_folio(folio, 1, flags);
 				goto pte_unmap;
Signature · 1 line
2.45.2
#3 lore raw

PATCH 3/3 s390/uv: drop arch_make_page_accessible()

In reply to David Hildenbrand

All code was converted to using arch_make_folio_accessible(), let's drop arch_make_page_accessible().

---
 arch/s390/include/asm/page.h | 2 --
 arch/s390/kernel/uv.c        | 5 -----
 include/linux/mm.h           | 7 -------
 3 files changed, 14 deletions(-)
arch/s390/include/asm/page.h +0 -2
index 06416b3f94f59..515db8241eb6b 100644
@@ -176,8 +176,6 @@ static inline int devmem_is_allowed(unsigned long pfn)
 
 int arch_make_folio_accessible(struct folio *folio);
 #define HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE
-int arch_make_page_accessible(struct page *page);
-#define HAVE_ARCH_MAKE_PAGE_ACCESSIBLE
 
 struct vm_layout {
 	unsigned long kaslr_offset;
arch/s390/kernel/uv.c +0 -5
index 36db065c7cf75..35ed2aea88918 100644
@@ -548,11 +548,6 @@ int arch_make_folio_accessible(struct folio *folio)
 }
 EXPORT_SYMBOL_GPL(arch_make_folio_accessible);
 
-int arch_make_page_accessible(struct page *page)
-{
-	return arch_make_folio_accessible(page_folio(page));
-}
-EXPORT_SYMBOL_GPL(arch_make_page_accessible);
 static ssize_t uv_query_facilities(struct kobject *kobj,
 				   struct kobj_attribute *attr, char *buf)
 {
include/linux/mm.h +0 -7
index bab689ec77f94..07b478952bb02 100644
@@ -2205,13 +2205,6 @@ static inline bool folio_likely_mapped_shared(struct folio *folio)
 	return atomic_read(&folio->_mapcount) > 0;
 }
 
-#ifndef HAVE_ARCH_MAKE_PAGE_ACCESSIBLE
-static inline int arch_make_page_accessible(struct page *page)
-{
-	return 0;
-}
-#endif
-
 #ifndef HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE
 static inline int arch_make_folio_accessible(struct folio *folio)
 {
Signature · 1 line
2.45.2
maintainer Reviewed-by on the v1 series
#5 lore raw
In reply to David Hildenbrand

Thank you for taking care of this!

Whole series:

Quoted 27 lines · On Mon, 29 Jul 2024 20:38:41 +0200 David Hildenbrand <[email protected]> wrote:

Now that s390x implements arch_make_folio_accessible(), let's convert remaining users to use arch_make_folio_accessible() instead so we can remove arch_make_page_accessible().

Cc Andrew Morton <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Alexander Gordeev <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Janosch Frank <[email protected]>
Cc Claudio Imbrenda <[email protected]>

David Hildenbrand (3):
mm: simplify arch_make_folio_accessible()
mm/gup: convert to arch_make_folio_accessible()
s390/uv: drop arch_make_page_accessible()

 arch/s390/include/asm/page.h |  2 --
 arch/s390/kernel/uv.c        |  5 -----
 include/linux/mm.h           | 18 +-----------------
 mm/gup.c                     |  8 +++++---
 4 files changed, 6 insertions(+), 27 deletions(-)

base-commit: 3bb434b9ff9bfeacf7f4aef6ae036146ae3c40cc