svn commit: r235913 - stable/9/sys/kern
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu May 24 15:55:43 UTC 2012
Author: trasz
Date: Thu May 24 15:55:41 2012
New Revision: 235913
URL: http://svn.freebsd.org/changeset/base/235913
Log:
MFC r234383:
Stop treating system processes as special. This fixes panics
like the one triggered by this:
# kldload geom_vinum
# pwait `pgrep -S gv_worker` &
# kldunload geom_vinum
or this:
GEOM_JOURNAL: Shutting down geom gjournal 3464572051.
panic: destroying non-empty racct: 1 allocated for resource 6
which were tracked by jh@ to be caused by checking p->p_flag,
while it wasn't initialised yet. Basically, during fork, the code
checked p_flag, concluded the process isn't marked as P_SYSTEM,
incremented the counter, and later on, when exiting, checked that
the process was marked as P_SYSTEM, and thus didn't decrement it.
Also, I believe there wasn't any good reason for checking P_SYSTEM
in the first place.
Modified:
stable/9/sys/kern/kern_racct.c
stable/9/sys/kern/kern_rctl.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/kern/kern_racct.c
==============================================================================
--- stable/9/sys/kern/kern_racct.c Thu May 24 15:25:35 2012 (r235912)
+++ stable/9/sys/kern/kern_racct.c Thu May 24 15:55:41 2012 (r235913)
@@ -267,9 +267,6 @@ racct_add_locked(struct proc *p, int res
int error;
#endif
- if (p->p_flag & P_SYSTEM)
- return (0);
-
SDT_PROBE(racct, kernel, rusage, add, p, resource, amount, 0, 0);
/*
@@ -344,9 +341,6 @@ void
racct_add_force(struct proc *p, int resource, uint64_t amount)
{
- if (p->p_flag & P_SYSTEM)
- return;
-
SDT_PROBE(racct, kernel, rusage, add_force, p, resource, amount, 0, 0);
/*
@@ -368,9 +362,6 @@ racct_set_locked(struct proc *p, int res
int error;
#endif
- if (p->p_flag & P_SYSTEM)
- return (0);
-
SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0);
/*
@@ -426,9 +417,6 @@ racct_set_force(struct proc *p, int reso
{
int64_t diff;
- if (p->p_flag & P_SYSTEM)
- return;
-
SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0);
/*
@@ -487,9 +475,6 @@ void
racct_sub(struct proc *p, int resource, uint64_t amount)
{
- if (p->p_flag & P_SYSTEM)
- return;
-
SDT_PROBE(racct, kernel, rusage, sub, p, resource, amount, 0, 0);
/*
@@ -556,12 +541,6 @@ racct_proc_fork(struct proc *parent, str
*/
racct_create(&child->p_racct);
- /*
- * No resource accounting for kernel processes.
- */
- if (child->p_flag & P_SYSTEM)
- return (0);
-
PROC_LOCK(parent);
PROC_LOCK(child);
mtx_lock(&racct_lock);
@@ -711,8 +690,6 @@ racctd(void)
FOREACH_PROC_IN_SYSTEM(p) {
if (p->p_state != PRS_NORMAL)
continue;
- if (p->p_flag & P_SYSTEM)
- continue;
microuptime(&wallclock);
timevalsub(&wallclock, &p->p_stats->p_start);
Modified: stable/9/sys/kern/kern_rctl.c
==============================================================================
--- stable/9/sys/kern/kern_rctl.c Thu May 24 15:25:35 2012 (r235912)
+++ stable/9/sys/kern/kern_rctl.c Thu May 24 15:55:41 2012 (r235913)
@@ -994,11 +994,6 @@ rctl_rule_add(struct rctl_rule *rule)
case RCTL_SUBJECT_TYPE_PROCESS:
p = rule->rr_subject.rs_proc;
KASSERT(p != NULL, ("rctl_rule_add: NULL proc"));
- /*
- * No resource limits for system processes.
- */
- if (p->p_flag & P_SYSTEM)
- return (EPERM);
rctl_racct_add_rule(p->p_racct, rule);
/*
@@ -1036,8 +1031,6 @@ rctl_rule_add(struct rctl_rule *rule)
*/
sx_assert(&allproc_lock, SA_LOCKED);
FOREACH_PROC_IN_SYSTEM(p) {
- if (p->p_flag & P_SYSTEM)
- continue;
cred = p->p_ucred;
switch (rule->rr_subject_type) {
case RCTL_SUBJECT_TYPE_USER:
@@ -1284,10 +1277,6 @@ sys_rctl_get_racct(struct thread *td, st
error = EINVAL;
goto out;
}
- if (p->p_flag & P_SYSTEM) {
- error = EINVAL;
- goto out;
- }
outputsbuf = rctl_racct_to_sbuf(p->p_racct, 0);
break;
case RCTL_SUBJECT_TYPE_USER:
@@ -1719,20 +1708,7 @@ rctl_proc_fork(struct proc *parent, stru
LIST_INIT(&child->p_racct->r_rule_links);
- /*
- * No limits for kernel processes.
- */
- if (child->p_flag & P_SYSTEM)
- return (0);
-
- /*
- * Nothing to inherit from P_SYSTEM parents.
- */
- if (parent->p_racct == NULL) {
- KASSERT(parent->p_flag & P_SYSTEM,
- ("non-system process without racct; p = %p", parent));
- return (0);
- }
+ KASSERT(parent->p_racct != NULL, ("process without racct; p = %p", parent));
rw_wlock(&rctl_lock);
More information about the svn-src-stable-9
mailing list