sparc64: mm: use kmap_local_page() in copy_{user_,}highpage()
PATCH 1/1 sparc64: mm: use kmap_local_page() in copy_{user_,}highpage()
kmap_atomic() is deprecated in favour of kmap_local_page(), as described in Documentation/mm/highmem.rst.
sparc64 has its own copy_user_highpage() and copy_highpage(), so that it can copy ADI tags along with the data. Apart from that they are copies of the generic helpers in <linux/highmem.h>, which were converted to kmap_local_page() in commit d2c20e51e396 ("mm/highmem: remove deprecated kmap_atomic").
sparc64 has no HIGHMEM, so both mappings are just page_address(), and all that kmap_atomic() adds is disabling preemption and page faults around the copy. Neither is needed. copy_page() is memcpy(). On sun4u, copy_user_page() disables preemption itself while it uses its temporary TLB mappings, as clear_user_page() does, and the generic clear_user_highpage() has called sparc64's clear_user_page() under kmap_local_page() since that same commit. On sun4v, copy_user_page() is patched to routines that copy through the linear mapping. No user memory is touched, and the ADI tags are copied after the unmap, by physical address.
Convert both functions to kmap_local_page() and kunmap_local(), like the generic helpers.
---
Notes:
Tested under QEMU (sun4u) with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, lockdep and CONFIG_DEBUG_ATOMIC_SLEEP. copy_user_highpage() through COW after fork() (with both the child and the parent writing), the first write to a MAP_PRIVATE file mapping and COW of a hugetlb page: 3332 copies. copy_highpage() through page migration by /proc/sys/vm/compact_memory, set up so that the test pages were among the ~37500 pages migrated. Every word of every copied test page was checked, and kprobes counted the calls. No warnings. With a CPU-bound task competing, the patched kernel was preempted inside the memcpy() of a migration, which could not happen before. sun4v is not tested, as QEMU cannot boot Linux there.
arch/sparc/mm/init_64.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/sparc/mm/init_64.c +8 -8
@@ -3072,11 +3072,11 @@ void copy_user_highpage(struct page *to, struct page *from, {char *vfrom, *vto; - vfrom =kmap_atomic (from); - vto =kmap_atomic (to); + vfrom =kmap_local_page (from); + vto =kmap_local_page (to);copy_user_page (vto, vfrom, vaddr, to); -kunmap_atomic (vto); -kunmap_atomic (vfrom); +kunmap_local (vto); +kunmap_local (vfrom);/* If this page has ADI enabled, copy over any ADI tags * as well
@@ -3106,11 +3106,11 @@ void copy_highpage(struct page *to, struct page *from) {char *vfrom, *vto; - vfrom =kmap_atomic (from); - vto =kmap_atomic (to); + vfrom =kmap_local_page (from); + vto =kmap_local_page (to);copy_page (vto, vfrom); -kunmap_atomic (vto); -kunmap_atomic (vfrom); +kunmap_local (vto); +kunmap_local (vfrom);/* If this platform is ADI enabled, copy any ADI tags * as well
base-commit: 93f51579e7df248780214094418f205253383cc5
Signature · 1 line
2.55.0