From feb3717e5070bfb8489990a2ff13aa599789b4bd Mon Sep 17 00:00:00 2001 From: "Luca(Wei) Chen" Date: Mon, 10 Feb 2020 10:51:01 +1100 Subject: [PATCH] fastpath: fix branch predications All jump instructions to slowpath are unlikely executed in fastpath, and this prevents polluting i-cache by pushing it away. --- src/fastpath/fastpath.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/fastpath/fastpath.c b/src/fastpath/fastpath.c index f43da65e0..3b4ed7f7a 100644 --- a/src/fastpath/fastpath.c +++ b/src/fastpath/fastpath.c @@ -72,7 +72,7 @@ fastpath_call(word_t cptr, word_t msgInfo) /* ensure we are not single stepping the destination in ia32 */ #if defined(CONFIG_HARDWARE_DEBUG_API) && defined(CONFIG_ARCH_IA32) - if (dest->tcbArch.tcbContext.breakpointState.single_step_enabled) { + if (unlikely(dest->tcbArch.tcbContext.breakpointState.single_step_enabled)) { slowpath(SysCall); } #endif @@ -114,8 +114,7 @@ fastpath_call(word_t cptr, word_t msgInfo) /* let gcc optimise this out for 1 domain */ dom = maxDom ? ksCurDomain : 0; /* ensure only the idle thread or lower prio threads are present in the scheduler */ - if (likely(dest->tcbPriority < NODE_STATE(ksCurThread->tcbPriority)) && - !isHighestPrio(dom, dest->tcbPriority)) { + if (unlikely(dest->tcbPriority < NODE_STATE(ksCurThread->tcbPriority)) && !isHighestPrio(dom, dest->tcbPriority)) { slowpath(SysCall); } @@ -276,8 +275,8 @@ void fastpath_reply_recv(word_t cptr, word_t msgInfo) #endif /* Check there is nothing waiting on the notification */ - if (NODE_STATE(ksCurThread)->tcbBoundNotification && - notification_ptr_get_state(NODE_STATE(ksCurThread)->tcbBoundNotification) == NtfnState_Active) { + if (unlikely(NODE_STATE(ksCurThread)->tcbBoundNotification && + notification_ptr_get_state(NODE_STATE(ksCurThread)->tcbBoundNotification) == NtfnState_Active)) { slowpath(SysReplyRecv); } @@ -314,7 +313,7 @@ void fastpath_reply_recv(word_t cptr, word_t msgInfo) /* ensure we are not single stepping the caller in ia32 */ #if defined(CONFIG_HARDWARE_DEBUG_API) && defined(CONFIG_ARCH_IA32) - if (caller->tcbArch.tcbContext.breakpointState.single_step_enabled) { + if (unlikely(caller->tcbArch.tcbContext.breakpointState.single_step_enabled)) { slowpath(SysReplyRecv); } #endif