Page MenuHomeFreeBSD

kern: import eventlog(9), a kernel event logging framework
Needs ReviewPublic

Authored by nickbanks_netflix.com on Tue, May 12, 9:25 PM.
Tags
None
Referenced Files
F157289018: D56979.id177714.diff
Wed, May 20, 1:27 AM
F157286724: D56979.id177792.diff
Wed, May 20, 12:57 AM
F157285495: D56979.id.diff
Wed, May 20, 12:42 AM
F157276659: D56979.diff
Tue, May 19, 11:06 PM
F157235315: D56979.diff
Tue, May 19, 1:51 PM
F157235151: D56979.diff
Tue, May 19, 1:49 PM
F157222684: D56979.diff
Tue, May 19, 11:28 AM
F157222681: D56979.diff
Tue, May 19, 11:28 AM
Subscribers

Details

Summary

Add eventlog(9), a subscription-based framework for emitting
structured per-session events from kernel subsystems to userspace
or in-kernel consumers. It has three concepts:

  • Provider: a kernel subsystem that emits events. Multiple providers may share a name (e.g. the default and RACK TCP stacks both register as "tcp"); each gets a unique 16-bit id.
  • Session: an observed entity, e.g. one TCP connection, identified by a provider-defined uint64_t.
  • Subscriber: a consumer of events, either via a per-CPU double-buffered ring exposed through the host-global /dev/eventlog device, or via a synchronous in-kernel callback.

The hot write path enters an smr(9) section, walks subscribers
without locks, and commits with a single atomic_fcmpset_64 on
64-bit targets or a per-pcpu MTX_SPIN on 32-bit targets; NMI
re-entrancy is detected via mtx_owned() to avoid deadlock.

A small DSL in <provider>_eventlog_schema.src files describes
event ids and payload layouts; eventlog_gen.awk processes a
schema into producer or consumer headers.

usr.bin/elog/ ships elog(1), a reference consumer that prints
events as text on stdout or writes a binary .elog stream (-o).
sys/kern/kern_eventlog_test.c implements ktest_eventlog(4) for
ring correctness under concurrent producers and the 32-bit
fallback path; tests/sys/kern/elog_test.py covers elog(1) CLI
smoke tests. Man pages: eventlog(9), elog(1), elog(5).

No in-tree providers ship with this import; downstream consumers
register their schemas and call the emit API directly.

Sponsored by: Netflix

Signed-off-by: Nick Banks <nickbanks@netflix.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73098
Build 69981: arc lint + arc unit

Event Timeline

Hi! We simplified the preferred license template now that SPDX notation has become an ISO standard. Thanks for including nice docs!

Add bin/elog to targets/pseudo/userland/Makefile.depend so DIRDEPS_BUILD also picks up the new userland binary.

Switch newly-introduced files to the simplified BSD-2-Clause template (Copyright + SPDX, no inlined boilerplate) per the licensing-policy doc. Existing files we only modify keep their existing headers untouched.

Add SPDX header to tests/sys/kern/kern_eventlog_test.py (it was previously unmarked).