mirror of
https://github.com/schoebel/mars
synced 2025-02-17 12:37:20 +00:00
infra: make limiter max_delay settable
This commit is contained in:
parent
606528768f
commit
8696e417db
@ -5,6 +5,8 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#define LIMITER_TIME_RESOLUTION NSEC_PER_SEC
|
||||
|
||||
int mars_limit(struct mars_limiter *lim, int amount)
|
||||
{
|
||||
int delay = 0;
|
||||
@ -72,3 +74,16 @@ int mars_limit(struct mars_limiter *lim, int amount)
|
||||
return delay;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_limit);
|
||||
|
||||
void mars_limit_sleep(struct mars_limiter *lim, int amount)
|
||||
{
|
||||
int sleep = mars_limit(lim, amount);
|
||||
if (sleep > 0) {
|
||||
if (unlikely(lim->lim_max_delay <= 0))
|
||||
lim->lim_max_delay = 1000;
|
||||
if (sleep > lim->lim_max_delay)
|
||||
sleep = lim->lim_max_delay;
|
||||
brick_msleep(sleep);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_limit_sleep);
|
||||
|
@ -6,13 +6,12 @@
|
||||
|
||||
#include <linux/utsname.h>
|
||||
|
||||
#define LIMITER_TIME_RESOLUTION NSEC_PER_SEC
|
||||
|
||||
struct mars_limiter {
|
||||
/* hierarchy tree */
|
||||
struct mars_limiter *lim_father;
|
||||
/* tunables */
|
||||
int lim_max_rate;
|
||||
int lim_max_delay;
|
||||
/* readable */
|
||||
int lim_rate;
|
||||
int lim_cumul;
|
||||
@ -23,15 +22,6 @@ struct mars_limiter {
|
||||
|
||||
extern int mars_limit(struct mars_limiter *lim, int amount);
|
||||
|
||||
extern inline
|
||||
void mars_limit_sleep(struct mars_limiter *lim, int amount)
|
||||
{
|
||||
int sleep = mars_limit(lim, amount);
|
||||
if (sleep > 0) {
|
||||
if (sleep > 1000)
|
||||
sleep = 1000;
|
||||
brick_msleep(sleep);
|
||||
}
|
||||
}
|
||||
extern void mars_limit_sleep(struct mars_limiter *lim, int amount);
|
||||
|
||||
#endif
|
||||
|
@ -170,6 +170,7 @@ EXPORT_SYMBOL_GPL(mars_max_loadavg);
|
||||
|
||||
#define LIMITER_ENTRIES(VAR, PREFIX, SUFFIX) \
|
||||
INT_ENTRY(PREFIX "_ratelimit_" SUFFIX, (VAR)->lim_max_rate, 0600), \
|
||||
INT_ENTRY(PREFIX "_maxdelay_ms", (VAR)->lim_max_delay,0600), \
|
||||
INT_ENTRY(PREFIX "_cumul_" SUFFIX, (VAR)->lim_cumul, 0600), \
|
||||
INT_ENTRY(PREFIX "_rate_" SUFFIX, (VAR)->lim_rate, 0400) \
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user