git: 24ac1bd8ec3d - stable/13 - arm64: optimize set_syscall_retval()

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Thu, 17 Feb 2022 13:46:19 UTC
The branch stable/13 has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=24ac1bd8ec3d20fdfa8e8b81d4a349554959ef35

commit 24ac1bd8ec3d20fdfa8e8b81d4a349554959ef35
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-02-08 10:46:29 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 23:17:34 +0000

    arm64: optimize set_syscall_retval()
    
    Microoptimize set_syscall_retval() for arm64 by predicting
    the return value to be zero.  This is similar to what has
    been done for other architectures
    
    Reviewed By:    emaste, mhorne
    Differential Revision: https://reviews.freebsd.org/D26991
    
    (cherry picked from commit fb8c2f743ab695f6004650b58bf96972e2535b20)
---
 sys/arm64/arm64/vm_machdep.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c
index 9c97a2848200..a5451c631336 100644
--- a/sys/arm64/arm64/vm_machdep.c
+++ b/sys/arm64/arm64/vm_machdep.c
@@ -150,12 +150,14 @@ cpu_set_syscall_retval(struct thread *td, int error)
 
 	frame = td->td_frame;
 
-	switch (error) {
-	case 0:
+	if (__predict_true(error == 0)) {
 		frame->tf_x[0] = td->td_retval[0];
 		frame->tf_x[1] = td->td_retval[1];
 		frame->tf_spsr &= ~PSR_C;	/* carry bit */
-		break;
+		return;
+	}
+
+	switch (error) {
 	case ERESTART:
 		frame->tf_elr -= 4;
 		break;