diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c --- a/sys/kern/kern_idle.c +++ b/sys/kern/kern_idle.c @@ -82,4 +82,7 @@ #ifdef SMP } #endif + PROC_LOCK(p); + p->p_flag |= P_IDLEPROC; + PROC_UNLOCK(p); } diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -322,15 +322,13 @@ u_int swtime; #ifdef SCHED_4BSD fixpt_t pctcpu, pctcpu_next; -#endif -#ifdef SMP - struct pcpu *pc; - int found; #endif fixpt_t p_pctcpu; struct thread *td; ASSERT_RACCT_ENABLED(); + KASSERT((p->p_flag & P_IDLEPROC) == 0, + ("racct_getpcpu: idle process %p", p)); swtime = (ticks - p->p_swtick) / hz; @@ -344,19 +342,6 @@ p_pctcpu = 0; FOREACH_THREAD_IN_PROC(p, td) { - if (td == PCPU_GET(idlethread)) - continue; -#ifdef SMP - found = 0; - STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { - if (td == pc->pc_idlethread) { - found = 1; - break; - } - } - if (found) - continue; -#endif thread_lock(td); #ifdef SCHED_4BSD pctcpu = sched_pctcpu(td); @@ -1252,7 +1237,8 @@ FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - if (p->p_state != PRS_NORMAL) { + if (p->p_state != PRS_NORMAL || + (p->p_flag & P_IDLEPROC) != 0) { if (p->p_state == PRS_ZOMBIE) racct_set(p, RACCT_PCTCPU, 0); PROC_UNLOCK(p); diff --git a/sys/sys/proc.h b/sys/sys/proc.h --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -803,7 +803,7 @@ lock. */ #define P_CONTROLT 0x00000002 /* Has a controlling terminal. */ #define P_KPROC 0x00000004 /* Kernel process. */ -#define P_UNUSED3 0x00000008 /* --available-- */ +#define P_IDLEPROC 0x00000008 /* Container for system idle threads. */ #define P_PPWAIT 0x00000010 /* Parent is waiting for child to exec/exit. */ #define P_PROFIL 0x00000020 /* Has started profiling. */