Module Name:    src
Committed By:   jruoho
Date:           Wed Jul 28 20:49:13 UTC 2010

Modified Files:
        src/lib/librt: mq.3
        src/share/man/man7: sysctl.7
        src/sys/kern: sys_mqueue.c

Log Message:
Get rid of SYSCTL_SETUP.

We want the sysctl variables also when mqueue(3) is loaded as a module.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librt/mq.3
cvs rdiff -u -r1.47 -r1.48 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.29 -r1.30 src/sys/kern/sys_mqueue.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librt/mq.3
diff -u src/lib/librt/mq.3:1.3 src/lib/librt/mq.3:1.4
--- src/lib/librt/mq.3:1.3	Mon Jun  7 16:33:45 2010
+++ src/lib/librt/mq.3	Wed Jul 28 20:49:12 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: mq.3,v 1.3 2010/06/07 16:33:45 wiz Exp $
+.\" $NetBSD: mq.3,v 1.4 2010/07/28 20:49:12 jruoho Exp $
 .\"
 .\" Copyright (c) 2010 Jukka Ruohonen <jruoho...@iki.fi>
 .\"
@@ -23,11 +23,12 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 26, 2010
+.Dd July 28, 2010
 .Dt MQ 3
 .Os
 .Sh NAME
-.Nm mq
+.Nm mq ,
+.Nm mqueue
 .Nd POSIX message queues (REALTIME)
 .Sh LIBRARY
 .Lb librt
@@ -144,10 +145,7 @@
 The standard does not specify whether
 .Tn POSIX
 message queues are exposed at the file system level.
-In the
-.Nx
-implementation these are not seen in the file system.
-Thus, it can be argued that
+It can be argued that
 .Nm
 inherited an old problem with the System V message queues.
 Even if an implementation would have support for it,
@@ -221,14 +219,13 @@
 .Fn mq_getattr
 and
 .Fn mq_setattr ,
-to retrieve and set attributes once
-the message queue has been created,
-the resource limits cannot be changed
-by an user once the queue has been created.
-To avoid blocking in case the maximum number of messages has been reached, the
-.Dv O_NONBLOCK
-flag can be set as an argument to
-.Fn mq_open .
+to retrieve and set attributes,
+resource limits cannot be changed once the queue has been created.
+In
+.Nx
+the super user may however control the global resource limits by using few
+.Xr sysctl 7
+variables.
 .Ss Asynchronous Notification
 Instead of blocking in the functions that receive messages,
 .Nm
@@ -278,8 +275,8 @@
 The basic rule of thumb with realtime prioritization is that low priority
 tasks should never unnecessarily delay high priority tasks.
 Priority inheritance is not however part of the provided
-.Tn API .
-The receiver process may run at low priority even
+.Tn API ;
+the receiver process may run at low priority even
 when receiving high priority messages.
 To address this limitation and other potential realtime problems,
 the user may consider other functions from the

Index: src/share/man/man7/sysctl.7
diff -u src/share/man/man7/sysctl.7:1.47 src/share/man/man7/sysctl.7:1.48
--- src/share/man/man7/sysctl.7:1.47	Tue Apr 20 13:03:33 2010
+++ src/share/man/man7/sysctl.7	Wed Jul 28 20:49:12 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.7,v 1.47 2010/04/20 13:03:33 wiz Exp $
+.\"	$NetBSD: sysctl.7,v 1.48 2010/07/28 20:49:12 jruoho Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
 .\"
-.Dd April 20, 2010
+.Dd July 28, 2010
 .Dt SYSCTL 7
 .Os
 .Sh NAME
@@ -692,6 +692,36 @@
 A boolean that enables or disables verbose
 debug messages related to kernel modules.
 .El
+.It Li kern.mqueue
+Settings related to
+.Tn POSIX
+message queues; see
+.Xr mqueue 3 .
+This node is created dynamically when
+the corresponding kernel module is loaded.
+The third level names for the settings are described below.
+.Bl -column "kern.mqueue.mq_max_msgsize" "integer" "Changeable" -offset indent
+.It Sy Third level name	Type	Changeable
+.It kern.mqueue.mq_open_max	integer	yes
+.It kern.mqueue.mq_prio_max	integer	yes
+.It kern.mqueue.mq_max_msgsize	integer	yes
+.It kern.mqueue.mq_def_maxmsg	integer	yes
+.It kern.mqueue.mq_max_maxmsg	integer	yes
+.El
+.Pp
+The variables are:
+.Bl -tag -width "123456"
+.It Li kern.mqueue.mq_open_max
+The maximum number of message queue descriptors any single process can open.
+.It Li kern.mqueue.mq_prio_max
+The maximum priority of a message.
+.It Li kern.mqueue.mq_max_msgsize
+The maximum size of a message in a message queue.
+.It Li kern.mqueue.mq_def_maxmsg
+The default maximum message count.
+.It Li kern.mqueue.mq_max_maxmsg
+The maximum number of messages in a message queue.
+.El
 .It Li kern.monotonic_clock ( KERN_MONOTONIC_CLOCK )
 Returns the standard version the implementation of the POSIX 1003.1b
 Monotonic Clock Option conforms to,

Index: src/sys/kern/sys_mqueue.c
diff -u src/sys/kern/sys_mqueue.c:1.29 src/sys/kern/sys_mqueue.c:1.30
--- src/sys/kern/sys_mqueue.c:1.29	Sun Dec 20 09:36:05 2009
+++ src/sys/kern/sys_mqueue.c	Wed Jul 28 20:49:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_mqueue.c,v 1.29 2009/12/20 09:36:05 dsl Exp $	*/
+/*	$NetBSD: sys_mqueue.c,v 1.30 2010/07/28 20:49:12 jruoho Exp $	*/
 
 /*
  * Copyright (c) 2007-2009 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.29 2009/12/20 09:36:05 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.30 2010/07/28 20:49:12 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -87,9 +87,11 @@
 static kmutex_t			mqlist_mtx;
 static pool_cache_t		mqmsg_cache;
 static LIST_HEAD(, mqueue)	mqueue_head;
+static struct sysctllog		*mqsysctl_log;
 
 static int	mqueue_sysinit(void);
 static int	mqueue_sysfini(bool);
+static int	mqueue_sysctl_init(void);
 static int	mq_poll_fop(file_t *, int);
 static int	mq_stat_fop(file_t *, struct stat *);
 static int	mq_close_fop(file_t *);
@@ -134,6 +136,11 @@
 	mutex_init(&mqlist_mtx, MUTEX_DEFAULT, IPL_NONE);
 	LIST_INIT(&mqueue_head);
 
+	error = mqueue_sysctl_init();
+	if (error) {
+		(void)mqueue_sysfini(false);
+		return error;
+	}
 	error = syscall_establish(NULL, mqueue_syscalls);
 	if (error) {
 		(void)mqueue_sysfini(false);
@@ -166,6 +173,10 @@
 			return EBUSY;
 		}
 	}
+
+	if (mqsysctl_log != NULL)
+		sysctl_teardown(&mqsysctl_log);
+
 	mutex_destroy(&mqlist_mtx);
 	pool_cache_destroy(mqmsg_cache);
 	return 0;
@@ -1119,17 +1130,19 @@
 /*
  * System control nodes.
  */
-
-SYSCTL_SETUP(sysctl_mqueue_setup, "sysctl mqueue setup")
+static int
+mqueue_sysctl_init(void)
 {
 	const struct sysctlnode *node = NULL;
 
-	sysctl_createv(clog, 0, NULL, NULL,
+	mqsysctl_log = NULL;
+
+	sysctl_createv(&mqsysctl_log, 0, NULL, NULL,
 		CTLFLAG_PERMANENT,
 		CTLTYPE_NODE, "kern", NULL,
 		NULL, 0, NULL, 0,
 		CTL_KERN, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
+	sysctl_createv(&mqsysctl_log, 0, NULL, NULL,
 		CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
 		CTLTYPE_INT, "posix_msg",
 		SYSCTL_DESCR("Version of IEEE Std 1003.1 and its "
@@ -1137,7 +1150,7 @@
 			     "system attempts to conform"),
 		NULL, _POSIX_MESSAGE_PASSING, NULL, 0,
 		CTL_KERN, CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, &node,
+	sysctl_createv(&mqsysctl_log, 0, NULL, &node,
 		CTLFLAG_PERMANENT,
 		CTLTYPE_NODE, "mqueue",
 		SYSCTL_DESCR("Message queue options"),
@@ -1145,39 +1158,41 @@
 		CTL_KERN, CTL_CREATE, CTL_EOL);
 
 	if (node == NULL)
-		return;
+		return ENXIO;
 
-	sysctl_createv(clog, 0, &node, NULL,
+	sysctl_createv(&mqsysctl_log, 0, &node, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "mq_open_max",
 		SYSCTL_DESCR("Maximal number of message queue descriptors "
 			     "that process could open"),
 		NULL, 0, &mq_open_max, 0,
 		CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, &node, NULL,
+	sysctl_createv(&mqsysctl_log, 0, &node, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "mq_prio_max",
 		SYSCTL_DESCR("Maximal priority of the message"),
 		NULL, 0, &mq_prio_max, 0,
 		CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, &node, NULL,
+	sysctl_createv(&mqsysctl_log, 0, &node, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "mq_max_msgsize",
 		SYSCTL_DESCR("Maximal allowed size of the message"),
 		NULL, 0, &mq_max_msgsize, 0,
 		CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, &node, NULL,
+	sysctl_createv(&mqsysctl_log, 0, &node, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "mq_def_maxmsg",
 		SYSCTL_DESCR("Default maximal message count"),
 		NULL, 0, &mq_def_maxmsg, 0,
 		CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, &node, NULL,
+	sysctl_createv(&mqsysctl_log, 0, &node, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "mq_max_maxmsg",
 		SYSCTL_DESCR("Maximal allowed message count"),
 		NULL, 0, &mq_max_maxmsg, 0,
 		CTL_CREATE, CTL_EOL);
+
+	return 0;
 }
 
 /*

Reply via email to