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. Requested and tested by: amdmi3 Reviewed by: jhb MFC after: 3 days
This commit is contained in:
parent
fca046e372
commit
5e1e617f5e
@ -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_P1003_1B_MAXID - 1];
|
||||
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, 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)
|
||||
{
|
||||
|
@ -976,6 +976,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
|
||||
|
@ -64,6 +64,7 @@ int p31b_proc(struct proc *, pid_t, struct proc **);
|
||||
void p31b_setcfg(int, int);
|
||||
int p31b_getcfg(int);
|
||||
int p31b_iscfg(int);
|
||||
void p31b_unsetcfg(int);
|
||||
|
||||
#ifdef _KPOSIX_PRIORITY_SCHEDULING
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user