diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-11-13 13:27:44 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-11-13 13:27:44 +0000 |
commit | 2a5785fb21c6ea3960931f272675b9ca8d9465e5 (patch) | |
tree | 0f57840afee554649dce42afc8512db3f710ec51 /sys/kern/init_main.c | |
parent | beb83bd5bc1f61576bc9a66d64a9fdac433efb0b (diff) | |
download | FreeBSD-src-2a5785fb21c6ea3960931f272675b9ca8d9465e5.zip FreeBSD-src-2a5785fb21c6ea3960931f272675b9ca8d9465e5.tar.gz |
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>
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r-- | sys/kern/init_main.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 7e2396d..837b066 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -369,6 +369,7 @@ proc0_init(void *dummy __unused) p->p_sflag = PS_INMEM; p->p_state = PRS_NORMAL; knlist_init(&p->p_klist, &p->p_mtx, NULL, NULL, NULL); + STAILQ_INIT(&p->p_ktr); p->p_nice = NZERO; td->td_state = TDS_RUNNING; kg->kg_pri_class = PRI_TIMESHARE; |