freebsd-nq/sys/kern
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
..
bus_if.m /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
clock_if.m /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
cpufreq_if.m Introduce a new method, cpufreq_drv_type(), that returns the type of the 2005-02-18 00:23:36 +00:00
device_if.m /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
genassym.sh
imgact_aout.c - Neither of our image formats require Giant now that the vm and vfs have 2005-05-03 10:51:38 +00:00
imgact_elf32.c
imgact_elf64.c
imgact_elf.c Back out alpha/alpha/trap.c:1.124, osf1_ioctl.c:1.14, osf1_misc.c:1.57, 2005-09-28 07:03:03 +00:00
imgact_gzip.c - Change the vm_mmap() function to accept an objtype_t parameter specifying 2005-04-01 20:00:11 +00:00
imgact_shell.c Fix a panic which could occur parsing #!-lines in a shell-script. If the 2005-06-19 02:21:03 +00:00
inflate.c Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
init_main.c Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
init_sysent.c Regen. 2005-10-30 02:14:37 +00:00
kern_acct.c Significant refactoring of the accounting code to improve locking and VFS 2005-11-12 10:45:13 +00:00
kern_acl.c Implement new world order in VFS locking for ACLs. This will remove the 2005-09-17 22:01:14 +00:00
kern_alq.c Modify the alq(9) alq_open() API to accept a file creation mode, rather 2005-04-16 12:12:27 +00:00
kern_clock.c In watchdog_config enable the software watchdog iff the WD_ACTIVE flag is 2005-10-27 17:22:47 +00:00
kern_condvar.c Refine the turnstile and sleep queue interfaces just a bit: 2004-10-12 18:36:20 +00:00
kern_conf.c Move the initialization of the devmtx into the mutex_init() function 2005-10-18 18:27:44 +00:00
kern_context.c
kern_cpu.c make saved cpu level stackable. 2005-10-03 06:57:29 +00:00
kern_descrip.c Add the f_msgcount field to the set of struct file fields printed in show 2005-11-10 13:26:29 +00:00
kern_environment.c Reorder statements to avoid accessing unknown memory. 2005-09-26 14:14:55 +00:00
kern_event.c Add in kqueue support to LIO event notification and fix how it handled 2005-10-12 17:51:31 +00:00
kern_exec.c Cleanup some signal interfaces. Now the tdsignal function accepts 2005-11-03 04:49:16 +00:00
kern_exit.c Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
kern_fork.c Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
kern_idle.c Divorce critical sections from spinlocks. Critical sections as denoted by 2005-04-04 21:53:56 +00:00
kern_intr.c Add a swi_remove() function to teardown software interrupt handlers. For 2005-10-26 15:51:05 +00:00
kern_jail.c Push Giant down in jails. Pass the MPSAFE flag to NDINIT, and keep track 2005-09-28 00:30:56 +00:00
kern_kse.c Cleanup some signal interfaces. Now the tdsignal function accepts 2005-11-03 04:49:16 +00:00
kern_kthread.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
kern_ktr.c - Add curthread to the state that ktr is saving. The extra information is 2005-06-10 23:21:29 +00:00
kern_ktrace.c Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
kern_linker.c Fix a bug in the kernel module runtime linker that made it impossible 2005-10-19 20:40:30 +00:00
kern_lock.c Include kdb.h so that kdb_active is declared regardless of KDB being 2005-10-02 10:03:51 +00:00
kern_lockf.c Print name of device instead of useless major/minor numbers. 2005-03-29 08:13:01 +00:00
kern_mac.c Standard Giant push down operations for the Mandatory Access Control (MAC) 2005-10-04 14:32:58 +00:00
kern_malloc.c Detect memory leaks when memory type is being destroyed. 2005-11-03 13:48:59 +00:00
kern_mbuf.c Fix panic string in last revision. 2005-11-06 16:47:59 +00:00
kern_mib.c mp_ncpus is always (properly) initialized, even on UP kernels, so just use it. 2005-08-21 18:03:31 +00:00
kern_module.c Swap the arguments for CP so we copy the correct source and 2005-02-18 22:14:40 +00:00
kern_mtxpool.c Make a bunch of malloc types static. 2005-02-10 12:02:37 +00:00
kern_mutex.c Move the initialization of the devmtx into the mutex_init() function 2005-10-18 18:27:44 +00:00
kern_ntptime.c Explicitly acquire Giant around the ntp_gettime() and assert it in the 2005-05-28 14:34:41 +00:00
kern_physio.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
kern_pmc.c Fail the module loading process if the currently executing kernel 2005-07-30 09:02:42 +00:00
kern_poll.c - Don't pollute opt_global.h with DEVICE_POLLING and introduce 2005-10-05 10:09:17 +00:00
kern_proc.c Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
kern_prot.c Use the refcount API to manage the reference count for user credentials 2005-09-27 18:09:42 +00:00
kern_resource.c Calling setrlimit from 32bit apps could potentially increase certain 2005-11-02 21:18:07 +00:00
kern_sema.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
kern_shutdown.c Don't pretend to be thread0 when calling sync(). 2005-09-22 15:34:15 +00:00
kern_sig.c Make sure only remove one signal by debugger. 2005-11-12 04:22:16 +00:00
kern_subr.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
kern_switch.c In adjustrunqueue(), add code to handle thread migrating case for 2005-08-03 01:23:45 +00:00
kern_sx.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
kern_synch.c Use low level constructs borrowed from interrupt threads to wait for 2005-05-23 23:01:53 +00:00
kern_syscalls.c
kern_sysctl.c Drop in a WITNESS_WARN into SYSCTL_IN to make sure that we are 2005-08-08 21:06:42 +00:00
kern_tc.c Start time_uptime with 1 instead of 0. 2005-09-19 22:16:31 +00:00
kern_thr.c Cleanup some signal interfaces. Now the tdsignal function accepts 2005-11-03 04:49:16 +00:00
kern_thread.c Add support for queueing SIGCHLD same as other UNIX systems did. 2005-11-08 09:09:26 +00:00
kern_time.c Fix name compatible problem with POSIX standard. the sigval_ptr and 2005-11-04 09:41:00 +00:00
kern_timeout.c Oops, missed adding the required include. 2005-09-15 20:20:36 +00:00
kern_umtx.c do umtx_wake at userland thread exit address, so that others userland 2005-10-26 06:55:46 +00:00
kern_uuid.c Add parse_uuid() that creates a binary representation of an UUID from 2005-10-07 13:37:10 +00:00
kern_xxx.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
ksched.c /* -> /*- for license, minor formatting changes 2005-01-07 02:29:27 +00:00
link_elf_obj.c Handle vm_map_wire()'s failure. 2005-08-28 05:38:40 +00:00
link_elf.c Check to see if the hash table is present in link_elf_lookup_symbol() 2005-10-31 19:17:32 +00:00
linker_if.m /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
Make.tags.inc
Makefile Add a 'sysent' target that depends on the various files built from 2005-07-13 20:50:17 +00:00
makesyscalls.sh Introduce a new field in the syscalls.master file format to hold the 2005-05-30 15:09:18 +00:00
md4c.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
md5c.c MD5Pad() should never have been exposed. 2005-02-10 12:20:42 +00:00
p1003_1b.c Actually commit the code for kern_sched_get_rr_interval(). 2005-03-31 22:54:48 +00:00
posix4_mib.c Back when VOP_* was introduced, we did not have new-style struct 2004-12-01 23:16:38 +00:00
sched_4bsd.c Move HWPMC_HOOKS into its own opt_hwpmc_hooks.h file. It doesn't merit 2005-06-24 00:16:57 +00:00
sched_ule.c Temporarily disable nice threshold detection code, as it can starve 2005-09-22 01:19:37 +00:00
subr_acl_posix1e.c Implement new world order in VFS locking for ACLs. This will remove the 2005-09-17 22:01:14 +00:00
subr_autoconf.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
subr_blist.c
subr_bus.c When data passed into devctl_notify is NULL, don't print (null). Instead 2005-10-04 22:25:14 +00:00
subr_clist.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
subr_clock.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
subr_devstat.c - Remove two mtx_asserts that can incorrectly trigger if 2005-05-03 10:58:05 +00:00
subr_disk.c - Fix insertions of bios which represent data earlier than anything else 2005-06-15 23:32:07 +00:00
subr_eventhandler.c eliminate potential null deref 2005-02-23 19:32:29 +00:00
subr_hints.c The resource_xxx routines in subr_hints.c are called before and after the 2005-07-31 10:46:55 +00:00
subr_kdb.c Add stoppcbs[] arrays on Alpha and sparc64 and have each CPU save its 2005-11-03 21:08:20 +00:00
subr_kobj.c Export a routine, kobj_machdep_init(), that allows platforms 2005-08-07 02:20:35 +00:00
subr_log.c Use dynamic major number allocation. 2005-02-27 22:02:03 +00:00
subr_mbpool.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
subr_mchain.c Change API of mb_copy_t in libmchain so that netsmb can handle 2005-07-29 13:22:37 +00:00
subr_module.c
subr_msgbuf.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
subr_param.c Partially revert revision 1.66, which contained a change that did not 2005-10-14 19:15:10 +00:00
subr_pcpu.c Fix 'show allpcpu' ddb command on non-x86. CPU IDs are in the range 0 .. 2005-11-03 21:06:29 +00:00
subr_power.c General consensus is that it would be even better to run this in a 2005-11-09 16:22:56 +00:00
subr_prf.c Acquire Giant in uprintf() and tprintf() rather than asserting it. In 2005-09-26 08:02:24 +00:00
subr_prof.c netchild's mega-patch to isolate compiler dependencies into a central 2005-03-02 21:33:29 +00:00
subr_rman.c Eliminate __RMAN_RESOURCE_VISIBLE hack entirely by moving the struct 2005-10-06 21:49:31 +00:00
subr_rtc.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
subr_sbuf.c Make a bunch of malloc types static. 2005-02-10 12:02:37 +00:00
subr_scanf.c
subr_sleepqueue.c Clarify panic message, I parsed the old one 'trying to sleep while sleeping' 2005-11-09 07:28:52 +00:00
subr_smp.c Rename the KDB_STOP_NMI kernel option to STOP_NMI and make it apply to all 2005-10-24 21:04:19 +00:00
subr_stack.c Add 'depth' argument to CTRSTACK() macro, which allows to reduce number 2005-08-29 11:34:08 +00:00
subr_taskqueue.c Use shorter names for the Giant and fast taskqueues so that their names 2005-10-25 19:29:02 +00:00
subr_trap.c Moderate rewrite of kernel ktrace code to attempt to generally improve 2005-11-13 13:27:44 +00:00
subr_turnstile.c Trim a couple of unneeded includes. 2005-09-29 19:13:52 +00:00
subr_unit.c Remove debugging printfs. 2005-03-14 06:51:29 +00:00
subr_witness.c Reorganize the interrupt handling code a bit to make a few things cleaner 2005-10-25 19:48:48 +00:00
sys_generic.c - Add two new system calls: preadv() and pwritev() which are like readv() 2005-07-07 18:17:55 +00:00
sys_pipe.c Fix the recent panics/LORs/hangs created by my kqueue commit by: 2005-07-01 16:28:32 +00:00
sys_process.c Make sure pending SIGCHLD is removed from previous parent when process 2005-11-08 23:28:12 +00:00
sys_socket.c Introduce three additional MAC Framework and MAC Policy entry points to 2005-04-16 18:46:29 +00:00
syscalls.c Regen. 2005-10-30 02:14:37 +00:00
syscalls.master Fix sigevent's POSIX incompatible problem by adding member fields 2005-10-30 02:12:49 +00:00
sysv_ipc.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
sysv_msg.c Add much needed descriptions for a number of the IPC related sysctl OIDs. 2005-02-12 01:22:39 +00:00
sysv_sem.c Gratuitous renaming of four System V Semaphore MAC Framework entry 2005-06-07 05:03:28 +00:00
sysv_shm.c Re-order MAC and DAC checks in shmget() in order to give precedence to 2005-10-04 16:40:20 +00:00
tty_compat.c Make ttsetcompat() static 2005-10-16 20:40:40 +00:00
tty_conf.c Preparation commit for the tty cleanups that will follow in the near 2004-07-15 20:47:41 +00:00
tty_cons.c Use dynamic major number allocation for /dev/console, there is no 2005-02-27 21:52:42 +00:00
tty_pty.c Merge the dev_clone and dev_clone_cred event handlers into a single 2005-08-08 19:55:32 +00:00
tty_subr.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
tty_tty.c Merge the dev_clone and dev_clone_cred event handlers into a single 2005-08-08 19:55:32 +00:00
tty.c Revert most of revision 1.235 and fix the problem a different way. We 2005-10-27 16:47:28 +00:00
uipc_accf.c o setsockopt(2) cannot remove accept filter. [1] 2005-06-11 11:59:48 +00:00
uipc_cow.c Previously, nothing prevented the page that was returned by pmap_extract() 2005-10-23 07:41:56 +00:00
uipc_domain.c /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-06 23:35:40 +00:00
uipc_mbuf2.c Define four constants, MBUF_{,MEM,CLUSTER,PACKET,TAG}_MEM_NAME, which 2005-07-17 14:04:03 +00:00
uipc_mbuf.c Free only those mbuf+clusters back to the packet zone that were allocated 2005-11-05 19:43:55 +00:00
uipc_proto.c Use sparse initializers for "struct domain" and "struct protosw", 2005-11-09 13:29:16 +00:00
uipc_sem.c Const-qualify ksem_timedwait's parameter abstime as it's only passed in. 2005-10-18 11:46:24 +00:00
uipc_sockbuf.c Retire MT_HEADER mbuf type and change its users to use MT_DATA. 2005-11-02 13:46:32 +00:00
uipc_socket2.c Retire MT_HEADER mbuf type and change its users to use MT_DATA. 2005-11-02 13:46:32 +00:00
uipc_socket.c Retire MT_HEADER mbuf type and change its users to use MT_DATA. 2005-11-02 13:46:32 +00:00
uipc_syscalls.c Reformat socket control messages on input/output for 32bit compatibility 2005-10-31 21:09:56 +00:00
uipc_usrreq.c Correct a number of serious and closely related bugs in the UNIX domain 2005-11-10 16:06:04 +00:00
vfs_acl.c Implement new world order in VFS locking for ACLs. This will remove the 2005-09-17 22:01:14 +00:00
vfs_aio.c In aio_waitcomplete, do not return EAGAIN if no other threads 2005-11-08 23:48:32 +00:00
vfs_bio.c Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
vfs_cache.c - Fix a leaked reference to a vnode via v_dd. We rely on cache_purge() and 2005-06-17 01:05:13 +00:00
vfs_cluster.c Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
vfs_default.c In vop_stdpathconf(ap) also default for _PC_NAME_MAX and _PC_PATH_MAX. 2005-08-17 06:59:23 +00:00
vfs_export.c Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
vfs_extattr.c Implement new world order in VFS locking for extended attributes. This will 2005-09-24 23:47:04 +00:00
vfs_hash.c Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
vfs_init.c Remove VFS_START(). Its original purpose involved the mfs filesystem, 2005-02-20 23:02:20 +00:00
vfs_lookup.c Use correct VFS locking rather than unconditionally grabbing Giant around 2005-09-21 19:49:42 +00:00
vfs_mount.c style(9) cleanups. 2005-11-12 14:41:44 +00:00
vfs_subr.c This is a workaround for a complicated issue involving VFS cookies and devfs. 2005-11-09 22:03:50 +00:00
vfs_syscalls.c Implement new world order in VFS locking for extended attributes. This will 2005-09-24 23:47:04 +00:00
vfs_vnops.c - Replace the series of DEBUG_LOCKS hacks which tried to save the vn_lock 2005-08-03 04:48:22 +00:00
vnode_if.src Allow EVFILT_VNODE events to work on every filesystem type, not just 2005-06-09 20:20:31 +00:00