Date: Sun, 13 Nov 2005 13:27:44 +0000 (UTC) From: Robert Watson <rwatson@FreeBSD.org> To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/sys/kern init_main.c kern_exit.c kern_fork.c kern_ktrace.c kern_proc.c subr_trap.c src/sys/sys ktrace.h proc.h Message-ID: <200511131327.jADDRiqv047419@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
rwatson 2005-11-13 13:27:44 UTC FreeBSD src repository Modified files: sys/kern init_main.c kern_exit.c kern_fork.c kern_ktrace.c kern_proc.c subr_trap.c sys/sys ktrace.h proc.h Log: 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> Revision Changes Path 1.259 +1 -0 src/sys/kern/init_main.c 1.273 +3 -1 src/sys/kern/kern_exit.c 1.253 +1 -0 src/sys/kern/kern_fork.c 1.104 +191 -91 src/sys/kern/kern_ktrace.c 1.235 +1 -0 src/sys/kern/kern_proc.c 1.283 +4 -0 src/sys/kern/subr_trap.c 1.32 +11 -0 src/sys/sys/ktrace.h 1.443 +1 -0 src/sys/sys/proc.h
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200511131327.jADDRiqv047419>