svn commit: r213714 - in head/sys: kern sys
David Xu
davidxu at FreeBSD.org
Tue Oct 12 00:36:57 UTC 2010
Author: davidxu
Date: Tue Oct 12 00:36:56 2010
New Revision: 213714
URL: http://svn.freebsd.org/changeset/base/213714
Log:
Add a flag TDF_TIDHASH to prevent a thread from being
added to or removed from thread hash table multiple times.
Modified:
head/sys/kern/kern_thread.c
head/sys/sys/proc.h
Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c Mon Oct 11 23:24:57 2010 (r213713)
+++ head/sys/kern/kern_thread.c Tue Oct 12 00:36:56 2010 (r213714)
@@ -981,7 +981,12 @@ void
tidhash_add(struct thread *td)
{
rw_wlock(&tidhash_lock);
- LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash);
+ thread_lock(td);
+ if ((td->td_flags & TDF_TIDHASH) == 0) {
+ LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash);
+ td->td_flags |= TDF_TIDHASH;
+ }
+ thread_unlock(td);
rw_wunlock(&tidhash_lock);
}
@@ -989,6 +994,11 @@ void
tidhash_remove(struct thread *td)
{
rw_wlock(&tidhash_lock);
- LIST_REMOVE(td, td_hash);
+ thread_lock(td);
+ if ((td->td_flags & TDF_TIDHASH) != 0) {
+ LIST_REMOVE(td, td_hash);
+ td->td_flags &= ~TDF_TIDHASH;
+ }
+ thread_unlock(td);
rw_wunlock(&tidhash_lock);
}
Modified: head/sys/sys/proc.h
==============================================================================
--- head/sys/sys/proc.h Mon Oct 11 23:24:57 2010 (r213713)
+++ head/sys/sys/proc.h Tue Oct 12 00:36:56 2010 (r213714)
@@ -353,7 +353,7 @@ do { \
#define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */
#define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */
#define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */
-#define TDF_UNUSED19 0x00080000 /* Thread is sleeping on a umtx. */
+#define TDF_TIDHASH 0x00080000 /* Thread is on hash table. */
#define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */
#define TDF_UNUSED21 0x00200000 /* --available-- */
#define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */
More information about the svn-src-head
mailing list