From 27eb38ff3e9bf2d4855189b5ea6dd83ee074b8eb Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 24 Jun 2015 09:33:21 +0200 Subject: [PATCH] infra: add total statistics to limiter --- kernel/lib_limiter.c | 7 +++++++ kernel/lib_limiter.h | 2 ++ kernel/sy_old/mars_proc.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/kernel/lib_limiter.c b/kernel/lib_limiter.c index f9273298..65e59fa9 100644 --- a/kernel/lib_limiter.c +++ b/kernel/lib_limiter.c @@ -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. */ diff --git a/kernel/lib_limiter.h b/kernel/lib_limiter.h index 7c6f5c3c..5910ed66 100644 --- a/kernel/lib_limiter.h +++ b/kernel/lib_limiter.h @@ -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; diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index 15a297fe..1c76c95a 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -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), \