MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ktr_drain

Function ktr_drain

freebsd/kern/kern_ktrace.c:362–384  ·  view source on GitHub ↗

* Drain any pending ktrace records from the per-thread queue to disk. This * is used both internally before committing other records, and also on * system call return. We drain all the ones we can find at the time when * drain is requested, but don't keep draining after that as those events * may be approximately "after" the current event. */

Source from the content-addressed store, hash-verified

360 * may be approximately "after" the current event.
361 */
362static void
363ktr_drain(struct thread *td)
364{
365 struct ktr_request *queued_req;
366 STAILQ_HEAD(, ktr_request) local_queue;
367
368 ktrace_assert(td);
369 sx_assert(&ktrace_sx, SX_XLOCKED);
370
371 STAILQ_INIT(&local_queue);
372
373 if (!STAILQ_EMPTY(&td->td_proc->p_ktr)) {
374 mtx_lock(&ktrace_mtx);
375 STAILQ_CONCAT(&local_queue, &td->td_proc->p_ktr);
376 mtx_unlock(&ktrace_mtx);
377
378 while ((queued_req = STAILQ_FIRST(&local_queue))) {
379 STAILQ_REMOVE_HEAD(&local_queue, ktr_list);
380 ktr_writerequest(td, queued_req);
381 ktr_freerequest(queued_req);
382 }
383 }
384}
385
386/*
387 * Submit a trace record for immediate commit to disk -- to be used only

Callers 3

ktr_submitrequestFunction · 0.85
ktrprocexitFunction · 0.85
ktruserretFunction · 0.85

Calls 5

ktrace_assertFunction · 0.85
ktr_writerequestFunction · 0.85
ktr_freerequestFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected