Module Name: src Committed By: ad Date: Mon Dec 16 19:43:36 UTC 2019
Modified Files: src/sys/kern: kern_sleepq.c src/sys/sys: sleepq.h Log Message: As with turnstiles, don't bother allocating sleepq locks with mutex_obj_alloc(), and avoid the indirect reference. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/kern/kern_sleepq.c cvs rdiff -u -r1.26 -r1.27 src/sys/sys/sleepq.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_sleepq.c diff -u src/sys/kern/kern_sleepq.c:1.54 src/sys/kern/kern_sleepq.c:1.55 --- src/sys/kern/kern_sleepq.c:1.54 Fri Dec 6 21:36:10 2019 +++ src/sys/kern/kern_sleepq.c Mon Dec 16 19:43:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sleepq.c,v 1.54 2019/12/06 21:36:10 ad Exp $ */ +/* $NetBSD: kern_sleepq.c,v 1.55 2019/12/16 19:43:36 ad Exp $ */ /*- * Copyright (c) 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.54 2019/12/06 21:36:10 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.55 2019/12/16 19:43:36 ad Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -66,7 +66,7 @@ static int sleepq_sigtoerror(lwp_t *, in /* General purpose sleep table, used by mtsleep() and condition variables. */ sleeptab_t sleeptab __cacheline_aligned; -kmutex_t *sleepq_locks[SLEEPTAB_HASH_SIZE] __read_mostly; +sleepqlock_t sleepq_locks[SLEEPTAB_HASH_SIZE] __cacheline_aligned; /* * sleeptab_init: @@ -79,7 +79,7 @@ sleeptab_init(sleeptab_t *st) int i; for (i = 0; i < SLEEPTAB_HASH_SIZE; i++) { - sleepq_locks[i] = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED); + mutex_init(&sleepq_locks[i].lock, MUTEX_DEFAULT, IPL_SCHED); sleepq_init(&st->st_queue[i]); } } Index: src/sys/sys/sleepq.h diff -u src/sys/sys/sleepq.h:1.26 src/sys/sys/sleepq.h:1.27 --- src/sys/sys/sleepq.h:1.26 Thu Nov 21 18:56:55 2019 +++ src/sys/sys/sleepq.h Mon Dec 16 19:43:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sleepq.h,v 1.26 2019/11/21 18:56:55 ad Exp $ */ +/* $NetBSD: sleepq.h,v 1.27 2019/12/16 19:43:36 ad Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -38,6 +38,7 @@ #include <sys/queue.h> #include <sys/sched.h> #include <sys/syncobj.h> +#include <sys/param.h> /* * Generic sleep queues. @@ -72,6 +73,11 @@ void sleeptab_init(sleeptab_t *); extern sleeptab_t sleeptab; #ifdef _KERNEL +typedef union { + kmutex_t lock; + uint8_t pad[COHERENCY_UNIT]; +} sleepqlock_t; + /* * Return non-zero if it is unsafe to sleep. * @@ -92,13 +98,13 @@ sleepq_dontsleep(lwp_t *l) static __inline sleepq_t * sleeptab_lookup(sleeptab_t *st, wchan_t wchan, kmutex_t **mp) { - extern kmutex_t *sleepq_locks[SLEEPTAB_HASH_SIZE]; + extern sleepqlock_t sleepq_locks[SLEEPTAB_HASH_SIZE]; sleepq_t *sq; u_int hash; hash = SLEEPTAB_HASH(wchan); sq = &st->st_queue[hash]; - *mp = sleepq_locks[hash]; + *mp = &sleepq_locks[hash].lock; mutex_spin_enter(*mp); return sq; } @@ -106,10 +112,10 @@ sleeptab_lookup(sleeptab_t *st, wchan_t static __inline kmutex_t * sleepq_hashlock(wchan_t wchan) { - extern kmutex_t *sleepq_locks[SLEEPTAB_HASH_SIZE]; + extern sleepqlock_t sleepq_locks[SLEEPTAB_HASH_SIZE]; kmutex_t *mp; - mp = sleepq_locks[SLEEPTAB_HASH(wchan)]; + mp = &sleepq_locks[SLEEPTAB_HASH(wchan)].lock; mutex_spin_enter(mp); return mp; }