Commit 06bb2409 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune Committed by Poul-Henning Kamp

Add the reason for dynamic bounds in param specs

parent 779459ac
...@@ -56,6 +56,8 @@ struct parspec { ...@@ -56,6 +56,8 @@ struct parspec {
const char *def; const char *def;
const char *units; const char *units;
const char *dyn_min_reason;
const char *dyn_max_reason;
char *dyn_min; char *dyn_min;
char *dyn_max; char *dyn_max;
char *dyn_def; char *dyn_def;
...@@ -80,7 +82,8 @@ enum tweak_e { ...@@ -80,7 +82,8 @@ enum tweak_e {
}; };
enum tweak_e tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, enum tweak_e tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest,
const char *arg, const char *min, const char *max); const char *arg, const char *min, const char *max,
const char *min_reason, const char *max_reason);
extern struct parspec mgt_parspec[]; /* mgt_param_tbl.c */ extern struct parspec mgt_parspec[]; /* mgt_param_tbl.c */
extern struct parspec VSL_parspec[]; /* mgt_param_vsl.c */ extern struct parspec VSL_parspec[]; /* mgt_param_vsl.c */
......
...@@ -158,7 +158,8 @@ tweak_bool(struct vsb *vsb, const struct parspec *par, const char *arg) ...@@ -158,7 +158,8 @@ tweak_bool(struct vsb *vsb, const struct parspec *par, const char *arg)
enum tweak_e enum tweak_e
tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg,
const char *min, const char *max) const char *min, const char *max,
const char *min_reason, const char *max_reason)
{ {
unsigned u, minv = 0, maxv = 0; unsigned u, minv = 0, maxv = 0;
char *p; char *p;
...@@ -191,11 +192,17 @@ tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, ...@@ -191,11 +192,17 @@ tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg,
} }
} }
if (min != NULL && u < minv) { if (min != NULL && u < minv) {
VSB_printf(vsb, "Must be at least %s\n", min); VSB_printf(vsb, "Must be at least %s", min);
if (min_reason != NULL)
VSB_printf(vsb, " %s", min_reason);
VSB_putc(vsb, '\n');
return (TWEAK_BELOW_MIN); return (TWEAK_BELOW_MIN);
} }
if (max != NULL && u > maxv) { if (max != NULL && u > maxv) {
VSB_printf(vsb, "Must be no more than %s\n", max); VSB_printf(vsb, "Must be no more than %s", max);
if (max_reason != NULL)
VSB_printf(vsb, " %s", max_reason);
VSB_putc(vsb, '\n');
return (TWEAK_ABOVE_MAX); return (TWEAK_ABOVE_MAX);
} }
*dest = u; *dest = u;
...@@ -215,7 +222,8 @@ tweak_uint(struct vsb *vsb, const struct parspec *par, const char *arg) ...@@ -215,7 +222,8 @@ tweak_uint(struct vsb *vsb, const struct parspec *par, const char *arg)
volatile unsigned *dest; volatile unsigned *dest;
dest = par->priv; dest = par->priv;
return (tweak_generic_uint(vsb, dest, arg, par->min, par->max)); return (tweak_generic_uint(vsb, dest, arg, par->min, par->max,
par->dyn_min_reason, par->dyn_max_reason));
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -415,11 +423,13 @@ tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg) ...@@ -415,11 +423,13 @@ tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg)
} }
px = *pp; px = *pp;
retval = tweak_generic_uint(vsb, &px.min_pool, av[1], retval = tweak_generic_uint(vsb, &px.min_pool, av[1],
par->min, par->max); par->min, par->max, par->dyn_min_reason,
par->dyn_max_reason);
if (retval) if (retval)
break; break;
retval = tweak_generic_uint(vsb, &px.max_pool, av[2], retval = tweak_generic_uint(vsb, &px.max_pool, av[2],
par->min, par->max); par->min, par->max, par->dyn_min_reason,
par->dyn_max_reason);
if (retval) if (retval)
break; break;
retval = tweak_generic_double(vsb, retval = tweak_generic_double(vsb,
......
...@@ -59,7 +59,8 @@ tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par, ...@@ -59,7 +59,8 @@ tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par,
{ {
enum tweak_e tweak; enum tweak_e tweak;
tweak = tweak_generic_uint(vsb, par->priv, arg, par->min, par->max); tweak = tweak_generic_uint(vsb, par->priv, arg, par->min, par->max,
par->dyn_min_reason, par->dyn_max_reason);
if (tweak == TWEAK_OK) { if (tweak == TWEAK_OK) {
MCF_ParamConf(MCF_MINIMUM, "thread_pool_max", MCF_ParamConf(MCF_MINIMUM, "thread_pool_max",
...@@ -69,11 +70,6 @@ tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par, ...@@ -69,11 +70,6 @@ tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par,
return (0); return (0);
} }
if (arg != JSON_FMT && tweak == TWEAK_ABOVE_MAX) {
vsb->s_len--; /* XXX: VSB_trim(vsb, "\n"); instead? */
VSB_cat(vsb, " (thread_pool_max)\n");
}
return (-1); return (-1);
} }
...@@ -83,7 +79,8 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, ...@@ -83,7 +79,8 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par,
{ {
enum tweak_e tweak; enum tweak_e tweak;
tweak = tweak_generic_uint(vsb, par->priv, arg, par->min, par->max); tweak = tweak_generic_uint(vsb, par->priv, arg, par->min, par->max,
par->dyn_min_reason, par->dyn_max_reason);
if (tweak == TWEAK_OK) { if (tweak == TWEAK_OK) {
MCF_ParamConf(MCF_MAXIMUM, "thread_pool_min", MCF_ParamConf(MCF_MAXIMUM, "thread_pool_min",
...@@ -91,29 +88,6 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, ...@@ -91,29 +88,6 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par,
return (0); return (0);
} }
if (arg != JSON_FMT && tweak == TWEAK_BELOW_MIN) {
vsb->s_len--; /* XXX: VSB_trim(vsb, "\n"); instead? */
VSB_cat(vsb, " (thread_pool_min)\n");
}
return (-1);
}
static int
tweak_thread_pool_reserve(struct vsb *vsb, const struct parspec *par,
const char *arg)
{
enum tweak_e tweak;
tweak = tweak_generic_uint(vsb, par->priv, arg, par->min, par->max);
if (tweak == TWEAK_OK)
return (0);
if (arg != JSON_FMT && tweak == TWEAK_ABOVE_MAX) {
vsb->s_len--; /* XXX: VSB_trim(vsb, "\n"); instead? */
VSB_cat(vsb, " (95% of thread_pool_min)\n");
}
return (-1); return (-1);
} }
...@@ -146,7 +120,8 @@ struct parspec WRK_parspec[] = { ...@@ -146,7 +120,8 @@ struct parspec WRK_parspec[] = {
"worker threads soak up RAM and CPU and generally just get " "worker threads soak up RAM and CPU and generally just get "
"in the way of getting work done.", "in the way of getting work done.",
DELAYED_EFFECT, DELAYED_EFFECT,
"5000", "threads" }, "5000", "threads",
"(thread_pool_min)" },
{ "thread_pool_min", tweak_thread_pool_min, &mgt_param.wthread_min, { "thread_pool_min", tweak_thread_pool_min, &mgt_param.wthread_min,
NULL, NULL, NULL, NULL,
"The minimum number of worker threads in each pool. The " "The minimum number of worker threads in each pool. The "
...@@ -157,8 +132,9 @@ struct parspec WRK_parspec[] = { ...@@ -157,8 +132,9 @@ struct parspec WRK_parspec[] = {
"\n" "\n"
"Minimum is 10 threads.", "Minimum is 10 threads.",
DELAYED_EFFECT, DELAYED_EFFECT,
"100", "threads" }, "100", "threads",
{ "thread_pool_reserve", tweak_thread_pool_reserve, NULL, "(thread_pool_max)" },
{ "thread_pool_reserve", tweak_uint,
&mgt_param.wthread_reserve, &mgt_param.wthread_reserve,
NULL, NULL, NULL, NULL,
"The number of worker threads reserved for vital tasks " "The number of worker threads reserved for vital tasks "
...@@ -177,7 +153,8 @@ struct parspec WRK_parspec[] = { ...@@ -177,7 +153,8 @@ struct parspec WRK_parspec[] = {
"Default is 0 to auto-tune (currently 5% of thread_pool_min).\n" "Default is 0 to auto-tune (currently 5% of thread_pool_min).\n"
"Minimum is 1 otherwise, maximum is 95% of thread_pool_min.", "Minimum is 1 otherwise, maximum is 95% of thread_pool_min.",
DELAYED_EFFECT, DELAYED_EFFECT,
"0", "threads" }, "0", "threads",
NULL, "(95% of thread_pool_min)" },
{ "thread_pool_timeout", { "thread_pool_timeout",
tweak_timeout, &mgt_param.wthread_timeout, tweak_timeout, &mgt_param.wthread_timeout,
"10", NULL, "10", NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment