Date: Mon, 3 Aug 2015 20:43:36 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286256 - head/sys/kern Message-ID: <201508032043.t73Kha3U001918@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Mon Aug 3 20:43:36 2015 New Revision: 286256 URL: https://svnweb.freebsd.org/changeset/base/286256 Log: kgdb uses td_oncpu to determine if a thread is running and should use a pcb from stoppcbs[] rather than the thread's PCB. However, exited threads retained td_oncpu from the last time they ran, and newborn threads had their CPU fields cleared to zero during fork and thread creation since they are in the set of fields zeroed when threads are setup. To fix, explicitly update the CPU fields for exiting threads in sched_throw() to reflect the switch out and reset the CPU fields for new threads in sched_fork_thread() to NOCPU. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D3193 Modified: head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Mon Aug 3 20:30:27 2015 (r286255) +++ head/sys/kern/sched_4bsd.c Mon Aug 3 20:43:36 2015 (r286256) @@ -792,6 +792,8 @@ sched_fork_thread(struct thread *td, str { struct td_sched *ts; + childtd->td_oncpu = NOCPU; + childtd->td_lastcpu = NOCPU; childtd->td_estcpu = td->td_estcpu; childtd->td_lock = &sched_lock; childtd->td_cpuset = cpuset_ref(td->td_cpuset); @@ -1671,6 +1673,8 @@ sched_throw(struct thread *td) } else { lock_profile_release_lock(&sched_lock.lock_object); MPASS(td->td_lock == &sched_lock); + td->td_lastcpu = td->td_oncpu; + td->td_oncpu = NOCPU; } mtx_assert(&sched_lock, MA_OWNED); KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Mon Aug 3 20:30:27 2015 (r286255) +++ head/sys/kern/sched_ule.c Mon Aug 3 20:43:36 2015 (r286256) @@ -2080,6 +2080,8 @@ sched_fork_thread(struct thread *td, str */ ts = td->td_sched; ts2 = child->td_sched; + child->td_oncpu = NOCPU; + child->td_lastcpu = NOCPU; child->td_lock = TDQ_LOCKPTR(tdq); child->td_cpuset = cpuset_ref(td->td_cpuset); ts2->ts_cpu = ts->ts_cpu; @@ -2703,6 +2705,8 @@ sched_throw(struct thread *td) MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); tdq_load_rem(tdq, td); lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object); + td->td_lastcpu = td->td_oncpu; + td->td_oncpu = NOCPU; } KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); newtd = choosethread();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508032043.t73Kha3U001918>