summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2008-03-27 18:30:15 +0000
committerad <ad@NetBSD.org>2008-03-27 18:30:15 +0000
commitfeb4783fdf430e68e8769f3316ffda5ffc70e208 (patch)
tree12192b78f48a0a906f2cf9a902b3cd5e5fe8367e /sys
parent0f33676c6c2ea51b5269eb51c45119ebf42142a9 (diff)
Replace use of CACHE_LINE_SIZE in some obvious places.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_auth.c10
-rw-r--r--sys/kern/kern_descrip.c12
-rw-r--r--sys/kern/sched_m2.c10
-rw-r--r--sys/kern/subr_lockdebug.c8
-rw-r--r--sys/kern/subr_pool.c14
-rw-r--r--sys/kern/subr_workqueue.c18
-rw-r--r--sys/kern/sys_mqueue.c6
-rw-r--r--sys/kern/sys_pipe.c11
-rw-r--r--sys/kern/sys_select.c10
9 files changed, 45 insertions, 54 deletions
diff --git a/sys/kern/kern_auth.c b/sys/kern/kern_auth.c
index d3f3c504c1b..672c6c41053 100644
--- a/sys/kern/kern_auth.c
+++ b/sys/kern/kern_auth.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_auth.c,v 1.57 2008/02/14 15:01:45 ad Exp $ */
+/* $NetBSD: kern_auth.c,v 1.58 2008/03/27 18:30:15 ad Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.57 2008/02/14 15:01:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.58 2008/03/27 18:30:15 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -100,7 +100,9 @@ struct kauth_cred {
* sharing between CPUs.
*/
u_int cr_refcnt; /* reference count */
- uint8_t cr_pad[CACHE_LINE_SIZE - sizeof(u_int)];
+#if COHERENCY_UNIT > 4
+ uint8_t cr_pad[COHERENCY_UNIT - 4];
+#endif
uid_t cr_uid; /* user id */
uid_t cr_euid; /* effective user id */
uid_t cr_svuid; /* saved effective user id */
@@ -803,7 +805,7 @@ kauth_init(void)
rw_init(&kauth_lock);
kauth_cred_cache = pool_cache_init(sizeof(struct kauth_cred),
- CACHE_LINE_SIZE, 0, 0, "kcredpl", NULL, IPL_NONE,
+ coherency_unit, 0, 0, "kcredpl", NULL, IPL_NONE,
NULL, NULL, NULL);
/* Create specificdata domain. */
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 9e835fa55fd..d32b94863ed 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_descrip.c,v 1.173 2008/03/21 21:53:35 ad Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.174 2008/03/27 18:33:39 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.173 2008/03/21 21:53:35 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.174 2008/03/27 18:33:39 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -140,20 +140,20 @@ fd_sys_init(void)
mutex_init(&filelist_lock, MUTEX_DEFAULT, IPL_NONE);
- file_cache = pool_cache_init(sizeof(file_t), CACHE_LINE_SIZE, 0,
+ file_cache = pool_cache_init(sizeof(file_t), coherency_unit, 0,
0, "file", NULL, IPL_NONE, file_ctor, file_dtor, NULL);
KASSERT(file_cache != NULL);
- fdfile_cache = pool_cache_init(sizeof(fdfile_t), CACHE_LINE_SIZE, 0,
+ fdfile_cache = pool_cache_init(sizeof(fdfile_t), coherency_unit, 0,
PR_LARGECACHE, "fdfile", NULL, IPL_NONE, fdfile_ctor, fdfile_dtor,
NULL);
KASSERT(fdfile_cache != NULL);
- cwdi_cache = pool_cache_init(sizeof(struct cwdinfo), CACHE_LINE_SIZE,
+ cwdi_cache = pool_cache_init(sizeof(struct cwdinfo), coherency_unit,
0, 0, "cwdi", NULL, IPL_NONE, cwdi_ctor, cwdi_dtor, NULL);
KASSERT(cwdi_cache != NULL);
- filedesc_cache = pool_cache_init(sizeof(filedesc_t), CACHE_LINE_SIZE,
+ filedesc_cache = pool_cache_init(sizeof(filedesc_t), coherency_unit,
0, 0, "filedesc", NULL, IPL_NONE, filedesc_ctor, filedesc_dtor,
NULL);
KASSERT(filedesc_cache != NULL);
diff --git a/sys/kern/sched_m2.c b/sys/kern/sched_m2.c
index bcfd728b51a..601534d7be2 100644
--- a/sys/kern/sched_m2.c
+++ b/sys/kern/sched_m2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sched_m2.c,v 1.22 2008/03/11 18:18:49 rmind Exp $ */
+/* $NetBSD: sched_m2.c,v 1.23 2008/03/27 18:30:15 ad Exp $ */
/*
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sched_m2.c,v 1.22 2008/03/11 18:18:49 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_m2.c,v 1.23 2008/03/27 18:30:15 ad Exp $");
#include <sys/param.h>
@@ -176,7 +176,7 @@ sched_rqinit(void)
#endif
/* Pool of the scheduler-specific structures */
- sil_pool = pool_cache_init(sizeof(sched_info_lwp_t), CACHE_LINE_SIZE,
+ sil_pool = pool_cache_init(sizeof(sched_info_lwp_t), coherency_unit,
0, 0, "lwpsd", NULL, IPL_NONE, NULL, NULL, NULL);
/* Attach the primary CPU here */
@@ -219,12 +219,12 @@ sched_cpuattach(struct cpu_info *ci)
}
/* Allocate the run queue */
- size = roundup2(sizeof(runqueue_t), CACHE_LINE_SIZE) + CACHE_LINE_SIZE;
+ size = roundup2(sizeof(runqueue_t), coherency_unit) + coherency_unit;
rq_ptr = kmem_zalloc(size, KM_SLEEP);
if (rq_ptr == NULL) {
panic("sched_cpuattach: could not allocate the runqueue");
}
- ci_rq = (void *)(roundup2((uintptr_t)(rq_ptr), CACHE_LINE_SIZE));
+ ci_rq = (void *)(roundup2((uintptr_t)(rq_ptr), coherency_unit));
/* Initialize run queues */
KASSERT(sizeof(kmutex_t) <= CACHE_LINE_SIZE);
diff --git a/sys/kern/subr_lockdebug.c b/sys/kern/subr_lockdebug.c
index 62cb3cdcb93..6d99cf08d30 100644
--- a/sys/kern/subr_lockdebug.c
+++ b/sys/kern/subr_lockdebug.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_lockdebug.c,v 1.28 2008/02/18 18:31:10 ad Exp $ */
+/* $NetBSD: subr_lockdebug.c,v 1.29 2008/03/27 18:30:15 ad Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.28 2008/02/18 18:31:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.29 2008/03/27 18:30:15 ad Exp $");
#include "opt_ddb.h"
@@ -80,8 +80,8 @@ typedef union lockdebuglk {
u_int lku_lock;
int lku_oldspl;
} ul;
- uint8_t lk_pad[CACHE_LINE_SIZE];
-} volatile __aligned(CACHE_LINE_SIZE) lockdebuglk_t;
+ uint8_t lk_pad[COHERENCY_UNIT];
+} volatile __aligned(COHERENCY_UNIT) lockdebuglk_t;
#define lk_lock ul.lku_lock
#define lk_oldspl ul.lku_oldspl
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index bf1b4bbd480..48ce957a35c 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pool.c,v 1.155 2008/03/17 17:05:54 ad Exp $ */
+/* $NetBSD: subr_pool.c,v 1.156 2008/03/27 18:30:15 ad Exp $ */
/*-
* Copyright (c) 1997, 1999, 2000, 2002, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.155 2008/03/17 17:05:54 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.156 2008/03/27 18:30:15 ad Exp $");
#include "opt_ddb.h"
#include "opt_pool.h"
@@ -612,10 +612,10 @@ pool_subsystem_init(void)
pa_reclaim_register(pa);
}
- pool_init(&cache_pool, sizeof(struct pool_cache), CACHE_LINE_SIZE,
+ pool_init(&cache_pool, sizeof(struct pool_cache), coherency_unit,
0, 0, "pcache", &pool_allocator_nointr, IPL_NONE);
- pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), CACHE_LINE_SIZE,
+ pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), coherency_unit,
0, 0, "pcachecpu", &pool_allocator_nointr, IPL_NONE);
}
@@ -855,12 +855,12 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
size = sizeof(pcg_t) +
(PCG_NOBJECTS_NORMAL - 1) * sizeof(pcgpair_t);
- pool_init(&pcg_normal_pool, size, CACHE_LINE_SIZE, 0, 0,
+ pool_init(&pcg_normal_pool, size, coherency_unit, 0, 0,
"pcgnormal", &pool_allocator_meta, IPL_VM);
size = sizeof(pcg_t) +
(PCG_NOBJECTS_LARGE - 1) * sizeof(pcgpair_t);
- pool_init(&pcg_large_pool, size, CACHE_LINE_SIZE, 0, 0,
+ pool_init(&pcg_large_pool, size, coherency_unit, 0, 0,
"pcglarge", &pool_allocator_meta, IPL_VM);
}
@@ -2206,7 +2206,6 @@ pool_cache_cpu_init1(struct cpu_info *ci, pool_cache_t pc)
index = ci->ci_index;
KASSERT(index < MAXCPUS);
- KASSERT(((uintptr_t)pc->pc_cpus & (CACHE_LINE_SIZE - 1)) == 0);
if ((cc = pc->pc_cpus[index]) != NULL) {
KASSERT(cc->cc_cpuindex == index);
@@ -2399,7 +2398,6 @@ pool_cache_cpu_enter(pool_cache_t pc, int *s)
if (cc->cc_ipl != IPL_NONE) {
*s = splraiseipl(cc->cc_iplcookie);
}
- KASSERT(((uintptr_t)cc & (CACHE_LINE_SIZE - 1)) == 0);
return cc;
}
diff --git a/sys/kern/subr_workqueue.c b/sys/kern/subr_workqueue.c
index 8c5cda97ee9..c31079c4fbb 100644
--- a/sys/kern/subr_workqueue.c
+++ b/sys/kern/subr_workqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_workqueue.c,v 1.23 2008/03/10 22:20:14 martin Exp $ */
+/* $NetBSD: subr_workqueue.c,v 1.24 2008/03/27 18:30:15 ad Exp $ */
/*-
* Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.23 2008/03/10 22:20:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.24 2008/03/27 18:30:15 ad Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -63,14 +63,8 @@ struct workqueue {
void *wq_ptr;
};
-#ifdef MULTIPROCESSOR
-#define CPU_ALIGN_SIZE CACHE_LINE_SIZE
-#else
-#define CPU_ALIGN_SIZE (ALIGNBYTES + 1)
-#endif
-
-#define WQ_SIZE (roundup2(sizeof(struct workqueue), CPU_ALIGN_SIZE))
-#define WQ_QUEUE_SIZE (roundup2(sizeof(struct workqueue_queue), CPU_ALIGN_SIZE))
+#define WQ_SIZE (roundup2(sizeof(struct workqueue), coherency_unit))
+#define WQ_QUEUE_SIZE (roundup2(sizeof(struct workqueue_queue), coherency_unit))
#define POISON 0xaabbccdd
@@ -80,7 +74,7 @@ workqueue_size(int flags)
return WQ_SIZE
+ ((flags & WQ_PERCPU) != 0 ? ncpu : 1) * WQ_QUEUE_SIZE
- + CPU_ALIGN_SIZE;
+ + coherency_unit;
}
static struct workqueue_queue *
@@ -241,7 +235,7 @@ workqueue_create(struct workqueue **wqp, const char *name,
KASSERT(sizeof(work_impl_t) <= sizeof(struct work));
ptr = kmem_zalloc(workqueue_size(flags), KM_SLEEP);
- wq = (void *)roundup2((intptr_t)ptr, CPU_ALIGN_SIZE);
+ wq = (void *)roundup2((intptr_t)ptr, coherency_unit);
wq->wq_ptr = ptr;
wq->wq_flags = flags;
diff --git a/sys/kern/sys_mqueue.c b/sys/kern/sys_mqueue.c
index 639fb49f030..cb5eb5d3fca 100644
--- a/sys/kern/sys_mqueue.c
+++ b/sys/kern/sys_mqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_mqueue.c,v 1.8 2008/03/23 00:44:15 rmind Exp $ */
+/* $NetBSD: sys_mqueue.c,v 1.9 2008/03/27 18:30:15 ad Exp $ */
/*
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.8 2008/03/23 00:44:15 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.9 2008/03/27 18:30:15 ad Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -96,7 +96,7 @@ void
mqueue_sysinit(void)
{
- mqmsg_cache = pool_cache_init(MQ_DEF_MSGSIZE, CACHE_LINE_SIZE,
+ mqmsg_cache = pool_cache_init(MQ_DEF_MSGSIZE, coherency_unit,
0, 0, "mqmsg_cache", NULL, IPL_NONE, NULL, NULL, NULL);
mutex_init(&mqlist_mtx, MUTEX_DEFAULT, IPL_NONE);
}
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 02df7131d82..bb2a34b0436 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.99 2008/03/21 21:55:00 ad Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.100 2008/03/27 18:30:15 ad Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.99 2008/03/21 21:55:00 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.100 2008/03/27 18:30:15 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -206,16 +206,13 @@ static pool_cache_t pipe_mutex_cache;
void
pipe_init(void)
{
- size_t size;
pipe_cache = pool_cache_init(sizeof(struct pipe), 0, 0, 0, "pipepl",
NULL, IPL_NONE, NULL, NULL, NULL);
KASSERT(pipe_cache != NULL);
- size = (sizeof(struct pipe_mutex) + (CACHE_LINE_SIZE - 1)) &
- (CACHE_LINE_SIZE - 1);
- pipe_mutex_cache = pool_cache_init(size, CACHE_LINE_SIZE,
- 0, 0, "pipemtxpl", NULL, IPL_NONE, pipe_mutex_ctor,
+ pipe_mutex_cache = pool_cache_init(sizeof(struct pipe_mutex),
+ coherency_unit, 0, 0, "pipemtxpl", NULL, IPL_NONE, pipe_mutex_ctor,
pipe_mutex_dtor, NULL);
KASSERT(pipe_cache != NULL);
}
diff --git a/sys/kern/sys_select.c b/sys/kern/sys_select.c
index b8934dadf7f..5cdd16a3732 100644
--- a/sys/kern/sys_select.c
+++ b/sys/kern/sys_select.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_select.c,v 1.1 2008/03/23 14:02:49 ad Exp $ */
+/* $NetBSD: sys_select.c,v 1.2 2008/03/27 18:30:15 ad Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.1 2008/03/23 14:02:49 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.2 2008/03/27 18:30:15 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -722,9 +722,9 @@ selsysinit(struct cpu_info *ci)
{
selcpu_t *sc;
- sc = kmem_alloc(roundup2(sizeof(selcpu_t), CACHE_LINE_SIZE) +
- CACHE_LINE_SIZE, KM_SLEEP);
- sc = (void *)roundup2((uintptr_t)sc, CACHE_LINE_SIZE);
+ sc = kmem_alloc(roundup2(sizeof(selcpu_t), coherency_unit) +
+ coherency_unit, KM_SLEEP);
+ sc = (void *)roundup2((uintptr_t)sc, coherency_unit);
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SCHED);
sleepq_init(&sc->sc_sleepq, &sc->sc_lock);
sc->sc_ncoll = 0;