* [PATCH] sparc64: mm: use kmap_local_page() in copy_{user_,}highpage()
@ 2026-09-22 15:37 Danish Khateeb
0 siblings, 0 replies; only message in thread
From: Danish Khateeb @ 2026-09-22 15:37 UTC (permalink / raw)
To: David S. Miller, Andreas Larsson; +Cc: sparclinux, linux-kernel, Danish Khateeb
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.
Assisted-by: LLM sparse
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
---
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(-)
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 103db4683b16..5af327e5aa64 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -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
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-22 15:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 15:37 [PATCH] sparc64: mm: use kmap_local_page() in copy_{user_,}highpage() Danish Khateeb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®