Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 May 2017 13:16:07 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r319205 - stable/11/sys/arm64/arm64
Message-ID:  <201705301316.v4UDG7FY008417@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Tue May 30 13:16:06 2017
New Revision: 319205
URL: https://svnweb.freebsd.org/changeset/base/319205

Log:
  MFC r317192:
  
  Push loading curthread into assembly in the synchronous exception handlers.
  This will help investigating the performance impact of moving parts of the
  switch statement in do_el0_sync into assembly.

Modified:
  stable/11/sys/arm64/arm64/exception.S
  stable/11/sys/arm64/arm64/genassym.c
  stable/11/sys/arm64/arm64/trap.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm64/arm64/exception.S
==============================================================================
--- stable/11/sys/arm64/arm64/exception.S	Tue May 30 13:02:10 2017	(r319204)
+++ stable/11/sys/arm64/arm64/exception.S	Tue May 30 13:16:06 2017	(r319205)
@@ -143,7 +143,8 @@ __FBSDID("$FreeBSD$");
 
 ENTRY(handle_el1h_sync)
 	save_registers 1
-	mov	x0, sp
+	ldr	x0, [x18, #PC_CURTHREAD]
+	mov	x1, sp
 	bl	do_el1h_sync
 	restore_registers 1
 	eret
@@ -163,7 +164,9 @@ END(handle_el1h_error)
 
 ENTRY(handle_el0_sync)
 	save_registers 0
-	mov	x0, sp
+	ldr	x0, [x18, #PC_CURTHREAD]
+	mov	x1, sp
+	str	x1, [x0, #TD_FRAME]
 	bl	do_el0_sync
 	do_ast
 	restore_registers 0

Modified: stable/11/sys/arm64/arm64/genassym.c
==============================================================================
--- stable/11/sys/arm64/arm64/genassym.c	Tue May 30 13:02:10 2017	(r319204)
+++ stable/11/sys/arm64/arm64/genassym.c	Tue May 30 13:16:06 2017	(r319205)
@@ -57,6 +57,7 @@ ASSYM(SF_UC, offsetof(struct sigframe, sf_uc));
 
 ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
+ASSYM(TD_FRAME, offsetof(struct thread, td_frame));
 ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
 
 ASSYM(TF_SIZE, sizeof(struct trapframe));

Modified: stable/11/sys/arm64/arm64/trap.c
==============================================================================
--- stable/11/sys/arm64/arm64/trap.c	Tue May 30 13:02:10 2017	(r319204)
+++ stable/11/sys/arm64/arm64/trap.c	Tue May 30 13:16:06 2017	(r319205)
@@ -72,8 +72,8 @@ __FBSDID("$FreeBSD$");
 extern register_t fsu_intr_fault;
 
 /* Called from exception.S */
-void do_el1h_sync(struct trapframe *);
-void do_el0_sync(struct trapframe *);
+void do_el1h_sync(struct thread *, struct trapframe *);
+void do_el0_sync(struct thread *, struct trapframe *);
 void do_el0_error(struct trapframe *);
 static void print_registers(struct trapframe *frame);
 
@@ -130,23 +130,20 @@ cpu_fetch_syscall_args(struct thread *td, struct sysca
 #include "../../kern/subr_syscall.c"
 
 static void
-svc_handler(struct trapframe *frame)
+svc_handler(struct thread *td, struct trapframe *frame)
 {
 	struct syscall_args sa;
-	struct thread *td;
 	int error;
 
-	td = curthread;
-
 	error = syscallenter(td, &sa);
 	syscallret(td, error, &sa);
 }
 
 static void
-data_abort(struct trapframe *frame, uint64_t esr, uint64_t far, int lower)
+data_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
+    uint64_t far, int lower)
 {
 	struct vm_map *map;
-	struct thread *td;
 	struct proc *p;
 	struct pcb *pcb;
 	vm_prot_t ftype;
@@ -167,7 +164,6 @@ data_abort(struct trapframe *frame, uint64_t esr, uint
 	}
 #endif
 
-	td = curthread;
 	pcb = td->td_pcb;
 
 	/*
@@ -258,7 +254,7 @@ print_registers(struct trapframe *frame)
 }
 
 void
-do_el1h_sync(struct trapframe *frame)
+do_el1h_sync(struct thread *td, struct trapframe *frame)
 {
 	uint32_t exception;
 	uint64_t esr, far;
@@ -273,8 +269,8 @@ do_el1h_sync(struct trapframe *frame)
 #endif
 
 	CTR4(KTR_TRAP,
-	    "do_el1_sync: curthread: %p, esr %lx, elr: %lx, frame: %p",
-	    curthread, esr, frame->tf_elr, frame);
+	    "do_el1_sync: curthread: %p, esr %lx, elr: %lx, frame: %p", td,
+	    esr, frame->tf_elr, frame);
 
 	switch(exception) {
 	case EXCP_FP_SIMD:
@@ -286,7 +282,7 @@ do_el1h_sync(struct trapframe *frame)
 	case EXCP_DATA_ABORT:
 		far = READ_SPECIALREG(far_el1);
 		intr_enable();
-		data_abort(frame, esr, far, 0);
+		data_abort(td, frame, esr, far, 0);
 		break;
 	case EXCP_BRK:
 #ifdef KDTRACE_HOOKS
@@ -327,9 +323,8 @@ el0_excp_unknown(struct trapframe *frame, uint64_t far
 }
 
 void
-do_el0_sync(struct trapframe *frame)
+do_el0_sync(struct thread *td, struct trapframe *frame)
 {
-	struct thread *td;
 	uint32_t exception;
 	uint64_t esr, far;
 
@@ -338,9 +333,6 @@ do_el0_sync(struct trapframe *frame)
 	    ("Invalid pcpu address from userland: %p (tpidr %lx)",
 	     get_pcpu(), READ_SPECIALREG(tpidr_el1)));
 
-	td = curthread;
-	td->td_frame = frame;
-
 	esr = frame->tf_esr;
 	exception = ESR_ELx_EXCEPTION(esr);
 	switch (exception) {
@@ -353,8 +345,8 @@ do_el0_sync(struct trapframe *frame)
 	intr_enable();
 
 	CTR4(KTR_TRAP,
-	    "do_el0_sync: curthread: %p, esr %lx, elr: %lx, frame: %p",
-	    curthread, esr, frame->tf_elr, frame);
+	    "do_el0_sync: curthread: %p, esr %lx, elr: %lx, frame: %p", td, esr,
+	    frame->tf_elr, frame);
 
 	switch(exception) {
 	case EXCP_FP_SIMD:
@@ -366,12 +358,12 @@ do_el0_sync(struct trapframe *frame)
 #endif
 		break;
 	case EXCP_SVC:
-		svc_handler(frame);
+		svc_handler(td, frame);
 		break;
 	case EXCP_INSN_ABORT_L:
 	case EXCP_DATA_ABORT_L:
 	case EXCP_DATA_ABORT:
-		data_abort(frame, esr, far, 1);
+		data_abort(td, frame, esr, far, 1);
 		break;
 	case EXCP_UNKNOWN:
 		el0_excp_unknown(frame, far);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705301316.v4UDG7FY008417>