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
This commit is contained in:
parent
47f6635cc1
commit
0b18eb6d74
@ -267,9 +267,6 @@ racct_add_locked(struct proc *p, int resource, uint64_t amount)
|
||||
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 resource, uint64_t amount)
|
||||
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 resource, uint64_t amount)
|
||||
{
|
||||
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, struct proc *child)
|
||||
*/
|
||||
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);
|
||||
|
@ -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, struct rctl_get_racct_args *uap)
|
||||
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, struct proc *child)
|
||||
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user