Skip to contentSkip to conversation

arm64: ftrace: eliminate literal pool entries

PATCH New Ard Biesheuvel 4 participants 5 messages Nov 7, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 arm64: ftrace: eliminate literal pool entries

Replace ldr xN, =<symbol> with adrp/add or adrp/ldr [as appropriate] in the implementation of _mcount(), which may be called very often.

---
 arch/arm64/kernel/entry-ftrace.S | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
arch/arm64/kernel/entry-ftrace.S +11 -10
index 38e704e597f7..08cafc518b9a 100644
@@ -98,8 +98,8 @@
 ENTRY(_mcount)
 	mcount_enter
 
-	ldr	x0, =ftrace_trace_function
-	ldr	x2, [x0]
+	adrp	x0, ftrace_trace_function
+	ldr	x2, [x0, #:lo12:ftrace_trace_function]
 	adr	x0, ftrace_stub
 	cmp	x0, x2			// if (ftrace_trace_function
 	b.eq	skip_ftrace_call	//     != ftrace_stub) {
@@ -115,14 +115,15 @@ skip_ftrace_call:			//   return;
 	mcount_exit			//   return;
 					// }
 skip_ftrace_call:
-	ldr	x1, =ftrace_graph_return
-	ldr	x2, [x1]		//   if ((ftrace_graph_return
-	cmp	x0, x2			//        != ftrace_stub)
-	b.ne	ftrace_graph_caller
-
-	ldr	x1, =ftrace_graph_entry	//     || (ftrace_graph_entry
-	ldr	x2, [x1]		//        != ftrace_graph_entry_stub))
-	ldr	x0, =ftrace_graph_entry_stub
+	adrp	x1, ftrace_graph_return
+	ldr	x2, [x1, #:lo12:ftrace_graph_return]
+	cmp	x0, x2			//   if ((ftrace_graph_return
+	b.ne	ftrace_graph_caller	//        != ftrace_stub)
+
+	adrp	x1, ftrace_graph_entry	//     || (ftrace_graph_entry
+	adrp	x0, ftrace_graph_entry_stub //     != ftrace_graph_entry_stub))
+	ldr	x2, [x1, #:lo12:ftrace_graph_entry]
+	add	x0, x0, #:lo12:ftrace_graph_entry_stub
 	cmp	x0, x2
 	b.ne	ftrace_graph_caller	//     ftrace_graph_caller();
 
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 2/2 arm64: kvm: eliminate literal pool entries

Replace two instances of 'ldr xN, =(constant)' in the world switch hot path with 'mov' instructions.

---
 arch/arm64/kvm/hyp.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp.S +2 -2
index b72aa9f9215c..fbe909fb0a1a 100644
@@ -761,10 +761,10 @@
 .macro activate_traps
 	ldr     x2, [x0, #VCPU_HCR_EL2]
 	msr     hcr_el2, x2
-	ldr	x2, =(CPTR_EL2_TTA)
+	mov	x2, #CPTR_EL2_TTA
 	msr	cptr_el2, x2
 
-	ldr	x2, =(1 << 15)	// Trap CP15 Cr=15
+	mov	x2, #(1 << 15)	// Trap CP15 Cr=15
 	msr	hstr_el2, x2
 
 	mrs	x2, mdcr_el2
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 2/2 arm64: kvm: eliminate literal pool entries

Quoted 16 lines · Ard Biesheuvel

Replace two instances of 'ldr xN, =(constant)' in the world switch hot path with 'mov' instructions.

---
 arch/arm64/kvm/hyp.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp.S +0 -0
index b72aa9f9215c..fbe909fb0a1a 100644
@@ -761,10 +761,10 @@
 .macro activate_traps
 	ldr     x2, [x0, #VCPU_HCR_EL2]

arch/arm64/kvm/hyp.S line 770

Quoted 10 lines
arch/arm64/kvm/hyp.S +2 -2
 	msr     hcr_el2, x2
-	ldr	x2, =(CPTR_EL2_TTA)
+	mov	x2, #CPTR_EL2_TTA
 	msr	cptr_el2, x2
 
-	ldr	x2, =(1 << 15)	// Trap CP15 Cr=15
+	mov	x2, #(1 << 15)	// Trap CP15 Cr=15
 	msr	hstr_el2, x2
 
 	mrs	x2, mdcr_el2

Looks good to me.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#3 lore raw

PATCH 2/2 arm64: kvm: eliminate literal pool entries

Quoted 25 lines · Marc Zyngier
Quoted 24 lines · Ard Biesheuvel

Replace two instances of 'ldr xN, =(constant)' in the world switch hot path with 'mov' instructions.

---
 arch/arm64/kvm/hyp.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp.S +2 -2
index b72aa9f9215c..fbe909fb0a1a 100644
@@ -761,10 +761,10 @@
 .macro activate_traps
 	ldr     x2, [x0, #VCPU_HCR_EL2]
 	msr     hcr_el2, x2
-	ldr	x2, =(CPTR_EL2_TTA)
+	mov	x2, #CPTR_EL2_TTA
 	msr	cptr_el2, x2
 
-	ldr	x2, =(1 << 15)	// Trap CP15 Cr=15
+	mov	x2, #(1 << 15)	// Trap CP15 Cr=15
 	msr	hstr_el2, x2
 
Quoted 7 lines

arch/arm64/kvm/hyp.S line 770

Quoted 2 lines
arch/arm64/kvm/hyp.S +0 -0
 	mrs	x2, mdcr_el2

Looks good to me.

Yup, me too:

#4 lore raw

PATCH 2/2 arm64: kvm: eliminate literal pool entries

Quoted 31 lines · Christoffer Dall
Quoted 30 lines · Marc Zyngier
Quoted 16 lines · Ard Biesheuvel

Replace two instances of 'ldr xN, =(constant)' in the world switch hot path with 'mov' instructions.

---
 arch/arm64/kvm/hyp.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp.S +0 -0
index b72aa9f9215c..fbe909fb0a1a 100644
@@ -761,10 +761,10 @@
 .macro activate_traps
 	ldr     x2, [x0, #VCPU_HCR_EL2]

arch/arm64/kvm/hyp.S line 770

Quoted 10 lines
arch/arm64/kvm/hyp.S +2 -2
 	msr     hcr_el2, x2
-	ldr	x2, =(CPTR_EL2_TTA)
+	mov	x2, #CPTR_EL2_TTA
 	msr	cptr_el2, x2
 
-	ldr	x2, =(1 << 15)	// Trap CP15 Cr=15
+	mov	x2, #(1 << 15)	// Trap CP15 Cr=15
 	msr	hstr_el2, x2
 
 	mrs	x2, mdcr_el2

Looks good to me.

Quoted 5 lines
Quoted 2 lines

Yup, me too:

Cheers guys, I've applied both patches to the arm64 tree for 3.19.

Will