freebsd-nq/sys
Robert Watson 2c255e9df6 Moderate rewrite of kernel ktrace code to attempt to generally improve
reliability when tracing fast-moving processes or writing traces to
slow file systems by avoiding unbounded queueuing and dropped records.
Record loss was previously possible when the global pool of records
become depleted as a result of record generation outstripping record
commit, which occurred quickly in many common situations.

These changes partially restore the 4.x model of committing ktrace
records at the point of trace generation (synchronous), but maintain
the 5.x deferred record commit behavior (asynchronous) for situations
where entering VFS and sleeping is not possible (i.e., in the
scheduler).  Records are now queued per-process as opposed to
globally, with processes responsible for committing records from their
own context as required.

- Eliminate the ktrace worker thread and global record queue, as they
  are no longer used.  Keep the global free record list, as records
  are still used.

- Add a per-process record queue, which will hold any asynchronously
  generated records, such as from context switches.  This replaces the
  global queue as the place to submit asynchronous records to.

- When a record is committed asynchronously, simply queue it to the
  process.

- When a record is committed synchronously, first drain any pending
  per-process records in order to maintain ordering as best we can.
  Currently ordering between competing threads is provided via a global
  ktrace_sx, but a per-process flag or lock may be desirable in the
  future.

- When a process returns to user space following a system call, trap,
  signal delivery, etc, flush any pending records.

- When a process exits, flush any pending records.

- Assert on process tear-down that there are no pending records.

- Slightly abstract the notion of being "in ktrace", which is used to
  prevent the recursive generation of records, as well as generating
  traces for ktrace events.

Future work here might look at changing the set of events marked for
synchronous and asynchronous record generation, re-balancing queue
depth, timeliness of commit to disk, and so on.  I.e., performing a
drain every (n) records.

MFC after:	1 month
Discussed with:	jhb
Requested by:	Marc Olzheim <marcolz at stack dot nl>
2005-11-13 13:27:44 +00:00
..
alpha In get_pv_entry() use PMAP_LOCK() instead of PMAP_TRYLOCK() when deadlock 2005-11-13 02:17:05 +00:00
amd64 In get_pv_entry() use PMAP_LOCK() instead of PMAP_TRYLOCK() when deadlock 2005-11-13 02:17:05 +00:00
arm There's no need to include <machine/asmacros.h> here. 2005-11-08 13:01:29 +00:00
boot Rename GEOM class kernel module g_md.ko to geom_md.ko for consistency 2005-11-11 11:31:23 +00:00
bsm
cam Make the exploring of all luns supported by an HBA more of a 2005-09-16 01:26:17 +00:00
coda Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
compat - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
conf Add /dev/speaker support to amd64. 2005-11-11 09:57:32 +00:00
contrib - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
crypto Add VIA/ACE "PadLock" support as a crypto(9) driver. 2005-08-18 00:30:22 +00:00
ddb - Rename 'traceall' to 'alltrace' so that the 'tr' shortcut for 'trace' 2005-10-24 15:21:36 +00:00
dev Add some cards: 2005-11-13 13:26:37 +00:00
doc
fs This is a workaround for a complicated issue involving VFS cookies and devfs. 2005-11-09 22:03:50 +00:00
gdb
geom Make the kern.geom.conftxt sysctl more usable by also dumping the 2005-11-12 20:02:02 +00:00
gnu Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
i4b Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
i386 In get_pv_entry() use PMAP_LOCK() instead of PMAP_TRYLOCK() when deadlock 2005-11-13 02:17:05 +00:00
ia64 In get_pv_entry() use PMAP_LOCK() instead of PMAP_TRYLOCK() when deadlock 2005-11-13 02:17:05 +00:00
isa Add support for XBOX to the FreeBSD port. The xbox architecture is 2005-11-09 03:55:40 +00:00
isofs/cd9660 Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
kern Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
libkern Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
modules Rename GEOM class kernel module g_md.ko to geom_md.ko for consistency 2005-11-11 11:31:23 +00:00
net - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
net80211 - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
netatalk - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
netatm - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
netgraph - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
netinet - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
netinet6 Use sparse initializers for "struct domain" and "struct protosw", 2005-11-09 13:29:16 +00:00
netipsec Use sparse initializers for "struct domain" and "struct protosw", 2005-11-09 13:29:16 +00:00
netipx Use sparse initializers for "struct domain" and "struct protosw", 2005-11-09 13:29:16 +00:00
netkey Use sparse initializers for "struct domain" and "struct protosw", 2005-11-09 13:29:16 +00:00
netnatm Use sparse initializers for "struct domain" and "struct protosw", 2005-11-09 13:29:16 +00:00
netncp Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
netsmb Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
nfs Fixes for NFS crashes on architectures that require strict alignment. 2005-07-14 20:08:27 +00:00
nfs4client Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
nfsclient fix a crash when an nfsv2 mount fails 2005-11-10 23:25:16 +00:00
nfsserver Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
opencrypto Fix bogus check. It was possible to panic the kernel by giving 0 length. 2005-08-18 11:58:03 +00:00
pc98 MFi386: Remove obsolete options. 2005-11-09 12:26:37 +00:00
pccard Remove the kernel portion of OLDCARD. I'm working on a replacement 2005-09-25 21:29:32 +00:00
pci - Store pointer to the link-level address right in "struct ifnet" 2005-11-11 16:04:59 +00:00
posix4 Const-qualify ksem_timedwait's parameter abstime as it's only passed in. 2005-10-18 11:46:24 +00:00
powerpc Add definitions for 64-bit PTEs 2005-11-11 12:03:28 +00:00
rpc Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
security Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
sparc64 Uncomment em(4) as it's now working. 2005-11-09 08:49:46 +00:00
sys Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
tools Add convenience macros for bus_space usage that doesn't require specification 2005-09-24 20:11:07 +00:00
ufs Slightly reorganize to reduce duplicated code. 2005-11-07 18:25:23 +00:00
vm Reimplement the reclamation of PV entries. Specifically, perform 2005-11-09 08:19:21 +00:00
Makefile