Module Name:    src
Committed By:   pooka
Date:           Tue Aug 25 14:52:31 UTC 2015

Modified Files:
        src/sys/kern: init_sysctl.c init_sysctl_base.c

Log Message:
Move a bunch of sysctl nodes from init_sysctl (kitchen sink sysctl file)
to init_sysctl_base (only base kernel defs).  Main motivation was to
fix sysconf(_SC_NPROCESSORS) for Rumprun.  As reported by neeraj on irc,
it returned -1 before this fix, so we were doing imaginary computing.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/kern/init_sysctl.c
cvs rdiff -u -r1.6 -r1.7 src/sys/kern/init_sysctl_base.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/init_sysctl.c
diff -u src/sys/kern/init_sysctl.c:1.208 src/sys/kern/init_sysctl.c:1.209
--- src/sys/kern/init_sysctl.c:1.208	Tue Jul  7 12:38:02 2015
+++ src/sys/kern/init_sysctl.c	Tue Aug 25 14:52:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_sysctl.c,v 1.208 2015/07/07 12:38:02 justin Exp $ */
+/*	$NetBSD: init_sysctl.c,v 1.209 2015/08/25 14:52:31 pooka Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.208 2015/07/07 12:38:02 justin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.209 2015/08/25 14:52:31 pooka Exp $");
 
 #include "opt_sysv.h"
 #include "opt_compat_netbsd.h"
@@ -607,82 +607,27 @@ SYSCTL_SETUP(sysctl_kern_setup, "sysctl 
 			CTL_CREATE, CTL_EOL);
 }
 
-SYSCTL_SETUP(sysctl_hw_setup, "sysctl hw subtree setup")
+SYSCTL_SETUP(sysctl_hw_misc_setup, "sysctl hw subtree misc setup")
 {
-	u_int u;
-	u_quad_t q;
-	const char *model = cpu_getmodel();
 
 	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT,
-		       CTLTYPE_STRING, "model",
-		       SYSCTL_DESCR("Machine model"),
-		       NULL, 0, __UNCONST(model), 0,
-		       CTL_HW, HW_MODEL, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT,
-		       CTLTYPE_INT, "ncpu",
-		       SYSCTL_DESCR("Number of CPUs configured"),
-		       NULL, 0, &ncpu, 0,
-		       CTL_HW, HW_NCPU, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
-		       CTLTYPE_INT, "byteorder",
-		       SYSCTL_DESCR("System byte order"),
-		       NULL, BYTE_ORDER, NULL, 0,
-		       CTL_HW, HW_BYTEORDER, CTL_EOL);
-	u = ((u_int)physmem > (UINT_MAX / PAGE_SIZE)) ?
-		UINT_MAX : physmem * PAGE_SIZE;
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
-		       CTLTYPE_INT, "physmem",
-		       SYSCTL_DESCR("Bytes of physical memory"),
-		       NULL, u, NULL, 0,
-		       CTL_HW, HW_PHYSMEM, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT,
 		       CTLTYPE_INT, "usermem",
 		       SYSCTL_DESCR("Bytes of non-kernel memory"),
 		       sysctl_hw_usermem, 0, NULL, 0,
 		       CTL_HW, HW_USERMEM, CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
-		       CTLTYPE_INT, "pagesize",
-		       SYSCTL_DESCR("Software page size"),
-		       NULL, PAGE_SIZE, NULL, 0,
-		       CTL_HW, HW_PAGESIZE, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
-		       CTLTYPE_INT, "alignbytes",
-		       SYSCTL_DESCR("Alignment constraint for all possible "
-				    "data types"),
-		       NULL, ALIGNBYTES, NULL, 0,
-		       CTL_HW, HW_ALIGNBYTES, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE|CTLFLAG_HEX,
 		       CTLTYPE_STRING, "cnmagic",
 		       SYSCTL_DESCR("Console magic key sequence"),
 		       sysctl_hw_cnmagic, 0, NULL, CNS_LEN,
 		       CTL_HW, HW_CNMAGIC, CTL_EOL);
-	q = (u_quad_t)physmem * PAGE_SIZE;
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
-		       CTLTYPE_QUAD, "physmem64",
-		       SYSCTL_DESCR("Bytes of physical memory"),
-		       NULL, q, NULL, 0,
-		       CTL_HW, HW_PHYSMEM64, CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT,
 		       CTLTYPE_QUAD, "usermem64",
 		       SYSCTL_DESCR("Bytes of non-kernel memory"),
 		       sysctl_hw_usermem, 0, NULL, 0,
 		       CTL_HW, HW_USERMEM64, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT,
-		       CTLTYPE_INT, "ncpuonline",
-		       SYSCTL_DESCR("Number of CPUs online"),
-		       NULL, 0, &ncpuonline, 0,
-		       CTL_HW, HW_NCPUONLINE, CTL_EOL);
 }
 
 #ifdef DEBUG

Index: src/sys/kern/init_sysctl_base.c
diff -u src/sys/kern/init_sysctl_base.c:1.6 src/sys/kern/init_sysctl_base.c:1.7
--- src/sys/kern/init_sysctl_base.c:1.6	Tue Aug 25 14:32:34 2015
+++ src/sys/kern/init_sysctl_base.c	Tue Aug 25 14:52:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_sysctl_base.c,v 1.6 2015/08/25 14:32:34 pooka Exp $ */
+/*	$NetBSD: init_sysctl_base.c,v 1.7 2015/08/25 14:52:31 pooka Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl_base.c,v 1.6 2015/08/25 14:32:34 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl_base.c,v 1.7 2015/08/25 14:52:31 pooka Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -185,9 +185,18 @@ SYSCTL_SETUP(sysctl_kernbase_setup, "sys
 
 SYSCTL_SETUP(sysctl_hwbase_setup, "sysctl hw subtree base setup")
 {
+	u_int u;
+	u_quad_t q;
+	const char *model = cpu_getmodel();
 
 	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT,
+		       CTLTYPE_STRING, "model",
+		       SYSCTL_DESCR("Machine model"),
+		       NULL, 0, __UNCONST(model), 0,
+		       CTL_HW, HW_MODEL, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT,
 		       CTLTYPE_STRING, "machine",
 		       SYSCTL_DESCR("Machine class"),
 		       NULL, 0, machine, 0,
@@ -198,6 +207,52 @@ SYSCTL_SETUP(sysctl_hwbase_setup, "sysct
 		       SYSCTL_DESCR("Machine CPU class"),
 		       NULL, 0, machine_arch, 0,
 		       CTL_HW, HW_MACHINE_ARCH, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT,
+		       CTLTYPE_INT, "ncpu",
+		       SYSCTL_DESCR("Number of CPUs configured"),
+		       NULL, 0, &ncpu, 0,
+		       CTL_HW, HW_NCPU, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+		       CTLTYPE_INT, "byteorder",
+		       SYSCTL_DESCR("System byte order"),
+		       NULL, BYTE_ORDER, NULL, 0,
+		       CTL_HW, HW_BYTEORDER, CTL_EOL);
+	u = ((u_int)physmem > (UINT_MAX / PAGE_SIZE)) ?
+		UINT_MAX : physmem * PAGE_SIZE;
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+		       CTLTYPE_INT, "physmem",
+		       SYSCTL_DESCR("Bytes of physical memory"),
+		       NULL, u, NULL, 0,
+		       CTL_HW, HW_PHYSMEM, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+		       CTLTYPE_INT, "pagesize",
+		       SYSCTL_DESCR("Software page size"),
+		       NULL, PAGE_SIZE, NULL, 0,
+		       CTL_HW, HW_PAGESIZE, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+		       CTLTYPE_INT, "alignbytes",
+		       SYSCTL_DESCR("Alignment constraint for all possible "
+				    "data types"),
+		       NULL, ALIGNBYTES, NULL, 0,
+		       CTL_HW, HW_ALIGNBYTES, CTL_EOL);
+	q = (u_quad_t)physmem * PAGE_SIZE;
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+		       CTLTYPE_QUAD, "physmem64",
+		       SYSCTL_DESCR("Bytes of physical memory"),
+		       NULL, q, NULL, 0,
+		       CTL_HW, HW_PHYSMEM64, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT,
+		       CTLTYPE_INT, "ncpuonline",
+		       SYSCTL_DESCR("Number of CPUs online"),
+		       NULL, 0, &ncpuonline, 0,
+		       CTL_HW, HW_NCPUONLINE, CTL_EOL);
 }
 
 /*

Reply via email to