Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
dyndbg: add print-once and print-ratelimited features. RFC.
Expand ddebug.flags to 11 bits, and define new flags to support pr_debug_once() and pr_debug_ratelimited() semantics: echo module main +o > control # init/main runs once anyway echo module foo +r > control # turn on ratelimiting echo module foo +g > control # turn on group flag Test these conditions in new is_onced_or_ratelimited(), and call it from __dynamic_pr_debug and others. print-once: can be done with just 2 bits in flags; .o _DPRINTK_FLAGS_ONCE enables state test and set .P _DPRINTK_FLAGS_PRINTED state bit Just adding the flags lets the existing code operate them. We will need new code to enforce constraints on flag combos; '+ro' is nonsense, but this can wait, or can take a new meaning. is_onced_or_ratelimited() should be correct for +o, and should be testable now. tbd. rate-limiting: .r _DPRINTK_FLAGS_RATELIMITED - track & limit prdbgs callrate Wewait until a prdebug is called, and if RATELIMITED is set, THEN lookup a RateLimitState (RL) for it. If found, bump its state and return true/false, otherwise create & initialize one and return false. group-flag: RFC .g _DPRINTK_FLAGS_GROUPED Currently, the hash-key is just the prdebug descriptor, so is unique per prdebug. With the 'g' flag, we could use a different key, for example desc->site.function, to get a shared ratelimit for whole functions. This gets subtly different behavior at the ratelimit transition, but it is predictable for a given function (except perhaps recursive, but thats not done anyway). Note also that any function can have a single group of prdebugs, plus any number of prdbgs without 'g', either with or without 'r'. So grouping should be flexible enough to use advantageously. Notes: - runtime mechanisms can be hidden (by not handling '+org' > control) - exposed only thru api flags (not done, probably just another param to DEFINE_DYANMIC_DEBUG_METADATA) TLDR: older key thinking That lookup is basically a hash, with 2 part key: . &builtin-vector-base OR &module or the hash(s) could hang off the header struct . ._back OR ._map chosen by _DPRINTK_FLAGS_GROUPED choice dictates per-site OR sharing across function
- Loading branch information