mirror of
https://github.com/schoebel/mars
synced 2024-12-26 00:22:31 +00:00
infra: add total statistics to limiter
This commit is contained in:
parent
a983bf42de
commit
27eb38ff3e
@ -51,6 +51,13 @@ int mars_limit(struct mars_limiter *lim, int amount)
|
||||
if (unlikely(window < (long long)lim->lim_min_window * (LIMITER_TIME_RESOLUTION / 1000)))
|
||||
window = (long long)lim->lim_min_window * (LIMITER_TIME_RESOLUTION / 1000);
|
||||
|
||||
/* Update total statistics.
|
||||
* They will intentionally wrap around.
|
||||
* Userspace must take care of that.
|
||||
*/
|
||||
lim->lim_total_ops++;
|
||||
lim->lim_total_sum += amount;
|
||||
|
||||
/* Only use incremental accumulation at repeated calls, but
|
||||
* never after longer pauses.
|
||||
*/
|
||||
|
@ -40,6 +40,8 @@ struct mars_limiter {
|
||||
int lim_rate;
|
||||
int lim_cumul;
|
||||
int lim_count;
|
||||
int lim_total_ops;
|
||||
int lim_total_sum;
|
||||
long long lim_stamp;
|
||||
/* internal */
|
||||
long long lim_accu;
|
||||
|
@ -208,6 +208,8 @@ EXPORT_SYMBOL_GPL(mars_max_loadavg);
|
||||
VEC_ENTRY(NAME, VAR, MODE, 1)
|
||||
|
||||
#define LIMITER_ENTRIES(VAR, PREFIX, SUFFIX) \
|
||||
INT_ENTRY(PREFIX "_total_ops_" SUFFIX, (VAR)->lim_total_ops, 0400), \
|
||||
INT_ENTRY(PREFIX "_total_sum_" SUFFIX, (VAR)->lim_total_sum, 0400), \
|
||||
INT_ENTRY(PREFIX "_ratelimit_" SUFFIX, (VAR)->lim_max_rate, 0600), \
|
||||
INT_ENTRY(PREFIX "_maxdelay_ms", (VAR)->lim_max_delay,0600), \
|
||||
INT_ENTRY(PREFIX "_minwindow_ms", (VAR)->lim_min_window,0600), \
|
||||
|
Loading…
Reference in New Issue
Block a user