]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/memory.c: use folios in __copy_remote_vm_str()
authorVishal Moola (Oracle) <vishal.moola@gmail.com>
Wed, 9 Jul 2025 19:40:16 +0000 (12:40 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 20 Jul 2025 01:59:51 +0000 (18:59 -0700)
Patch series "Remove unmap_and_put_page()".

This patchset uses folios in both the callers of unmap_and_put_page(),
saving a couple calls to compound_head() wrappers.

This patch (of 3):

Use kmap_local_folio() instead of kmap_local_page().  Replaces 2 calls to
compound_head() from unmap_and_put_page() with one.

This prepares us for the removal of unmap_and_put_page().

Link: https://lkml.kernel.org/r/20250709194017.927978-3-vishal.moola@gmail.com
Link: https://lkml.kernel.org/r/20250709194017.927978-4-vishal.moola@gmail.com
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Jordan Rome <linux@jordanrome.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory.c

index 4619bf5874af0e47bf7364438f8c325f23ff53d7..cb2f1296854a60dfd5c98887b041664aa5969050 100644 (file)
@@ -6815,6 +6815,7 @@ static int __copy_remote_vm_str(struct mm_struct *mm, unsigned long addr,
        while (len) {
                int bytes, offset, retval;
                void *maddr;
+               struct folio *folio;
                struct page *page;
                struct vm_area_struct *vma = NULL;
 
@@ -6830,17 +6831,18 @@ static int __copy_remote_vm_str(struct mm_struct *mm, unsigned long addr,
                        goto out;
                }
 
+               folio = page_folio(page);
                bytes = len;
                offset = addr & (PAGE_SIZE - 1);
                if (bytes > PAGE_SIZE - offset)
                        bytes = PAGE_SIZE - offset;
 
-               maddr = kmap_local_page(page);
+               maddr = kmap_local_folio(folio, folio_page_idx(folio, page) * PAGE_SIZE);
                retval = strscpy(buf, maddr + offset, bytes);
                if (retval >= 0) {
                        /* Found the end of the string */
                        buf += retval;
-                       unmap_and_put_page(page, maddr);
+                       folio_release_kmap(folio, maddr);
                        break;
                }
 
@@ -6858,7 +6860,7 @@ static int __copy_remote_vm_str(struct mm_struct *mm, unsigned long addr,
                }
                len -= bytes;
 
-               unmap_and_put_page(page, maddr);
+               folio_release_kmap(folio, maddr);
        }
 
 out: