Date: Tue, 17 Apr 2012 14:31:02 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r234383 - head/sys/kern Message-ID: <201204171431.q3HEV2mx086128@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Tue Apr 17 14:31:02 2012 New Revision: 234383 URL: http://svn.freebsd.org/changeset/base/234383 Log: 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. Tested by: jh Modified: head/sys/kern/kern_racct.c head/sys/kern/kern_rctl.c Modified: head/sys/kern/kern_racct.c ============================================================================== --- head/sys/kern/kern_racct.c Tue Apr 17 14:26:55 2012 (r234382) +++ head/sys/kern/kern_racct.c Tue Apr 17 14:31:02 2012 (r234383) @@ -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); @@ -723,8 +702,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: head/sys/kern/kern_rctl.c ============================================================================== --- head/sys/kern/kern_rctl.c Tue Apr 17 14:26:55 2012 (r234382) +++ head/sys/kern/kern_rctl.c Tue Apr 17 14:31:02 2012 (r234383) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204171431.q3HEV2mx086128>