summaryrefslogtreecommitdiff
path: root/kern/sleepq.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/sleepq.c')
-rw-r--r--kern/sleepq.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/kern/sleepq.c b/kern/sleepq.c
index 5af3d064..44ad9962 100644
--- a/kern/sleepq.c
+++ b/kern/sleepq.c
@@ -18,24 +18,25 @@
* TODO Analyse hash parameters.
*/
+#include <assert.h>
+#include <stdalign.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <kern/assert.h>
#include <kern/init.h>
#include <kern/kmem.h>
#include <kern/list.h>
#include <kern/macros.h>
-#include <kern/param.h>
#include <kern/sleepq.h>
#include <kern/spinlock.h>
#include <kern/thread.h>
+#include <machine/cpu.h>
struct sleepq_bucket {
- struct spinlock lock;
+ alignas(CPU_L1_SIZE) struct spinlock lock;
struct list list;
-} __aligned(CPU_L1_SIZE);
+};
struct sleepq {
struct sleepq_bucket *bucket;
@@ -192,7 +193,7 @@ sleepq_ctor(void *ptr)
sleepq->next_free = NULL;
}
-void __init
+static int __init
sleepq_bootstrap(void)
{
unsigned int i;
@@ -204,15 +205,24 @@ sleepq_bootstrap(void)
for (i = 0; i < ARRAY_SIZE(sleepq_cond_htable); i++) {
sleepq_bucket_init(&sleepq_cond_htable[i]);
}
+
+ return 0;
}
-void __init
+INIT_OP_DEFINE(sleepq_bootstrap);
+
+static int __init
sleepq_setup(void)
{
kmem_cache_init(&sleepq_cache, "sleepq", sizeof(struct sleepq),
CPU_L1_SIZE, sleepq_ctor, 0);
+ return 0;
}
+INIT_OP_DEFINE(sleepq_setup,
+ INIT_OP_DEP(kmem_setup, true),
+ INIT_OP_DEP(sleepq_bootstrap, true));
+
struct sleepq *
sleepq_create(void)
{