From 549c7d116fe06cad3a39b38d187daf87ddd22ac7 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 19 May 2024 09:20:18 -0400 Subject: 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 --- sys/kern/kern_sched.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sys') 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}; /* -- cgit v1.2.3