Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern We can not count CPUs at sysctl initialization time...



details:   https://anonhg.NetBSD.org/src/rev/c63a58385fbc
branches:  trunk
changeset: 556027:c63a58385fbc
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Dec 06 09:36:34 2003 +0000

description:
We can not count CPUs at sysctl initialization time - so don't make
hw.ncpu an immediate value.

diffstat:

 sys/kern/init_sysctl.c |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 04fd2f642d7e -r c63a58385fbc sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c    Sat Dec 06 09:32:22 2003 +0000
+++ b/sys/kern/init_sysctl.c    Sat Dec 06 09:36:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_sysctl.c,v 1.2 2003/12/06 02:52:29 atatat Exp $ */
+/*     $NetBSD: init_sysctl.c,v 1.3 2003/12/06 09:36:34 martin Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
 #define PTRTOINT64(foo)        ((u_int64_t)(uintptr_t)(foo))
 
 #ifndef MULTIPROCESSOR
-#define sysctl_ncpus() (1)
+#define        sysctl_ncpus()  (1)
 #else /* MULTIPROCESSOR */
 #ifndef CPU_INFO_FOREACH
 #define CPU_INFO_ITERATOR int
@@ -134,6 +134,7 @@
 static int sysctl_kern_proc_args(SYSCTLFN_PROTO);
 static int sysctl_hw_usermem(SYSCTLFN_PROTO);
 static int sysctl_hw_cnmagic(SYSCTLFN_PROTO);
+static int sysctl_hw_ncpu(SYSCTLFN_PROTO);
 
 static void fill_kproc2(struct proc *, struct kinfo_proc2 *);
 static void fill_lwp(struct lwp *l, struct kinfo_lwp *kl);
@@ -581,9 +582,9 @@
                       CTLTYPE_STRING, "model", NULL,
                       NULL, 0, cpu_model, 0,
                       CTL_HW, HW_MODEL, CTL_EOL);
-       sysctl_createv(SYSCTL_PERMANENT|SYSCTL_IMMEDIATE,
+       sysctl_createv(SYSCTL_PERMANENT,
                       CTLTYPE_INT, "ncpu", NULL,
-                      NULL, sysctl_ncpus(), NULL, 0,
+                      sysctl_hw_ncpu, 0, NULL, 0,
                       CTL_HW, HW_NCPU, CTL_EOL);
        sysctl_createv(SYSCTL_PERMANENT|SYSCTL_IMMEDIATE,
                       CTLTYPE_INT, "byteorder", NULL,
@@ -1963,6 +1964,20 @@
        return (cn_set_magic(magic));
 }
 
+static int
+sysctl_hw_ncpu(SYSCTLFN_ARGS)
+{
+       int ncpu;
+       struct sysctlnode node;
+
+       ncpu = sysctl_ncpus();
+       node = *rnode;
+       node.sysctl_data = &ncpu;
+       
+       return (sysctl_lookup(SYSCTLFN_CALL(&node)));
+}
+
+
 /*
  * ********************************************************************
  * section 3: public helper routines that are used for more than one



Home | Main Index | Thread Index | Old Index