On Fri, Dec 09, 2016 at 10:56:36AM -0800, Gleb Smirnoff wrote: > Yes, this is expected. The interface isn't designed to be precise. So if > we hit limit, the next second result will be 20345 events exceeded the rate > instead of 20346 events.
Note that the interface may legitimately give errors in the other direction as well, see below. The initial read of cr_ticks is racy, so one thread noting the condition of >= hz and executing counter_u64_zero() might race with another thread not observing the condition and executing counter_u64_add() in parallel. I believe this is possible even on relatively ordered arches like x86. Now, since counter_u64_add() is not atomic for the pcpu cell update (e.g. on x86), increment of the current pcpu cell might race with zeroing it, resulting in the old value of the counter cell to survive the change of ticks second. The end result is that events counted in the previous second would be transferred to the next second despite the reset, and cause unmerited rate check trigger. At very least, the function annotation should contain a warning to use it only for informational messages. _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"