From: Danish Khateeb <danishkhateeb03@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
Danish Khateeb <danishkhateeb03@gmail.com>
Subject: [PATCH] sparc64: mm: use kmap_local_page() in copy_{user_,}highpage()
Date: Tue, 22 Sep 2026 10:37:36 -0500 [thread overview]
Message-ID: <20260922153736.74167-1-danishkhateeb03@gmail.com> (raw)
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
reply other threads:[~2026-09-22 15:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260922153736.74167-1-danishkhateeb03@gmail.com \
--to=danishkhateeb03@gmail.com \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
/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
all inboxes | Powered by JetHome®