svn commit: r208832 - in stable/8/sys: kern sys

Konstantin Belousov kib at FreeBSD.org
Sat Jun 5 14:53:35 UTC 2010


Author: kib
Date: Sat Jun  5 14:53:34 2010
New Revision: 208832
URL: http://svn.freebsd.org/changeset/base/208832

Log:
  MFC r208731:
  Add a facility to dynamically adjust or unconfigure p1003_1b mib.
  Use it to allow to tune sem_nsem_max at runtime, only when sem.ko
  module is present in kernel.
  
  Approved by:    re (bz)

Modified:
  stable/8/sys/kern/posix4_mib.c
  stable/8/sys/kern/uipc_sem.c
  stable/8/sys/sys/posix4.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/kern/posix4_mib.c
==============================================================================
--- stable/8/sys/kern/posix4_mib.c	Sat Jun  5 12:53:44 2010	(r208831)
+++ stable/8/sys/kern/posix4_mib.c	Sat Jun  5 14:53:34 2010	(r208832)
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
 static int facility[CTL_P1003_1B_MAXID - 1];
 static int facility_initialized[CTL_P1003_1B_MAXID - 1];
 
+static int p31b_sysctl_proc(SYSCTL_HANDLER_ARGS);
+
 /* OID_AUTO isn't working with sysconf(3).  I guess I'd have to
  * modify it to do a lookup by name from the index.
  * For now I've left it a top-level sysctl.
@@ -55,16 +57,21 @@ static int facility_initialized[CTL_P100
 SYSCTL_DECL(_p1003_1b);
 
 #define P1B_SYSCTL(num, name)  \
-SYSCTL_INT(_p1003_1b, num, \
-	name, CTLFLAG_RD, facility + num - 1, 0, "");
+	SYSCTL_INT(_p1003_1b, num, name, CTLFLAG_RD, facility + num - 1, 0, "");
+#define P1B_SYSCTL_RW(num, name)  \
+	SYSCTL_PROC(_p1003_1b, num, name, CTLTYPE_INT | CTLFLAG_RW, NULL, num, \
+	    p31b_sysctl_proc, "I", "");
 
 #else
 
 SYSCTL_DECL(_kern_p1003_1b);
 
 #define P1B_SYSCTL(num, name)  \
-SYSCTL_INT(_kern_p1003_1b, OID_AUTO, \
-	name, CTLFLAG_RD, facility + num - 1, 0, "");
+	SYSCTL_INT(_kern_p1003_1b, OID_AUTO, name, CTLFLAG_RD, \
+	    facility + num - 1, 0, "");
+#define P1B_SYSCTL_RW(num, name)  \
+	SYSCTL_PROC(_p1003_1b, OID_AUTO, name, CTLTYPE_INT | CTLFLAG_RW, NULL, \
+	    num, p31b_sysctl_proc, "I", "");
 SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B");
 
 #endif
@@ -91,13 +98,28 @@ P1B_SYSCTL(CTL_P1003_1B_DELAYTIMER_MAX, 
 P1B_SYSCTL(CTL_P1003_1B_MQ_OPEN_MAX, mq_open_max);
 P1B_SYSCTL(CTL_P1003_1B_PAGESIZE, pagesize);
 P1B_SYSCTL(CTL_P1003_1B_RTSIG_MAX, rtsig_max);
-P1B_SYSCTL(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max);
+P1B_SYSCTL_RW(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max);
 P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max);
 P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max);
 P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max);
 
 #define P31B_VALID(num)	((num) >= 1 && (num) < CTL_P1003_1B_MAXID)
 
+static int
+p31b_sysctl_proc(SYSCTL_HANDLER_ARGS)
+{
+	int error, num, val;
+
+	num = arg2;
+	if (!P31B_VALID(num))
+		return (EINVAL);
+	val = facility_initialized[num] ? facility[num - 1] : 0;
+	error = sysctl_handle_int(oidp, &val, 0, req);
+	if (error == 0 && req->newptr != NULL && facility_initialized[num])
+		facility[num - 1] = val;
+	return (error);
+}
+
 /* p31b_setcfg: Set the configuration
  */
 void
@@ -110,6 +132,14 @@ p31b_setcfg(int num, int value)
 	}
 }
 
+void
+p31b_unsetcfg(int num)
+{
+
+	facility[num - 1] = 0;
+	facility_initialized[num -1] = 0;
+}
+
 int
 p31b_getcfg(int num)
 {

Modified: stable/8/sys/kern/uipc_sem.c
==============================================================================
--- stable/8/sys/kern/uipc_sem.c	Sat Jun  5 12:53:44 2010	(r208831)
+++ stable/8/sys/kern/uipc_sem.c	Sat Jun  5 14:53:34 2010	(r208832)
@@ -977,6 +977,8 @@ ksem_module_destroy(void)
 	sx_destroy(&ksem_dict_lock);
 	mtx_destroy(&ksem_count_lock);
 	mtx_destroy(&sem_lock);
+	p31b_unsetcfg(CTL_P1003_1B_SEM_VALUE_MAX);
+	p31b_unsetcfg(CTL_P1003_1B_SEM_NSEMS_MAX);
 }
 
 static int

Modified: stable/8/sys/sys/posix4.h
==============================================================================
--- stable/8/sys/sys/posix4.h	Sat Jun  5 12:53:44 2010	(r208831)
+++ stable/8/sys/sys/posix4.h	Sat Jun  5 14:53:34 2010	(r208832)
@@ -64,6 +64,7 @@ int p31b_proc(struct proc *, pid_t, stru
 void p31b_setcfg(int, int);
 int p31b_getcfg(int);
 int p31b_iscfg(int);
+void p31b_unsetcfg(int);
 
 #ifdef _KPOSIX_PRIORITY_SCHEDULING
 


More information about the svn-src-stable-8 mailing list