Re: rate-limited [kernel] debugging messages ?

看板FB_current作者時間13年前 (2012/08/14 05:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
On 14 August 2012 08:56, Luigi Rizzo <rizzo@iet.unipi.it> wrote: > 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. > See ppsratecheck(), it does most of that already. Andrew _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1GAMiE-i (FB_current)
文章代碼(AID): #1GAMiE-i (FB_current)