summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-19 17:16:38 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-19 17:32:05 +0100
commit5ce1cc89a0da5596b4bb2f39568a1511fda36cda (patch)
treee900397f8787d070eaf9e235126487e83818a11b
parent8d9dd1b04bb628ce7a1de838740da9b79c91d760 (diff)
downloadserenity-5ce1cc89a0da5596b4bb2f39568a1511fda36cda.zip
Kernel: Add fast-path for sys$gettid()
The userspace locks are very aggressively calling sys$gettid() to find out which thread ID they have. Since syscalls are quite heavy, this can get very expensive for some programs. This patch adds a fast-path for sys$gettid(), which makes it skip all of the usual syscall validation and just return the thread ID right away. This cuts Kernel/Process.cpp compile time by ~18%, from ~29 to ~24 sec.
-rw-r--r--Kernel/Syscall.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index a0e73b9620..a0d297e96e 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -119,6 +119,14 @@ int handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
void syscall_handler(RegisterDump regs)
{
+ // Special handling of the "gettid" syscall since it's extremely hot.
+ // FIXME: Remove this hack once userspace locks stop calling it so damn much.
+ if (regs.eax == SC_gettid) {
+ regs.eax = current->process().sys$gettid();
+ current->did_syscall();
+ return;
+ }
+
// Make sure SMAP protection is enabled on syscall entry.
clac();