BUG/MEDIUM: freq-ctr: Don't report overshoot for long inactivity period
The function returning the excess of events over the current period for a target frequency (the overshoot) has a flaw if the inactivity period is too long. In this case, the result may overflow. Instead to be negative, a very high positive value is returned. This function is used by the bandwidth limitation filter. It means after a long inactivity period, a huge burst may be detected while it should not. In fact, the problem arise from the moment we're past the current period. In this case, we should not report any overshoot and just get the number of remaining events as usual. This patch should be backported as far as 2.7.
This commit is contained in:
parent
2c9c2f9d77
commit
5705a6e3b7
@ -155,7 +155,7 @@ ullong freq_ctr_total(const struct freq_ctr *ctr, uint period, int pend)
|
||||
*/
|
||||
int freq_ctr_overshoot_period(const struct freq_ctr *ctr, uint period, uint freq)
|
||||
{
|
||||
uint curr, old_curr;
|
||||
ullong curr, old_curr;
|
||||
uint tick, old_tick;
|
||||
int elapsed;
|
||||
|
||||
@ -202,8 +202,8 @@ int freq_ctr_overshoot_period(const struct freq_ctr *ctr, uint period, uint freq
|
||||
}
|
||||
|
||||
elapsed = HA_ATOMIC_LOAD(&global_now_ms) - tick;
|
||||
if (unlikely(elapsed < 0)) {
|
||||
/* The counter is in the future, there is no overshoot */
|
||||
if (unlikely(elapsed < 0 || elapsed > period)) {
|
||||
/* The counter is in the future or the elapsed time is higher than the period, there is no overshoot */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user