[RFC] Introduce log ratelimit#620
Conversation
Add rate_limit() and log_*_rl() macros to guard hotpath log calls. A shared BPF_MAP_TYPE_ARRAY holds the last-allowed timestamp and a suppressed-message counter, updated via atomic CAS across all CPUs and probe programs. Due to the lockless design, two CPUs racing at the interval boundary may both pass the check, causing at most one extra message to be emitted per interval. Suppressed counts are reported at shutdown alongside dropped event counters. Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
|
CAS requires v3 instructions support (the patch doesn't have it). Didn't check the actual reason yet (i.e. no full nor partial v3 support) , but clang 14 still seem to crash despite forcing v3. |
|
Did you experience a flooding of eBPF log messages while using Retis? What was causing it? |
It was observed in some reports (e.g. ovs-related, WRT flow enrichment, IIRC). |
|
As discussed offline, a different approach could be used too with |
The idea is to avoid infinite printouts due to recurring error condition (e.g. unexpected corruption).
Requires 5.12 support (mostly for __sync_val_compare_and_swap).
As of today we roughly support 5.8+ (not really verified, only statically inspected). If that really matters, we can have something like a probe program for BPF_ATOMIC | BPF_CMPXCHG and instruct the probes to fall back to the non-ratelimited flavors.