From owner-cvs-all@FreeBSD.ORG Sun Nov 13 13:27:45 2005 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 37C5B16A41F; Sun, 13 Nov 2005 13:27:45 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF8D943D45; Sun, 13 Nov 2005 13:27:44 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jADDRiP7047420; Sun, 13 Nov 2005 13:27:44 GMT (envelope-from rwatson@repoman.freebsd.org) Received: (from rwatson@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jADDRiqv047419; Sun, 13 Nov 2005 13:27:44 GMT (envelope-from rwatson) Message-Id: <200511131327.jADDRiqv047419@repoman.freebsd.org> From: Robert Watson Date: Sun, 13 Nov 2005 13:27:44 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: 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 X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Nov 2005 13:27:45 -0000 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 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