You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log: full severity/once/throttle API with per-module level control
Expands the logging system from a simple H2K_log() macro into a complete
structured logging API with severity levels, spam control, and build-time
filtering.
## New API (all three build modes: LOGBUF, LOG_PRINTF, silent)
Severity variants:
H2K_log_err/warn/info/dbg(fmt, ...)
H2K_log_string_at(level, S), H2K_log_string_err/warn/info/dbg(S)
Spam control — log once per callsite:
H2K_log_once[_err/warn/info/dbg](...)
H2K_log_once_ht[_err/warn/info/dbg](...) per hardware thread
Spam control — rate limited by PCycle interval:
H2K_log_throttle[_err/warn/info/dbg](interval, ...)
H2K_log_throttle_ht[_err/warn/info/dbg](interval, ...) per hardware thread
All string variants (_string_once, _string_throttle, _ht) follow the same
pattern, giving a full NxM matrix of combinations.
## Log prefix format (same in both LOGBUF and LOG_PRINTF)
[ht<id>][LEVEL][<pcycles>][<file>:<line>] message
## Build-time level filtering
make LOGBUF=1[2] whole kernel, INFO and above only
make LOGBUF=sched[1] sched directory, WARN and above
make LOGBUF=dosched.ref.c[0] single file, ERROR only
make LOGBUF=sched,futex[2] mixed, no level = default (DBG)
The [level] syntax works for both kernel (LOGBUF) and standalone test
(LOG_PRINTF) builds via Makefile.inc.test.
## Implementation notes
- LOGBUF: lockless per-htid ring buffer; spinlock only for Angel flush.
Formatting (emit_prefix + format parse) happens outside the lock.
H2K_log_once uses H2K_atomic_setbit; H2K_log_throttle uses logbuf_lock.
H2K_log_throttle_ht / H2K_log_once_ht are lockless (per-slot ownership).
- LOG_PRINTF: static inline helpers (H2K_printf_now via H2K_get_pcycle_reg,
H2K_printf_basename via strrchr) give full prefix with zero link deps.
H2K_printf_log_once (atomic) and H2K_printf_log_throttle (spinlock) live
in log.ref.c under #ifdef H2K_LOG_PRINTF.
- H2K_log_string now has identical semantics in both modes (full prefix +
level check), replacing the previous puts() shortcut in LOG_PRINTF.
Signed-off-by: Zeev Belinsky <zbelinsk@qti.qualcomm.com>
0 commit comments