Module Name:    src
Committed By:   rmind
Date:           Fri May 13 22:16:44 UTC 2011

Modified Files:
        src/sys/kern: kern_cpu.c kern_mutex_obj.c kern_rwlock_obj.c
            kern_synch.c subr_percpu.c subr_xcall.c sysv_sem.c vfs_vnode.c

Log Message:
Sprinkle __cacheline_aligned and __read_mostly.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/kern/kern_cpu.c
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/kern_mutex_obj.c \
    src/sys/kern/kern_rwlock_obj.c
cvs rdiff -u -r1.288 -r1.289 src/sys/kern/kern_synch.c
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_percpu.c \
    src/sys/kern/subr_xcall.c
cvs rdiff -u -r1.86 -r1.87 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.5 -r1.6 src/sys/kern/vfs_vnode.c

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_cpu.c
diff -u src/sys/kern/kern_cpu.c:1.45 src/sys/kern/kern_cpu.c:1.46
--- src/sys/kern/kern_cpu.c:1.45	Wed Dec 22 02:43:23 2010
+++ src/sys/kern/kern_cpu.c	Fri May 13 22:16:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_cpu.c,v 1.45 2010/12/22 02:43:23 matt Exp $	*/
+/*	$NetBSD: kern_cpu.c,v 1.46 2011/05/13 22:16:43 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.45 2010/12/22 02:43:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.46 2011/05/13 22:16:43 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -103,13 +103,14 @@
 	D_OTHER | D_MPSAFE
 };
 
-kmutex_t cpu_lock;
-int	ncpu;
-int	ncpuonline;
-bool	mp_online;
-struct	cpuqueue cpu_queue = CIRCLEQ_HEAD_INITIALIZER(cpu_queue);
+kmutex_t	cpu_lock		__cacheline_aligned;
+int		ncpu			__read_mostly;
+int		ncpuonline		__read_mostly;
+bool		mp_online		__read_mostly;
+struct cpuqueue	cpu_queue		__cacheline_aligned
+    = CIRCLEQ_HEAD_INITIALIZER(cpu_queue);
 
-static struct cpu_info **cpu_infos;
+static struct cpu_info **cpu_infos	__read_mostly;
 
 int
 mi_cpu_attach(struct cpu_info *ci)

Index: src/sys/kern/kern_mutex_obj.c
diff -u src/sys/kern/kern_mutex_obj.c:1.2 src/sys/kern/kern_mutex_obj.c:1.3
--- src/sys/kern/kern_mutex_obj.c:1.2	Wed Mar 31 19:59:39 2010
+++ src/sys/kern/kern_mutex_obj.c	Fri May 13 22:16:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_mutex_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $	*/
+/*	$NetBSD: kern_mutex_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -47,7 +47,7 @@
 
 static int	mutex_obj_ctor(void *, void *, int);
 
-static pool_cache_t	mutex_obj_cache;
+static pool_cache_t	mutex_obj_cache		__read_mostly;
 
 /*
  * mutex_obj_init:
Index: src/sys/kern/kern_rwlock_obj.c
diff -u src/sys/kern/kern_rwlock_obj.c:1.2 src/sys/kern/kern_rwlock_obj.c:1.3
--- src/sys/kern/kern_rwlock_obj.c:1.2	Wed Mar 31 19:59:39 2010
+++ src/sys/kern/kern_rwlock_obj.c	Fri May 13 22:16:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rwlock_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $	*/
+/*	$NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -47,7 +47,7 @@
 
 static int	rw_obj_ctor(void *, void *, int);
 
-static pool_cache_t	rw_obj_cache;
+static pool_cache_t	rw_obj_cache	__read_mostly;
 
 /*
  * rw_obj_init:

Index: src/sys/kern/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.288 src/sys/kern/kern_synch.c:1.289
--- src/sys/kern/kern_synch.c:1.288	Mon May  2 00:29:53 2011
+++ src/sys/kern/kern_synch.c	Fri May 13 22:16:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $	*/
+/*	$NetBSD: kern_synch.c,v 1.289 2011/05/13 22:16:43 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.289 2011/05/13 22:16:43 rmind Exp $");
 
 #include "opt_kstack.h"
 #include "opt_perfctrs.h"
@@ -128,13 +128,15 @@
 	syncobj_noowner,
 };
 
-unsigned	sched_pstats_ticks;
-kcondvar_t	lbolt;			/* once a second sleep address */
+/* "Lightning bolt": once a second sleep address. */
+kcondvar_t		lbolt			__cacheline_aligned;
 
-/* Preemption event counters */
-static struct evcnt kpreempt_ev_crit;
-static struct evcnt kpreempt_ev_klock;
-static struct evcnt kpreempt_ev_immed;
+u_int			sched_pstats_ticks	__cacheline_aligned;
+
+/* Preemption event counters. */
+static struct evcnt	kpreempt_ev_crit	__cacheline_aligned;
+static struct evcnt	kpreempt_ev_klock	__cacheline_aligned;
+static struct evcnt	kpreempt_ev_immed	__cacheline_aligned;
 
 /*
  * During autoconfiguration or after a panic, a sleep will simply lower the

Index: src/sys/kern/subr_percpu.c
diff -u src/sys/kern/subr_percpu.c:1.12 src/sys/kern/subr_percpu.c:1.13
--- src/sys/kern/subr_percpu.c:1.12	Tue Apr 19 07:12:59 2011
+++ src/sys/kern/subr_percpu.c	Fri May 13 22:16:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_percpu.c,v 1.12 2011/04/19 07:12:59 martin Exp $	*/
+/*	$NetBSD: subr_percpu.c,v 1.13 2011/05/13 22:16:44 rmind Exp $	*/
 
 /*-
  * Copyright (c)2007,2008 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.12 2011/04/19 07:12:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.13 2011/05/13 22:16:44 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -58,10 +58,10 @@
 #define	percpu_decrypt(pc)	(pc)
 #endif /* defined(DIAGNOSTIC) */
 
-static krwlock_t percpu_swap_lock;
-static kmutex_t percpu_allocation_lock;
-static vmem_t *percpu_offset_arena;
-static unsigned int percpu_nextoff = PERCPU_QUANTUM_SIZE;
+static krwlock_t	percpu_swap_lock	__cacheline_aligned;
+static kmutex_t		percpu_allocation_lock	__cacheline_aligned;
+static vmem_t *		percpu_offset_arena	__cacheline_aligned;
+static unsigned int	percpu_nextoff		__cacheline_aligned;
 
 static percpu_cpu_t *
 cpu_percpu(struct cpu_info *ci)
@@ -217,6 +217,7 @@
 	ASSERT_SLEEPABLE();
 	rw_init(&percpu_swap_lock);
 	mutex_init(&percpu_allocation_lock, MUTEX_DEFAULT, IPL_NONE);
+	percpu_nextoff = PERCPU_QUANTUM_SIZE;
 
 	percpu_offset_arena = vmem_create("percpu", 0, 0, PERCPU_QUANTUM_SIZE,
 	    percpu_backend_alloc, NULL, NULL, PERCPU_QCACHE_MAX, VM_SLEEP,
Index: src/sys/kern/subr_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.12 src/sys/kern/subr_xcall.c:1.13
--- src/sys/kern/subr_xcall.c:1.12	Tue Jun 22 18:29:01 2010
+++ src/sys/kern/subr_xcall.c	Fri May 13 22:16:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_xcall.c,v 1.12 2010/06/22 18:29:01 rmind Exp $	*/
+/*	$NetBSD: subr_xcall.c,v 1.13 2011/05/13 22:16:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
  
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.12 2010/06/22 18:29:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13 2011/05/13 22:16:44 rmind Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -100,16 +100,16 @@
 #define	XC_PRI_BIT	(1ULL << 63)
 
 /* Low priority xcall structures. */
-static xc_state_t	xc_low_pri;
-static uint64_t		xc_tailp;
+static xc_state_t	xc_low_pri	__cacheline_aligned;
+static uint64_t		xc_tailp	__cacheline_aligned;
 
 /* High priority xcall structures. */
-static xc_state_t	xc_high_pri;
-static void *		xc_sih;
+static xc_state_t	xc_high_pri	__cacheline_aligned;
+static void *		xc_sih		__cacheline_aligned;
 
 /* Event counters. */
-static struct evcnt	xc_unicast_ev;
-static struct evcnt	xc_broadcast_ev;
+static struct evcnt	xc_unicast_ev	__cacheline_aligned;
+static struct evcnt	xc_broadcast_ev	__cacheline_aligned;
 
 static void		xc_init(void);
 static void		xc_thread(void *);

Index: src/sys/kern/sysv_sem.c
diff -u src/sys/kern/sysv_sem.c:1.86 src/sys/kern/sysv_sem.c:1.87
--- src/sys/kern/sysv_sem.c:1.86	Mon Oct  5 23:46:02 2009
+++ src/sys/kern/sysv_sem.c	Fri May 13 22:16:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_sem.c,v 1.86 2009/10/05 23:46:02 rmind Exp $	*/
+/*	$NetBSD: sysv_sem.c,v 1.87 2011/05/13 22:16:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.86 2009/10/05 23:46:02 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.87 2011/05/13 22:16:44 rmind Exp $");
 
 #define SYSVSEM
 
@@ -59,18 +59,22 @@
  *  3rd: Conditional variables
  *  4th: Undo structures
  */
-struct semid_ds		*sema;
-static struct __sem	*sem;
-static kcondvar_t	*semcv;
-static int		*semu;
-
-static kmutex_t	semlock;
-static struct	sem_undo *semu_list;	/* list of active undo structures */
-static u_int	semtot = 0;		/* total number of semaphores */
-
-static u_int	sem_waiters = 0;	/* total number of semop waiters */
-static bool	sem_realloc_state;
-static kcondvar_t sem_realloc_cv;
+struct semid_ds *	sema			__read_mostly;
+static struct __sem *	sem			__read_mostly;
+static kcondvar_t *	semcv			__read_mostly;
+static int *		semu			__read_mostly;
+
+static kmutex_t		semlock			__cacheline_aligned;
+static bool		sem_realloc_state	__read_mostly;
+static kcondvar_t	sem_realloc_cv;
+
+/*
+ * List of active undo structures, total number of semaphores,
+ * and total number of semop waiters.
+ */
+static struct sem_undo *semu_list		__read_mostly;
+static u_int		semtot			__cacheline_aligned;
+static u_int		sem_waiters		__cacheline_aligned;
 
 /* Macro to find a particular sem_undo vector */
 #define SEMU(s, ix)	((struct sem_undo *)(((long)s) + ix * seminfo.semusz))
@@ -94,6 +98,8 @@
 	mutex_init(&semlock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(&sem_realloc_cv, "semrealc");
 	sem_realloc_state = false;
+	semtot = 0;
+	sem_waiters = 0;
 
 	/* Allocate the wired memory for our structures */
 	sz = ALIGN(seminfo.semmni * sizeof(struct semid_ds)) +

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.5 src/sys/kern/vfs_vnode.c:1.6
--- src/sys/kern/vfs_vnode.c:1.5	Mon Apr  4 02:46:57 2011
+++ src/sys/kern/vfs_vnode.c	Fri May 13 22:16:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.5 2011/04/04 02:46:57 rmind Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.6 2011/05/13 22:16:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5 2011/04/04 02:46:57 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.6 2011/05/13 22:16:44 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -115,20 +115,20 @@
 #include <uvm/uvm.h>
 #include <uvm/uvm_readahead.h>
 
-u_int			numvnodes;
+u_int			numvnodes		__cacheline_aligned;
 
-static pool_cache_t	vnode_cache;
-static kmutex_t		vnode_free_list_lock;
+static pool_cache_t	vnode_cache		__read_mostly;
+static kmutex_t		vnode_free_list_lock	__cacheline_aligned;
 
-static vnodelst_t	vnode_free_list;
-static vnodelst_t	vnode_hold_list;
-static vnodelst_t	vrele_list;
-
-static kmutex_t		vrele_lock;
-static kcondvar_t	vrele_cv;
-static lwp_t *		vrele_lwp;
-static int		vrele_pending;
-static int		vrele_gen;
+static vnodelst_t	vnode_free_list		__cacheline_aligned;
+static vnodelst_t	vnode_hold_list		__cacheline_aligned;
+static vnodelst_t	vrele_list		__cacheline_aligned;
+
+static kmutex_t		vrele_lock		__cacheline_aligned;
+static kcondvar_t	vrele_cv		__cacheline_aligned;
+static lwp_t *		vrele_lwp		__cacheline_aligned;
+static int		vrele_pending		__cacheline_aligned;
+static int		vrele_gen		__cacheline_aligned;
 
 static vnode_t *	getcleanvnode(void);
 static void		vrele_thread(void *);

Reply via email to