infra: add total statistics to limiter

This commit is contained in:
Thomas Schoebel-Theuer 2015-06-24 09:33:21 +02:00
parent a983bf42de
commit 27eb38ff3e
3 changed files with 11 additions and 0 deletions

View File

@ -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))) if (unlikely(window < (long long)lim->lim_min_window * (LIMITER_TIME_RESOLUTION / 1000)))
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 /* Only use incremental accumulation at repeated calls, but
* never after longer pauses. * never after longer pauses.
*/ */

View File

@ -40,6 +40,8 @@ struct mars_limiter {
int lim_rate; int lim_rate;
int lim_cumul; int lim_cumul;
int lim_count; int lim_count;
int lim_total_ops;
int lim_total_sum;
long long lim_stamp; long long lim_stamp;
/* internal */ /* internal */
long long lim_accu; long long lim_accu;

View File

@ -208,6 +208,8 @@ EXPORT_SYMBOL_GPL(mars_max_loadavg);
VEC_ENTRY(NAME, VAR, MODE, 1) VEC_ENTRY(NAME, VAR, MODE, 1)
#define LIMITER_ENTRIES(VAR, PREFIX, SUFFIX) \ #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 "_ratelimit_" SUFFIX, (VAR)->lim_max_rate, 0600), \
INT_ENTRY(PREFIX "_maxdelay_ms", (VAR)->lim_max_delay,0600), \ INT_ENTRY(PREFIX "_maxdelay_ms", (VAR)->lim_max_delay,0600), \
INT_ENTRY(PREFIX "_minwindow_ms", (VAR)->lim_min_window,0600), \ INT_ENTRY(PREFIX "_minwindow_ms", (VAR)->lim_min_window,0600), \