Date: Thu, 14 Mar 2013 23:20:19 +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: r248298 - head/sys/kern Message-ID: <201303142320.r2ENKJln060775@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Thu Mar 14 23:20:18 2013 New Revision: 248298 URL: http://svnweb.freebsd.org/changeset/base/248298 Log: Accessing td_state requires thread lock to be held. Submitted by: Rudo Tomori Reviewed by: kib Modified: head/sys/kern/kern_racct.c Modified: head/sys/kern/kern_racct.c ============================================================================== --- head/sys/kern/kern_racct.c Thu Mar 14 23:14:47 2013 (r248297) +++ head/sys/kern/kern_racct.c Thu Mar 14 23:20:18 2013 (r248298) @@ -1033,6 +1033,7 @@ racct_proc_throttle(struct proc *p) p->p_throttled = 1; FOREACH_THREAD_IN_PROC(p, td) { + thread_lock(td); switch (td->td_state) { case TDS_RUNQ: /* @@ -1041,27 +1042,24 @@ racct_proc_throttle(struct proc *p) * TDF_NEEDRESCHED for the thread, so that once it is * running, it is taken off the cpu as soon as possible. */ - thread_lock(td); td->td_flags |= TDF_NEEDRESCHED; - thread_unlock(td); break; case TDS_RUNNING: /* * If the thread is running, we request a context * switch for it by setting the TDF_NEEDRESCHED flag. */ - thread_lock(td); td->td_flags |= TDF_NEEDRESCHED; #ifdef SMP cpuid = td->td_oncpu; if ((cpuid != NOCPU) && (td != curthread)) ipi_cpu(cpuid, IPI_AST); #endif - thread_unlock(td); break; default: break; } + thread_unlock(td); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303142320.r2ENKJln060775>