Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - Move sched_listener and co. from kern_synch.c to sys_s...
details: https://anonhg.NetBSD.org/src/rev/c1e305d7ae64
branches: trunk
changeset: 747868:c1e305d7ae64
user: elad <elad%NetBSD.org@localhost>
date: Sat Oct 03 22:32:56 2009 +0000
description:
- Move sched_listener and co. from kern_synch.c to sys_sched.c, where it
really belongs (suggested by rmind@),
- Rename sched_init() to synch_init(), and introduce a new sched_init()
in sys_sched.c where we (a) initialize the sysctl node (no more
link-set) and (b) listen on the process scope with sched_listener.
Reviewed by and okay rmind@.
diffstat:
sys/kern/init_main.c | 8 +++--
sys/kern/kern_synch.c | 61 ++------------------------------------------
sys/kern/sys_sched.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++--
sys/sys/sched.h | 3 +-
4 files changed, 76 insertions(+), 65 deletions(-)
diffs (258 lines):
diff -r 2896fe1477e2 -r c1e305d7ae64 sys/kern/init_main.c
--- a/sys/kern/init_main.c Sat Oct 03 22:28:33 2009 +0000
+++ b/sys/kern/init_main.c Sat Oct 03 22:32:56 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.404 2009/10/02 22:18:57 elad Exp $ */
+/* $NetBSD: init_main.c,v 1.405 2009/10/03 22:32:56 elad Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.404 2009/10/02 22:18:57 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.405 2009/10/03 22:32:56 elad Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -398,6 +398,8 @@
turnstile_init();
sleeptab_init(&sleeptab);
+ sched_init();
+
/* Initialize processor-sets */
psets_init();
@@ -780,7 +782,7 @@
/* Setup the runqueues and scheduler. */
runq_init();
- sched_init();
+ synch_init();
/*
* Bus scans can make it appear as if the system has paused, so
diff -r 2896fe1477e2 -r c1e305d7ae64 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Sat Oct 03 22:28:33 2009 +0000
+++ b/sys/kern/kern_synch.c Sat Oct 03 22:32:56 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.269 2009/10/03 21:21:56 elad Exp $ */
+/* $NetBSD: kern_synch.c,v 1.270 2009/10/03 22:32:56 elad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.269 2009/10/03 21:21:56 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.270 2009/10/03 22:32:56 elad Exp $");
#include "opt_kstack.h"
#include "opt_perfctrs.h"
@@ -97,7 +97,6 @@
#include <sys/lwpctl.h>
#include <sys/atomic.h>
#include <sys/simplelock.h>
-#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -128,8 +127,6 @@
unsigned sched_pstats_ticks;
kcondvar_t lbolt; /* once a second sleep address */
-static kauth_listener_t sched_listener;
-
/* Preemption event counters */
static struct evcnt kpreempt_ev_crit;
static struct evcnt kpreempt_ev_klock;
@@ -145,57 +142,8 @@
*/
int safepri;
-static int
-sched_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
- void *arg0, void *arg1, void *arg2, void *arg3)
-{
- struct proc *p;
- int result;
-
- result = KAUTH_RESULT_DEFER;
- p = arg0;
-
- switch (action) {
- case KAUTH_PROCESS_SCHEDULER_GETPARAM:
- if (kauth_cred_uidmatch(cred, p->p_cred))
- result = KAUTH_RESULT_ALLOW;
- break;
-
- case KAUTH_PROCESS_SCHEDULER_SETPARAM:
- if (kauth_cred_uidmatch(cred, p->p_cred)) {
- struct lwp *l;
- int policy;
- pri_t priority;
-
- l = arg1;
- policy = (int)(unsigned long)arg2;
- priority = (pri_t)(unsigned long)arg3;
-
- if ((policy == l->l_class ||
- (policy != SCHED_FIFO && policy != SCHED_RR)) &&
- priority <= l->l_priority)
- result = KAUTH_RESULT_ALLOW;
- }
-
- break;
-
- case KAUTH_PROCESS_SCHEDULER_GETAFFINITY:
- result = KAUTH_RESULT_ALLOW;
- break;
-
- case KAUTH_PROCESS_SCHEDULER_SETAFFINITY:
- /* Privileged; we let the secmodel handle this. */
- break;
-
- default:
- break;
- }
-
- return result;
-}
-
void
-sched_init(void)
+synch_init(void)
{
cv_init(&lbolt, "lbolt");
@@ -210,9 +158,6 @@
"kpreempt", "immediate");
sched_pstats(NULL);
-
- sched_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
- sched_listener_cb, NULL);
}
/*
diff -r 2896fe1477e2 -r c1e305d7ae64 sys/kern/sys_sched.c
--- a/sys/kern/sys_sched.c Sat Oct 03 22:28:33 2009 +0000
+++ b/sys/kern/sys_sched.c Sat Oct 03 22:32:56 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_sched.c,v 1.33 2009/03/03 21:55:06 rmind Exp $ */
+/* $NetBSD: sys_sched.c,v 1.34 2009/10/03 22:32:56 elad Exp $ */
/*
* Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.33 2009/03/03 21:55:06 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.34 2009/10/03 22:32:56 elad Exp $");
#include <sys/param.h>
@@ -64,6 +64,9 @@
#include "opt_sa.h"
+static struct sysctllog *sched_sysctl_log;
+static kauth_listener_t sched_listener;
+
/*
* Convert user priority or the in-kernel priority or convert the current
* priority to the appropriate range according to the policy change.
@@ -528,7 +531,8 @@
/*
* Sysctl nodes and initialization.
*/
-SYSCTL_SETUP(sysctl_sched_setup, "sysctl sched setup")
+static void
+sysctl_sched_setup(struct sysctllog **clog)
{
const struct sysctlnode *node = NULL;
@@ -568,3 +572,62 @@
NULL, SCHED_PRI_MAX, NULL, 0,
CTL_CREATE, CTL_EOL);
}
+
+static int
+sched_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
+ void *arg0, void *arg1, void *arg2, void *arg3)
+{
+ struct proc *p;
+ int result;
+
+ result = KAUTH_RESULT_DEFER;
+ p = arg0;
+
+ switch (action) {
+ case KAUTH_PROCESS_SCHEDULER_GETPARAM:
+ if (kauth_cred_uidmatch(cred, p->p_cred))
+ result = KAUTH_RESULT_ALLOW;
+ break;
+
+ case KAUTH_PROCESS_SCHEDULER_SETPARAM:
+ if (kauth_cred_uidmatch(cred, p->p_cred)) {
+ struct lwp *l;
+ int policy;
+ pri_t priority;
+
+ l = arg1;
+ policy = (int)(unsigned long)arg2;
+ priority = (pri_t)(unsigned long)arg3;
+
+ if ((policy == l->l_class ||
+ (policy != SCHED_FIFO && policy != SCHED_RR)) &&
+ priority <= l->l_priority)
+ result = KAUTH_RESULT_ALLOW;
+ }
+
+ break;
+
+ case KAUTH_PROCESS_SCHEDULER_GETAFFINITY:
+ result = KAUTH_RESULT_ALLOW;
+ break;
+
+ case KAUTH_PROCESS_SCHEDULER_SETAFFINITY:
+ /* Privileged; we let the secmodel handle this. */
+ break;
+
+ default:
+ break;
+ }
+
+ return result;
+}
+
+void
+sched_init(void)
+{
+
+ sysctl_sched_setup(&sched_sysctl_log);
+
+ sched_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
+ sched_listener_cb, NULL);
+}
diff -r 2896fe1477e2 -r c1e305d7ae64 sys/sys/sched.h
--- a/sys/sys/sched.h Sat Oct 03 22:28:33 2009 +0000
+++ b/sys/sys/sched.h Sat Oct 03 22:32:56 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sched.h,v 1.70 2009/04/25 19:38:25 rmind Exp $ */
+/* $NetBSD: sched.h,v 1.71 2009/10/03 22:32:56 elad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -228,6 +228,7 @@
/* Scheduler initialization */
void runq_init(void);
+void synch_init(void);
void sched_init(void);
void sched_rqinit(void);
void sched_cpuattach(struct cpu_info *);
Home |
Main Index |
Thread Index |
Old Index