]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Improve the ktrace locking somewhat to reduce overhead:
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 13 Jun 2007 20:01:42 +0000 (20:01 +0000)
committerJohn Baldwin <jhb@FreeBSD.org>
Wed, 13 Jun 2007 20:01:42 +0000 (20:01 +0000)
commit34a9edafbc5a13fa5f16c5e4e9f9f5df7d04f262
tree04c4626ae55b88c5f4812648c9e15bb1ef22b6fc
parentce0be646879c129805b2c182608f06c4ef97022b
Improve the ktrace locking somewhat to reduce overhead:
- Depessimize userret() in kernels where KTRACE is enabled by doing an
  unlocked check of the per-process queue of pending events before
  acquiring any locks.  Previously ktr_userret() unconditionally acquired
  the global ktrace_sx lock on every return to userland for every thread,
  even if ktrace wasn't enabled for the thread.
- Optimize the locking in exit() to first perform an unlocked read of
  p_traceflag to see if ktrace is enabled and only acquire locks and
  teardown ktrace if the test succeeds.  Also, explicitly disable tracing
  before draining any pending events so the pending events actually get
  written out.  The unlocked read is safe because proc lock is acquired
  earlier after single-threading so p_traceflag can't change between then
  and this check (well, it can currently due to a bug in ktrace I will fix
  next, but that race existed prior to this change as well).

Reviewed by: rwatson
sys/kern/kern_exit.c
sys/kern/kern_ktrace.c