Skip to contentSkip to conversation

uprobes: transition from kmap_atomic to kmap_local_page

PATCH Applied Keke Ming 5 participants 14 messages Jan 3 – Feb 20

Subsystems (8)
lore
Share & tools
lore

Keke Ming

author
#0 lore raw

cover uprobes: transition from kmap_atomic to kmap_local_page

The use of kmap_atomic/kunmap_atomic is deprecated. The purpose of kmap-like functions is to create temporary mappings.

kmap_atomic() typically disables preemption, while kmap_local_page() allows preemption.

According to the documentation, kmap_atomic() is primarily necessary for contexts that cannot sleep.

Quoted 8 lines

kmap_atomic() may also be used by interrupt contexts, since it does not sleep and the callers too may not sleep until after kunmap_atomic() is called.

kunmap_atomic() may implicitly depend on the side effects of atomic mappings, i.e. disabling page faults or preemption, or both. In that case, explicit calls to pagefault_disable() or preempt_disable() or both must be made in conjunction with the use of kmap_local_page().

Keke Ming (5):
riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()
uprobes: use kmap_local_page() for temporary page mappings

 arch/arm/probes/uprobes/core.c     |  4 ++--
 arch/arm64/kernel/probes/uprobes.c |  4 ++--
 arch/mips/kernel/uprobes.c         |  4 ++--
 arch/riscv/kernel/probes/uprobes.c |  4 ++--
 kernel/events/uprobes.c            | 12 ++++++------
 5 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/5 riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/riscv/kernel/probes/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/probes/uprobes.c +2 -2
index cc15f7ca6cc1..f0d0691a8688 100644
@@ -165,7 +165,7 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 			   void *src, unsigned long len)
 {
 	/* Initialize the slot */
-	void *kaddr = kmap_atomic(page);
+	void *kaddr = kmap_local_page(page);
 	void *dst = kaddr + (vaddr & ~PAGE_MASK);
 	unsigned long start = (unsigned long)dst;
 
@@ -178,5 +178,5 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 	}
 
 	flush_icache_range(start, start + len);
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 }
Signature · 1 line
2.43.0
merge bot Applied
#2 lore raw

[tip: perf/core] riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     a18dfb5dd33247679a0cc4ff208ad7340d1e08a5
Gitweb:        https://git.kernel.org/tip/a18dfb5dd33247679a0cc4ff208ad7340d1e08a5
Author:        Keke Ming <[email protected]>
AuthorDate:    Sat, 03 Jan 2026 16:42:39 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 06 Jan 2026 16:34:27 +01:00

riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/riscv/kernel/probes/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/probes/uprobes.c +2 -2
index cc15f7c..f0d0691 100644
@@ -165,7 +165,7 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 			   void *src, unsigned long len)
 {
 	/* Initialize the slot */
-	void *kaddr = kmap_atomic(page);
+	void *kaddr = kmap_local_page(page);
 	void *dst = kaddr + (vaddr & ~PAGE_MASK);
 	unsigned long start = (unsigned long)dst;
 
@@ -178,5 +178,5 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 	}
 
 	flush_icache_range(start, start + len);
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 }
author
#3 lore raw

PATCH 2/5 arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

In reply to Keke Ming

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/arm64/kernel/probes/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/probes/uprobes.c +2 -2
index 941668800aea..4c55bf832ec3 100644
@@ -15,7 +15,7 @@
 void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 		void *src, unsigned long len)
 {
-	void *xol_page_kaddr = kmap_atomic(page);
+	void *xol_page_kaddr = kmap_local_page(page);
 	void *dst = xol_page_kaddr + (vaddr & ~PAGE_MASK);
 
 	/*
@@ -32,7 +32,7 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 	sync_icache_aliases((unsigned long)dst, (unsigned long)dst + len);
 
 done:
-	kunmap_atomic(xol_page_kaddr);
+	kunmap_local(xol_page_kaddr);
 }
 
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
Signature · 1 line
2.43.0
merge bot Applied
#4 lore raw

[tip: perf/core] arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     094cc7bb5fc3b484614417b4578233a38e3df942
Gitweb:        https://git.kernel.org/tip/094cc7bb5fc3b484614417b4578233a38e3df942
Author:        Keke Ming <[email protected]>
AuthorDate:    Sat, 03 Jan 2026 16:42:40 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 06 Jan 2026 16:34:27 +01:00

arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/arm64/kernel/probes/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/probes/uprobes.c +2 -2
index 9416688..4c55bf8 100644
@@ -15,7 +15,7 @@
 void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 		void *src, unsigned long len)
 {
-	void *xol_page_kaddr = kmap_atomic(page);
+	void *xol_page_kaddr = kmap_local_page(page);
 	void *dst = xol_page_kaddr + (vaddr & ~PAGE_MASK);
 
 	/*
@@ -32,7 +32,7 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 	sync_icache_aliases((unsigned long)dst, (unsigned long)dst + len);
 
 done:
-	kunmap_atomic(xol_page_kaddr);
+	kunmap_local(xol_page_kaddr);
 }
 
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
author
#5 lore raw

PATCH 3/5 mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

In reply to Keke Ming

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/mips/kernel/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/uprobes.c +2 -2
index 401b148f8917..05cfc320992b 100644
@@ -214,11 +214,11 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 	unsigned long kaddr, kstart;
 
 	/* Initialize the slot */
-	kaddr = (unsigned long)kmap_atomic(page);
+	kaddr = (unsigned long)kmap_local_page(page);
 	kstart = kaddr + (vaddr & ~PAGE_MASK);
 	memcpy((void *)kstart, src, len);
 	flush_icache_range(kstart, kstart + len);
-	kunmap_atomic((void *)kaddr);
+	kunmap_local((void *)kaddr);
 }
 
 /**
Signature · 1 line
2.43.0
merge bot Applied
#6 lore raw

[tip: perf/core] mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     e6eb9acc024cdad7d1cbb7693ac39afdf9c5193f
Gitweb:        https://git.kernel.org/tip/e6eb9acc024cdad7d1cbb7693ac39afdf9c5193f
Author:        Keke Ming <[email protected]>
AuthorDate:    Sat, 03 Jan 2026 16:42:41 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 06 Jan 2026 16:34:27 +01:00

mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/mips/kernel/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/uprobes.c +2 -2
index 401b148..05cfc32 100644
@@ -214,11 +214,11 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 	unsigned long kaddr, kstart;
 
 	/* Initialize the slot */
-	kaddr = (unsigned long)kmap_atomic(page);
+	kaddr = (unsigned long)kmap_local_page(page);
 	kstart = kaddr + (vaddr & ~PAGE_MASK);
 	memcpy((void *)kstart, src, len);
 	flush_icache_range(kstart, kstart + len);
-	kunmap_atomic((void *)kaddr);
+	kunmap_local((void *)kaddr);
 }
 
 /**
author
#7 lore raw

PATCH 4/5 arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

In reply to Keke Ming

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/arm/probes/uprobes/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/probes/uprobes/core.c +2 -2
index 3d96fb41d624..0e1c6b9e7e54 100644
@@ -113,7 +113,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm,
 void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 			   void *src, unsigned long len)
 {
-	void *xol_page_kaddr = kmap_atomic(page);
+	void *xol_page_kaddr = kmap_local_page(page);
 	void *dst = xol_page_kaddr + (vaddr & ~PAGE_MASK);
 
 	preempt_disable();
@@ -126,7 +126,7 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 
 	preempt_enable();
 
-	kunmap_atomic(xol_page_kaddr);
+	kunmap_local(xol_page_kaddr);
 }
 
 
Signature · 1 line
2.43.0
merge bot Applied
#8 lore raw

[tip: perf/core] arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     1752a1ad43a1d4fd450a8ef5f8d240f9e228e0a3
Gitweb:        https://git.kernel.org/tip/1752a1ad43a1d4fd450a8ef5f8d240f9e228e0a3
Author:        Keke Ming <[email protected]>
AuthorDate:    Sat, 03 Jan 2026 16:42:42 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 06 Jan 2026 16:34:27 +01:00

arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

Replace deprecated kmap_atomic() with kmap_local_page().

---
 arch/arm/probes/uprobes/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/probes/uprobes/core.c +2 -2
index 3d96fb4..0e1c6b9 100644
@@ -113,7 +113,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm,
 void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 			   void *src, unsigned long len)
 {
-	void *xol_page_kaddr = kmap_atomic(page);
+	void *xol_page_kaddr = kmap_local_page(page);
 	void *dst = xol_page_kaddr + (vaddr & ~PAGE_MASK);
 
 	preempt_disable();
@@ -126,7 +126,7 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
 
 	preempt_enable();
 
-	kunmap_atomic(xol_page_kaddr);
+	kunmap_local(xol_page_kaddr);
 }
 
 
author
#9 lore raw

PATCH 5/5 uprobes: use kmap_local_page() for temporary page mappings

In reply to Keke Ming

Replace deprecated kmap_atomic() with kmap_local_page().

---
 kernel/events/uprobes.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/events/uprobes.c +6 -6
index d546d32390a8..a7d7d83ca1d7 100644
@@ -179,16 +179,16 @@ bool __weak is_trap_insn(uprobe_opcode_t *insn)
 
 void uprobe_copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len)
 {
-	void *kaddr = kmap_atomic(page);
+	void *kaddr = kmap_local_page(page);
 	memcpy(dst, kaddr + (vaddr & ~PAGE_MASK), len);
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 }
 
 static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len)
 {
-	void *kaddr = kmap_atomic(page);
+	void *kaddr = kmap_local_page(page);
 	memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len);
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 }
 
 static int verify_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t *insn,
@@ -323,7 +323,7 @@ __update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d)
 		return ret == 0 ? -EBUSY : ret;
 	}
 
-	kaddr = kmap_atomic(page);
+	kaddr = kmap_local_page(page);
 	ptr = kaddr + (vaddr & ~PAGE_MASK);
 
 	if (unlikely(*ptr + d < 0)) {
@@ -336,7 +336,7 @@ __update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d)
 	*ptr += d;
 	ret = 0;
 out:
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 	put_page(page);
 	return ret;
 }
Signature · 1 line
2.43.0
merge bot Applied
#10 lore raw

[tip: perf/core] uprobes: use kmap_local_page() for temporary page mappings

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     a491c02c2770c9c2d02b96fad7e3a176d77bb737
Gitweb:        https://git.kernel.org/tip/a491c02c2770c9c2d02b96fad7e3a176d77bb737
Author:        Keke Ming <[email protected]>
AuthorDate:    Sat, 03 Jan 2026 16:42:43 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 06 Jan 2026 16:34:28 +01:00

uprobes: use kmap_local_page() for temporary page mappings

Replace deprecated kmap_atomic() with kmap_local_page().

---
 kernel/events/uprobes.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/events/uprobes.c +6 -6
index d546d32..a7d7d83 100644
@@ -179,16 +179,16 @@ bool __weak is_trap_insn(uprobe_opcode_t *insn)
 
 void uprobe_copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len)
 {
-	void *kaddr = kmap_atomic(page);
+	void *kaddr = kmap_local_page(page);
 	memcpy(dst, kaddr + (vaddr & ~PAGE_MASK), len);
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 }
 
 static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len)
 {
-	void *kaddr = kmap_atomic(page);
+	void *kaddr = kmap_local_page(page);
 	memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len);
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 }
 
 static int verify_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t *insn,
@@ -323,7 +323,7 @@ __update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d)
 		return ret == 0 ? -EBUSY : ret;
 	}
 
-	kaddr = kmap_atomic(page);
+	kaddr = kmap_local_page(page);
 	ptr = kaddr + (vaddr & ~PAGE_MASK);
 
 	if (unlikely(*ptr + d < 0)) {
@@ -336,7 +336,7 @@ __update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d)
 	*ptr += d;
 	ret = 0;
 out:
-	kunmap_atomic(kaddr);
+	kunmap_local(kaddr);
 	put_page(page);
 	return ret;
 }
maintainer Acked-by on the v1 series
#11 lore raw
In reply to Keke Ming
Quoted 8 lines · Keke Ming

Keke Ming (5):
riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()
uprobes: use kmap_local_page() for temporary page mappings

Quoted 6 lines
 arch/arm/probes/uprobes/core.c     |  4 ++--
 arch/arm64/kernel/probes/uprobes.c |  4 ++--
 arch/mips/kernel/uprobes.c         |  4 ++--
 arch/riscv/kernel/probes/uprobes.c |  4 ++--
 kernel/events/uprobes.c            | 12 ++++++------
 5 files changed, 14 insertions(+), 14 deletions(-)

Thanks,

maintainer
#12 lore raw
Quoted 16 lines · Oleg Nesterov
Quoted 8 lines · Keke Ming

Keke Ming (5):
riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol() arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()
uprobes: use kmap_local_page() for temporary page mappings

Quoted 6 lines
 arch/arm/probes/uprobes/core.c     |  4 ++--
 arch/arm64/kernel/probes/uprobes.c |  4 ++--
 arch/mips/kernel/uprobes.c         |  4 ++--
 arch/riscv/kernel/probes/uprobes.c |  4 ++--
 kernel/events/uprobes.c            | 12 ++++++------
 5 files changed, 14 insertions(+), 14 deletions(-)
Quoted 3 lines

Thanks,

Let me go stick them in tip/perf/core

#13 lore raw
In reply to Keke Ming
This series was applied to riscv/linux.git (fixes) by Peter Zijlstra <[email protected]>:

Hello:

This series was applied to riscv/linux.git (fixes) by Peter Zijlstra <[email protected]>:

Quoted 10 lines · On Sat, 3 Jan 2026 16:42:38 +0800 you wrote:

The use of kmap_atomic/kunmap_atomic is deprecated. The purpose of kmap-like functions is to create temporary mappings.

kmap_atomic() typically disables preemption, while kmap_local_page() allows preemption.

According to the documentation, kmap_atomic() is primarily necessary for contexts that cannot sleep.

[...]

Here is the summary with links:
- [1/5] riscv/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()

    https://git.kernel.org/riscv/c/a18dfb5dd332
  - [2/5] arm64/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()
    https://git.kernel.org/riscv/c/094cc7bb5fc3
  - [3/5] mips/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()
    https://git.kernel.org/riscv/c/e6eb9acc024c
  - [4/5] arm/uprobes: use kmap_local_page() in arch_uprobe_copy_ixol()
    https://git.kernel.org/riscv/c/1752a1ad43a1
  - [5/5] uprobes: use kmap_local_page() for temporary page mappings
    https://git.kernel.org/riscv/c/a491c02c2770

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html