Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha/alpha It's unlikely that a process will be us...



details:   https://anonhg.NetBSD.org/src/rev/23d028e7b96a
branches:  trunk
changeset: 1022498:23d028e7b96a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 22 15:48:40 2021 +0000

description:
It's unlikely that a process will be using restartable atomic sequences
on Alpha, and furthermore it's unlikely that any given context switch
will be returning to one even if the process has them.  So, re-arrange
the RAS processing in cpu_switchto() so that the most likely code paths
are predicted by the branch predictor.  On an EV4-class processor, this
will save ~4-6 cycles on just about every context switch.

diffstat:

 sys/arch/alpha/alpha/locore.s |  23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diffs (51 lines):

diff -r 051c1413ee4d -r 23d028e7b96a sys/arch/alpha/alpha/locore.s
--- a/sys/arch/alpha/alpha/locore.s     Thu Jul 22 13:54:38 2021 +0000
+++ b/sys/arch/alpha/alpha/locore.s     Thu Jul 22 15:48:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.140 2021/07/11 01:55:51 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.141 2021/07/22 15:48:40 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <machine/asm.h>
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.140 2021/07/11 01:55:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.141 2021/07/22 15:48:40 thorpej Exp $");
 
 #include "assym.h"
 
@@ -844,14 +844,7 @@
         */
        ldq     a0, L_PROC(s2)                  /* first ras_lookup() arg */
        ldq     t0, P_RASLIST(a0)               /* any RAS entries? */
-       beq     t0, 2f                          /* no, skip */
-       ldq     s1, L_MD_TF(s2)                 /* s1 = l->l_md.md_tf */
-       ldq     a1, (FRAME_PC*8)(s1)            /* second ras_lookup() arg */
-       CALL(ras_lookup)                        /* ras_lookup(p, PC) */
-       addq    v0, 1, t0                       /* -1 means "not in ras" */
-       beq     t0, 2f
-       stq     v0, (FRAME_PC*8)(s1)
-
+       bne     t0, 4f                          /* yes, go deal with it */
 2:
        mov     s4, v0                          /* return the old lwp */
        /*
@@ -883,6 +876,16 @@
        stq     sp, PCB_HWPCB_KSP(a3)           /* save old SP */
        ldq     sp, PCB_HWPCB_KSP(a2)           /* restore new SP */
        br      1b                              /* finish up */
+
+4:
+       ldq     s1, L_MD_TF(s2)                 /* s1 = l->l_md.md_tf */
+       ldq     a1, (FRAME_PC*8)(s1)            /* second ras_lookup() arg */
+       CALL(ras_lookup)                        /* ras_lookup(p, PC) */
+       addq    v0, 1, t0                       /* -1 means "not in ras" */
+       beq     t0, 2b                          /* not in ras? return */
+       stq     v0, (FRAME_PC*8)(s1)            /* in ras? fix up PC */
+       br      2b                              /* finish up */
+
        END(cpu_switchto)
 
 /*



Home | Main Index | Thread Index | Old Index