History log of /freebsd-10-stable/sys/kern/kern_thread.c
Revision Date Author Comments
# 337258 03-Aug-2018 asomers

MFC r336205:

Don't acquire evclass_lock with a spinlock held

When the "pc" audit class is enabled and auditd is running, witness will
panic during thread exit because au_event_class tries to lock an rwlock
while holding a spinlock acquired upstack by thread_exit.

To fix this, move AUDIT_SYSCALL_EXIT futher upstack, before the spinlock is
acquired. Of thread_exit's 16 callers, it's only necessary to call
AUDIT_SYSCALL_EXIT from two, exit1 (for exiting processes) and kern_thr_exit
(for exiting threads). The other callers are all kernel threads, which
needen't call AUDIT_SYSCALL_EXIT because since they can't make syscalls
there will be nothing to audit. And exit1 already does call
AUDIT_SYSCALL_EXIT, making the second call in thread_exit redundant for that
case.

PR: 228444
Reported by: aniketp
Reviewed by: aniketp, kib
Differential Revision: https://reviews.freebsd.org/D16210


# 315837 23-Mar-2017 avg

MFC r315074: actually implement proc:::lwp-exit probe


# 314667 04-Mar-2017 avg

MFC r283291: don't use CALLOUT_MPSAFE with callout_init()

The main purpose of this MFC is to reduce conflicts for other merges.
Parts of the original change have already "trickled down" via individual MFCs.


# 304905 27-Aug-2016 kib

MFC r303426:
Rewrite subr_sleepqueue.c use of callouts to not depend on the
specifics of callout KPI.


# 302134 23-Jun-2016 kib

MFC r301960:
Remove XXX comments from kern_thread.c.


# 302133 23-Jun-2016 kib

MFC r301959:
Remove code duplication.


# 294614 22-Jan-2016 jhb

MFC 292892:
Call kern_thr_exit() instead of duplicating it.

This code is missing the racct_subr() call from kern_thr_exit() and would
require further code duplication in future changes.


# 293490 09-Jan-2016 dchagin

MFC r283382:

In preparation for switching linuxulator to the use the native 1:1
threads add a hook for cleaning thread resources before the thread die.


# 293473 09-Jan-2016 dchagin

To facillitate an upcoming Linuxulator merging partially
MFC r275121 (by kib). Only merge the syntax changes from r275121,
PROC_*LOCK() macros still lock the same proc spinlock.

The process spin lock currently has the following distinct uses:

- Threads lifetime cycle, in particular, counting of the threads in
the process, and interlocking with process mutex and thread lock.
The main reason of this is that turnstile locks are after thread
locks, so you e.g. cannot unlock blockable mutex (think process
mutex) while owning thread lock.

- Virtual and profiling itimers, since the timers activation is done
from the clock interrupt context. Replace the p_slock by p_itimmtx
and PROC_ITIMLOCK().

- Profiling code (profil(2)), for similar reason. Replace the p_slock
by p_profmtx and PROC_PROFLOCK().

- Resource usage accounting. Need for the spinlock there is subtle,
my understanding is that spinlock blocks context switching for the
current thread, which prevents td_runtime and similar fields from
changing (updates are done at the mi_switch()). Replace the p_slock
by p_statmtx and PROC_STATLOCK().

Discussed with: kib


# 290325 03-Nov-2015 kib

MFC r289661:
Mark struct thread zone as type-stable, to prevent dereference of the
freed memory in the locks spin loops.


# 283765 30-May-2015 kib

MFC r283320:
Always obey thread request to not stop on non-boundary.


# 283279 22-May-2015 kib

MFC r282944:
Decrement p_boundary_count in the single-threading thread, during making
other thread runnable. This guarantees that upon return from the
thread_single_end(), p_boundary_count is zero.


# 283004 16-May-2015 kib

MFC r282679:
Do not return from thread_single(SINGLE_BOUNDARY) until all stopped
thread are guarenteed to be removed from the processors.


# 281979 25-Apr-2015 kib

MFC r281696:
Initialize td_sel in the thread_init().

PR: 199518


# 280309 20-Mar-2015 kib

MFC r279390:
Change umtx_lock to be the sleepable mutex.


# 276272 26-Dec-2014 kib

MFC r275745:
Add facility to stop all userspace processes.

MFC r275753:
Fix gcc build.

MFC r275820:
Add missed break.


# 275795 15-Dec-2014 kib

MFC r275617:
Do some refactoring and minor cleanups of the thread_single() code.


# 275794 15-Dec-2014 kib

MFC r275616:
Thread waiting for the vfork(2)-ed child to exec or exit, must allow
for the suspension.

MFC r275683 (by andreast):
Fix build for powerpc(32|64) kernels.

MFC r275686 (by andreast):
Fix kernel build for booke.

r275639 (by andrew) is not merged, since arm/arm/syscall.c is not
present on the stable/10 branch, and arm/arm/trap.c already includes
sys/kernel.h.


# 271372 10-Sep-2014 kib

MFC r271000:
Delay the return from thread_single(SINGLE_EXIT) until all threads are
really destroyed by thread_stash() after the last switch out.

MFC r271007:
Retire thread_unthread().

MFC r271008:
Style.

Approved by: re (marius)


# 260817 17-Jan-2014 avg

MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE


# 283765 30-May-2015 kib

MFC r283320:
Always obey thread request to not stop on non-boundary.


# 283279 22-May-2015 kib

MFC r282944:
Decrement p_boundary_count in the single-threading thread, during making
other thread runnable. This guarantees that upon return from the
thread_single_end(), p_boundary_count is zero.


# 283004 16-May-2015 kib

MFC r282679:
Do not return from thread_single(SINGLE_BOUNDARY) until all stopped
thread are guarenteed to be removed from the processors.


# 281979 25-Apr-2015 kib

MFC r281696:
Initialize td_sel in the thread_init().

PR: 199518


# 280309 20-Mar-2015 kib

MFC r279390:
Change umtx_lock to be the sleepable mutex.


# 276272 26-Dec-2014 kib

MFC r275745:
Add facility to stop all userspace processes.

MFC r275753:
Fix gcc build.

MFC r275820:
Add missed break.


# 275795 15-Dec-2014 kib

MFC r275617:
Do some refactoring and minor cleanups of the thread_single() code.


# 275794 15-Dec-2014 kib

MFC r275616:
Thread waiting for the vfork(2)-ed child to exec or exit, must allow
for the suspension.

MFC r275683 (by andreast):
Fix build for powerpc(32|64) kernels.

MFC r275686 (by andreast):
Fix kernel build for booke.

r275639 (by andrew) is not merged, since arm/arm/syscall.c is not
present on the stable/10 branch, and arm/arm/trap.c already includes
sys/kernel.h.


# 271372 10-Sep-2014 kib

MFC r271000:
Delay the return from thread_single(SINGLE_EXIT) until all threads are
really destroyed by thread_stash() after the last switch out.

MFC r271007:
Retire thread_unthread().

MFC r271008:
Style.

Approved by: re (marius)


# 260817 17-Jan-2014 avg

MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE