rate-limited [kernel] debugging messages ?
Luigi Rizzo
rizzo at iet.unipi.it
Mon Aug 13 20:37:29 UTC 2012
In my kernel stuff i tend to define debugging macros of the form
#define ND(format, ...) do {} while (0)
#define D(format, ...) do { <some useful stuff> } while (0)
so it is convenient to comment them out when not needed anymore.
I have recently tried the following rate-limited version, where the
first parameter indicates how many lines per second are output at most
/* rate limited, lps indicates how many per second */
#define RD(lps, format, ...) \
do { \
static int t0, cnt; \
if (t0 != time_second) { \
t0 = time_second; \
cnt = 0; \
} \
if (cnt++ < lps) \
D(format, ##__VA_ARGS__); \
} while (0)
I was wondering if people have better suggestions or perhaps there
are already similar macros used by other parts of the kernel.
cheers
luigi
More information about the freebsd-current
mailing list