Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - Add mi_cpu_init() and initialise cpu_lock and kcpuset_...
details: https://anonhg.NetBSD.org/src/rev/a086c36d5bb9
branches: trunk
changeset: 773254:a086c36d5bb9
user: rmind <rmind%NetBSD.org@localhost>
date: Sun Jan 29 22:55:40 2012 +0000
description:
- Add mi_cpu_init() and initialise cpu_lock and kcpuset_attached/running there.
- Add kcpuset_running which gets set in idle_loop().
- Use kcpuset_running in pserialize_perform().
diffstat:
sys/kern/init_main.c | 6 +++---
sys/kern/kern_cpu.c | 28 +++++++++++++++++++++++-----
sys/kern/kern_idle.c | 5 +++--
sys/kern/subr_pserialize.c | 6 +++---
sys/kern/sys_sched.c | 7 ++++---
sys/sys/cpu.h | 5 +++--
sys/sys/cpu_data.h | 5 +++--
7 files changed, 42 insertions(+), 20 deletions(-)
diffs (217 lines):
diff -r 56c630a5e407 -r a086c36d5bb9 sys/kern/init_main.c
--- a/sys/kern/init_main.c Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/kern/init_main.c Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.439 2012/01/24 20:03:36 christos Exp $ */
+/* $NetBSD: init_main.c,v 1.440 2012/01/29 22:55:40 rmind Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.439 2012/01/24 20:03:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.440 2012/01/29 22:55:40 rmind Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -304,7 +304,7 @@
kernel_lock_init();
once_init();
- mutex_init(&cpu_lock, MUTEX_DEFAULT, IPL_NONE);
+ mi_cpu_init();
kernconfig_lock_init();
kthread_sysinit();
diff -r 56c630a5e407 -r a086c36d5bb9 sys/kern/kern_cpu.c
--- a/sys/kern/kern_cpu.c Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/kern/kern_cpu.c Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_cpu.c,v 1.54 2012/01/17 10:47:27 cegger Exp $ */
+/* $NetBSD: kern_cpu.c,v 1.55 2012/01/29 22:55:40 rmind Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010, 2012 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.54 2012/01/17 10:47:27 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.55 2012/01/29 22:55:40 rmind Exp $");
#include "opt_cpu_ucode.h"
@@ -110,13 +110,31 @@
int ncpuonline __read_mostly;
bool mp_online __read_mostly;
-kcpuset_t * kcpuset_attached __read_mostly;
+/* Note: set on mi_cpu_attach() and idle_loop(). */
+kcpuset_t * kcpuset_attached __read_mostly = NULL;
+kcpuset_t * kcpuset_running __read_mostly = NULL;
struct cpuqueue cpu_queue __cacheline_aligned
= CIRCLEQ_HEAD_INITIALIZER(cpu_queue);
static struct cpu_info **cpu_infos __read_mostly;
+/*
+ * mi_cpu_init: early initialisation of MI CPU related structures.
+ *
+ * Note: may not block and memory allocator is not yet available.
+ */
+void
+mi_cpu_init(void)
+{
+
+ mutex_init(&cpu_lock, MUTEX_DEFAULT, IPL_NONE);
+
+ kcpuset_create(&kcpuset_attached, true);
+ kcpuset_create(&kcpuset_running, true);
+ kcpuset_set(kcpuset_running, 0);
+}
+
int
mi_cpu_attach(struct cpu_info *ci)
{
@@ -125,6 +143,8 @@
KASSERT(maxcpus > 0);
ci->ci_index = ncpu;
+ kcpuset_set(kcpuset_attached, cpu_index(ci));
+
CIRCLEQ_INSERT_TAIL(&cpu_queue, ci, ci_data.cpu_qchain);
TAILQ_INIT(&ci->ci_data.cpu_ld_locks);
__cpu_simple_lock_init(&ci->ci_data.cpu_ld_lock);
@@ -136,10 +156,8 @@
if (__predict_false(cpu_infos == NULL)) {
cpu_infos =
kmem_zalloc(sizeof(cpu_infos[0]) * maxcpus, KM_SLEEP);
- kcpuset_create(&kcpuset_attached, true);
}
cpu_infos[cpu_index(ci)] = ci;
- kcpuset_set(kcpuset_attached, ci->ci_index);
sched_cpuattach(ci);
diff -r 56c630a5e407 -r a086c36d5bb9 sys/kern/kern_idle.c
--- a/sys/kern/kern_idle.c Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/kern/kern_idle.c Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_idle.c,v 1.24 2011/01/17 07:13:31 uebayasi Exp $ */
+/* $NetBSD: kern_idle.c,v 1.25 2012/01/29 22:55:40 rmind Exp $ */
/*-
* Copyright (c)2002, 2006, 2007 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.24 2011/01/17 07:13:31 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.25 2012/01/29 22:55:40 rmind Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -49,6 +49,7 @@
struct schedstate_percpu *spc;
struct lwp *l = curlwp;
+ kcpuset_atomic_set(kcpuset_running, cpu_index(ci));
ci->ci_data.cpu_onproc = l;
/* Update start time for this thread. */
diff -r 56c630a5e407 -r a086c36d5bb9 sys/kern/subr_pserialize.c
--- a/sys/kern/subr_pserialize.c Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/kern/subr_pserialize.c Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pserialize.c,v 1.4 2011/08/07 21:38:32 rmind Exp $ */
+/* $NetBSD: subr_pserialize.c,v 1.5 2012/01/29 22:55:40 rmind Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.4 2011/08/07 21:38:32 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.5 2012/01/29 22:55:40 rmind Exp $");
#include <sys/param.h>
@@ -156,7 +156,7 @@
* other processors.
*/
psz->psz_owner = curlwp;
- kcpuset_copy(psz->psz_target, kcpuset_attached);
+ kcpuset_copy(psz->psz_target, kcpuset_running);
kcpuset_zero(psz->psz_pass);
mutex_spin_enter(&psz_lock);
diff -r 56c630a5e407 -r a086c36d5bb9 sys/kern/sys_sched.c
--- a/sys/kern/sys_sched.c Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/kern/sys_sched.c Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_sched.c,v 1.38 2011/08/07 21:38:32 rmind Exp $ */
+/* $NetBSD: sys_sched.c,v 1.39 2012/01/29 22:55:40 rmind Exp $ */
/*
* Copyright (c) 2008, 2011 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.38 2011/08/07 21:38:32 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.39 2012/01/29 22:55:40 rmind Exp $");
#include <sys/param.h>
@@ -353,8 +353,9 @@
for (CPU_INFO_FOREACH(cii, ici)) {
struct schedstate_percpu *ispc;
- if (kcpuset_isset(kcset, cpu_index(ici)) == 0)
+ if (!kcpuset_isset(kcset, cpu_index(ici))) {
continue;
+ }
ispc = &ici->ci_schedstate;
/* Check that CPU is not in the processor-set */
diff -r 56c630a5e407 -r a086c36d5bb9 sys/sys/cpu.h
--- a/sys/sys/cpu.h Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/sys/cpu.h Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.34 2012/01/13 16:05:16 cegger Exp $ */
+/* $NetBSD: cpu.h,v 1.35 2012/01/29 22:55:40 rmind Exp $ */
/*-
* Copyright (c) 2007 YAMAMOTO Takashi,
@@ -94,7 +94,8 @@
extern u_int maxcpus;
extern struct cpuqueue cpu_queue;
extern kcpuset_t *kcpuset_attached;
-
+extern kcpuset_t *kcpuset_running;
+
static inline u_int
cpu_index(struct cpu_info *ci)
{
diff -r 56c630a5e407 -r a086c36d5bb9 sys/sys/cpu_data.h
--- a/sys/sys/cpu_data.h Sun Jan 29 20:20:18 2012 +0000
+++ b/sys/sys/cpu_data.h Sun Jan 29 22:55:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_data.h,v 1.33 2011/02/17 18:32:29 rmind Exp $ */
+/* $NetBSD: cpu_data.h,v 1.34 2012/01/29 22:55:40 rmind Exp $ */
/*-
* Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -125,6 +125,7 @@
#define ci_core_id ci_data.cpu_core_id
#define ci_smt_id ci_data.cpu_smt_id
-int mi_cpu_attach(struct cpu_info *ci);
+void mi_cpu_init(void);
+int mi_cpu_attach(struct cpu_info *);
#endif /* _SYS_CPU_DATA_H_ */
Home |
Main Index |
Thread Index |
Old Index