diff options
author | trasz <trasz@FreeBSD.org> | 2013-03-14 23:20:18 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2013-03-14 23:20:18 +0000 |
commit | 8593db8ad43b6bccf4eb60017ae9ebedfe7722f6 (patch) | |
tree | 90fa447537cc5276caee21d97df8664fda2c1f20 | |
parent | 3d6eb97a85e1458edb83b958747f6fe433bf1e12 (diff) | |
download | FreeBSD-src-8593db8ad43b6bccf4eb60017ae9ebedfe7722f6.zip FreeBSD-src-8593db8ad43b6bccf4eb60017ae9ebedfe7722f6.tar.gz |
Accessing td_state requires thread lock to be held.
Submitted by: Rudo Tomori
Reviewed by: kib
-rw-r--r-- | sys/kern/kern_racct.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index bf8141c..d31c832 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -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); } } |