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.
This commit is contained in:
pooka 2015-08-25 14:52:31 +00:00
parent f6f0cd6151
commit 7cc60ed4d8
2 changed files with 60 additions and 60 deletions

View File

@ -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 kern subtree setup")
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

View File

@ -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,7 +185,16 @@ SYSCTL_SETUP(sysctl_kernbase_setup, "sysctl kern subtree base setup")
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",
@ -198,6 +207,52 @@ SYSCTL_SETUP(sysctl_hwbase_setup, "sysctl hw subtree base setup")
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);
}
/*