summaryrefslogtreecommitdiff
path: root/src/sys/include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-09-17 03:10:28 -0400
committerIan Moffett <ian@osmora.org>2025-09-17 03:12:58 -0400
commit61aaead7e2904a2756ed72a71e36eeeb21591733 (patch)
tree6fc83ac548c715c1f5782ea31e4253fc5f6e2303 /src/sys/include
parentdf9eb8790b8e49c63beaef93c3194f1b0ed48f4d (diff)
kern/amd64: cpu: Add process load balancing
This commit introduces load balancing of processes between cores by using a scalable "CPU arbiter" which decides how to fetch the next core descriptor. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include')
-rw-r--r--src/sys/include/sys/cpuvar.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/sys/include/sys/cpuvar.h b/src/sys/include/sys/cpuvar.h
index a41131b..e4f3cd1 100644
--- a/src/sys/include/sys/cpuvar.h
+++ b/src/sys/include/sys/cpuvar.h
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/proc.h>
+#include <sys/param.h>
#if defined(_KERNEL)
#include <os/sched.h>
#include <machine/mdcpu.h>
@@ -60,6 +61,35 @@ struct pcore {
};
#if defined(_KERNEL)
+
+typedef enum {
+ CORE_ARBITER_RR, /* Round robin */
+} arbiter_type_t;
+
+/*
+ * The processor core arbiter assists in scheduling
+ * processor cores to be used for execution.
+ *
+ * @rr_id: Round robin ID; next processor to be scheduled
+ * @type: Arbitration policy (CORE_ARBITER_RR is default)
+ * @lock: Protects the ID
+ */
+struct core_arbiter {
+ size_t rr_id;
+ arbiter_type_t type;
+ struct spinlock lock;
+} __aligned(COHERENCY_UNIT);
+
+/*
+ * Return a pointer to the next processor that
+ * is ready for queues to be assigned to them
+ *
+ * [MI]
+ *
+ * Returns NULL on failure
+ */
+struct pcore *cpu_sched(void);
+
/*
* Configure a processor core on the system
*