Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Whether or not the semaphore code is loaded as a module ...
details: https://anonhg.NetBSD.org/src/rev/e194d192c37d
branches: trunk
changeset: 341507:e194d192c37d
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Nov 09 01:21:18 2015 +0000
description:
Whether or not the semaphore code is loaded as a module or built-in, its
sysctl data belongs with the module code. Move it from kern/init_sysctl.c
to kern/uipc_sem.c
While here, add a new sysctl variable kern.posix.semcnt (current count of
semaphores) to complement the existing kern.posix.semmax (maximum number
of semaphores).
diffstat:
sys/conf/param.c | 10 ++--------
sys/kern/init_sysctl.c | 19 ++-----------------
sys/kern/uipc_sem.c | 34 ++++++++++++++++++++++++++++++++--
3 files changed, 36 insertions(+), 27 deletions(-)
diffs (165 lines):
diff -r ea5c2e14195d -r e194d192c37d sys/conf/param.c
--- a/sys/conf/param.c Mon Nov 09 00:53:57 2015 +0000
+++ b/sys/conf/param.c Mon Nov 09 01:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.c,v 1.66 2015/08/24 22:50:33 pooka Exp $ */
+/* $NetBSD: param.c,v 1.67 2015/11/09 01:21:18 pgoyette Exp $ */
/*
* Copyright (c) 1980, 1986, 1989 Regents of the University of California.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: param.c,v 1.66 2015/08/24 22:50:33 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: param.c,v 1.67 2015/11/09 01:21:18 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_hz.h"
@@ -59,7 +59,6 @@
#include <ufs/ufs/quota.h>
#include <sys/kernel.h>
#include <sys/utsname.h>
-#include <sys/ksem.h>
#include <sys/lwp.h>
#ifdef SYSVSHM
#include <machine/vmparam.h>
@@ -218,8 +217,3 @@
*/
const int msize = MSIZE;
const int mclbytes = MCLBYTES;
-
-/*
- * Values in support of POSIX semaphores.
- */
-int ksem_max = KSEM_MAX;
diff -r ea5c2e14195d -r e194d192c37d sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c Mon Nov 09 00:53:57 2015 +0000
+++ b/sys/kern/init_sysctl.c Mon Nov 09 01:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_sysctl.c,v 1.209 2015/08/25 14:52:31 pooka Exp $ */
+/* $NetBSD: init_sysctl.c,v 1.210 2015/11/09 01:21:18 pgoyette 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.209 2015/08/25 14:52:31 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.210 2015/11/09 01:21:18 pgoyette Exp $");
#include "opt_sysv.h"
#include "opt_compat_netbsd.h"
@@ -64,7 +64,6 @@
#include <sys/stat.h>
#include <sys/kauth.h>
#include <sys/ktrace.h>
-#include <sys/ksem.h>
#include <sys/cpu.h>
@@ -591,20 +590,6 @@
SYSCTL_DESCR("Information from build environment"),
NULL, 0, __UNCONST(buildinfo), 0,
CTL_KERN, CTL_CREATE, CTL_EOL);
-
- /* kern.posix. */
- sysctl_createv(clog, 0, NULL, &rnode,
- CTLFLAG_PERMANENT,
- CTLTYPE_NODE, "posix",
- SYSCTL_DESCR("POSIX options"),
- NULL, 0, NULL, 0,
- CTL_KERN, CTL_CREATE, CTL_EOL);
- sysctl_createv(clog, 0, &rnode, NULL,
- CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
- CTLTYPE_INT, "semmax",
- SYSCTL_DESCR("Maximal number of semaphores"),
- NULL, 0, &ksem_max, 0,
- CTL_CREATE, CTL_EOL);
}
SYSCTL_SETUP(sysctl_hw_misc_setup, "sysctl hw subtree misc setup")
diff -r ea5c2e14195d -r e194d192c37d sys/kern/uipc_sem.c
--- a/sys/kern/uipc_sem.c Mon Nov 09 00:53:57 2015 +0000
+++ b/sys/kern/uipc_sem.c Mon Nov 09 01:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_sem.c,v 1.42 2014/09/05 09:20:59 matt Exp $ */
+/* $NetBSD: uipc_sem.c,v 1.43 2015/11/09 01:21:18 pgoyette Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.42 2014/09/05 09:20:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.43 2015/11/09 01:21:18 pgoyette Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -80,6 +80,7 @@
#include <sys/syscall.h>
#include <sys/syscallargs.h>
#include <sys/syscallvar.h>
+#include <sys/sysctl.h>
MODULE(MODULE_CLASS_MISC, ksem, NULL);
@@ -129,6 +130,9 @@
{ 0, 0, NULL },
};
+struct sysctllog *ksem_clog;
+int ksem_max;
+
static int
ksem_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
void *arg0, void *arg1, void *arg2, void *arg3)
@@ -154,6 +158,7 @@
ksem_sysinit(void)
{
int error;
+ const struct sysctlnode *rnode;
mutex_init(&ksem_lock, MUTEX_DEFAULT, IPL_NONE);
LIST_INIT(&ksem_head);
@@ -168,6 +173,30 @@
ksem_listener = kauth_listen_scope(KAUTH_SCOPE_SYSTEM,
ksem_listener_cb, NULL);
+ /* Define module-specific sysctl tree */
+
+ ksem_max = KSEM_MAX;
+ ksem_clog = NULL;
+
+ sysctl_createv(&ksem_clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "posix",
+ SYSCTL_DESCR("POSIX options"),
+ NULL, 0, NULL, 0,
+ CTL_KERN, CTL_CREATE, CTL_EOL);
+ sysctl_createv(&ksem_clog, 0, &rnode, NULL,
+ CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+ CTLTYPE_INT, "semmax",
+ SYSCTL_DESCR("Maximal number of semaphores"),
+ NULL, 0, &ksem_max, 0,
+ CTL_CREATE, CTL_EOL);
+ sysctl_createv(&ksem_clog, 0, &rnode, NULL,
+ CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+ CTLTYPE_INT, "semcnt",
+ SYSCTL_DESCR("Current number of semaphores"),
+ NULL, 0, &nsems, 0,
+ CTL_CREATE, CTL_EOL);
+
return error;
}
@@ -193,6 +222,7 @@
}
kauth_unlisten_scope(ksem_listener);
mutex_destroy(&ksem_lock);
+ sysctl_teardown(&ksem_clog);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index