aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-19 09:20:18 -0400
committerIan Moffett <ian@osmora.org>2024-05-19 09:33:12 -0400
commit549c7d116fe06cad3a39b38d187daf87ddd22ac7 (patch)
tree497d78b4d637a7827303a6e6e37aea56eb30a7cb
parented31f8283ca62f550da28456bc190250d6495815 (diff)
kernel: sched: Align 'tdq_lock' on cache line size
The lock should be aligned on a cache line boundary so it isn't in a cache line with other data. This is important for 'tdq_lock' as it is used by every processor which constantly acquires and releases it. This alignment can reduce how violently cache lines bounce between processor local caches. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/kern/kern_sched.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 0aebf5b..b7e6af5 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -58,7 +58,13 @@ static size_t nthread = 0;
/*
* Thread queue lock - all operations to `td_queue'
* must be done with this lock acquired.
+ *
+ * This lock is aligned on a cache line boundary to ensure
+ * it has its own cacheline to reduce contention. This is
+ * because it is constantly acquired and released on every
+ * processor.
*/
+__cacheline_aligned
static struct spinlock tdq_lock = {0};
/*