Hi Maeda-san,
Thanks for the patch. I agree with the approach.
One additional change is needed though...
we need some valid number to work with when the user starts to create
class and assigning shares. Basically, we should prevent the user from
changing shares (from dontcare) of a child class if the total numtasks
is "unlimited".
See below for coding related comments.
On Thu, 2005-06-30 at 17:50 +0900, MAEDA Naoaki wrote:
> Hi Gerrit,
>
> This patch changes the default value of sys_total_tasks and forkrate
> to unlimited, and forkrate_interval to 1 second in order to nullify
> the numtask controller by default.
>
> This patch also lets the numtask accept the keyword of "unlimited" for
> sys_total_tasks and forkrate.
>
> Signed-Off-By: Maeda Naoaki <[EMAIL PROTECTED]>
> ---
>
> linux-2.6.12-ckrm-e18-maeda/kernel/ckrm/ckrm_numtasks.c | 77
> +++++++++++-----
> 1 files changed, 53 insertions(+), 24 deletions(-)
>
> diff -puN kernel/ckrm/ckrm_numtasks.c~default_numtask_disable
> kernel/ckrm/ckrm_numtasks.c
> --- linux-2.6.12-ckrm-e18/kernel/ckrm/ckrm_numtasks.c~default_numtask_disable
> 2005-06-30 12:58:03.000000000 +0900
> +++ linux-2.6.12-ckrm-e18-maeda/kernel/ckrm/ckrm_numtasks.c 2005-06-30
> 16:31:52.000000000 +0900
> @@ -27,7 +27,8 @@
> #include <linux/ckrm_tc.h>
> #include <linux/ckrm_tsk.h>
>
> -#define DEF_TOTAL_NUM_TASKS (131072) /* 128 K */
> +#define UNLIMITED INT_MAX
> +#define DEF_TOTAL_NUM_TASKS UNLIMITED
> static int total_numtasks = DEF_TOTAL_NUM_TASKS;
> static int total_cnt_alloc = 0;
>
> @@ -36,8 +37,8 @@ static int total_cnt_alloc = 0;
> #define NUMTASKS_DEBUG
> #define NUMTASKS_NAME "numtasks"
>
> -#define DEF_FORKRATE (1000000) /* 1 million tasks */
> -#define DEF_FORKRATE_INTERVAL (3600) /* per hour */
> +#define DEF_FORKRATE UNLIMITED
> +#define DEF_FORKRATE_INTERVAL (1) /* per second */
> #define FORKRATE "forkrate"
> #define FORKRATE_INTERVAL "forkrate_interval"
>
> @@ -464,10 +465,20 @@ static int numtasks_show_config(void *my
>
> if (!res)
> return -EINVAL;
> - seq_printf(sfile, "res=%s,%s=%d,%s=%d,%s=%d\n", NUMTASKS_NAME,
> - SYS_TOTAL_TASKS, total_numtasks,
> - FORKRATE, forkrate,
> - FORKRATE_INTERVAL, forkrate_interval);
> + if (total_numtasks == UNLIMITED) {
> + seq_printf(sfile, "res=%s,%s=%s,", NUMTASKS_NAME,
> + SYS_TOTAL_TASKS, "unlimited");
> + } else {
> + seq_printf(sfile, "res=%s,%s=%d,", NUMTASKS_NAME,
> + SYS_TOTAL_TASKS, total_numtasks);
> + }
> + if (forkrate == UNLIMITED) {
> + seq_printf(sfile, "%s=%s,%s=%d\n", FORKRATE, "unlimited",
> + FORKRATE_INTERVAL, forkrate_interval);
> + } else {
> + seq_printf(sfile, "%s=%d,%s=%d\n", FORKRATE, forkrate,
> + FORKRATE_INTERVAL, forkrate_interval);
> + }
> return 0;
> }
>
> @@ -479,8 +490,8 @@ enum numtasks_token_t {
> };
>
> static match_table_t numtasks_tokens = {
> - {numtasks_token_total, SYS_TOTAL_TASKS "=%d"},
> - {numtasks_token_forkrate, FORKRATE "=%d"},
> + {numtasks_token_total, SYS_TOTAL_TASKS "=%s"},
> + {numtasks_token_forkrate, FORKRATE "=%s"},
> {numtasks_token_interval, FORKRATE_INTERVAL "=%d"},
> {numtasks_token_err, NULL},
> };
> @@ -518,35 +529,53 @@ static int numtasks_set_config(void *my_
> while ((p = strsep((char**)&cfgstr, ",")) != NULL) {
> substring_t args[MAX_OPT_ARGS];
> int token;
> + char *s;
> if (!*p)
> continue;
>
> token = match_token(p, numtasks_tokens, args);
> switch (token) {
> case numtasks_token_total:
> - if (match_int(args, &new_total) ||
> - (new_total < total_cnt_alloc)) {
> + if ((s = match_strdup(args)) == NULL) {
> err = -EINVAL;
shouldn't we return -ENOMEM ?
> - } else {
> + break;
> + }
> + new_total = simple_strtol(s, NULL, 0);
one problem we had with strtol is that it behaves badly when the given
number overflows int. Matt Helsley posted a patch (for strtol usage in
order in rbce) a while ago. Have a look at the patch and see this code
follows the logic there.
> + if (strcmp(s, "unlimited") == 0) {
> + total_numtasks = UNLIMITED;
> + } else if (new_total > total_cnt_alloc) {
> total_numtasks = new_total;
> - /*
> - * res is the default class, as config is
> - * present only in that directory.
> - */
> - spin_lock(&res->cnt_lock);
> - res->cnt_guarantee = total_numtasks;
> - res->cnt_unused = total_numtasks;
> - res->cnt_limit = total_numtasks;
> - recalc_and_propagate(res, NULL);
> - spin_unlock(&res->cnt_lock);
> + } else {
> + err = -EINVAL;
> + kfree(s);
> + break;
> }
> + /*
> + * res is the default class, as config is
> + * present only in that directory.
> + */
> + spin_lock(&res->cnt_lock);
> + res->cnt_guarantee = total_numtasks;
> + res->cnt_unused = total_numtasks;
> + res->cnt_limit = total_numtasks;
> + recalc_and_propagate(res, NULL);
> + spin_unlock(&res->cnt_lock);
> + kfree(s);
> break;
> case numtasks_token_forkrate:
> - if (match_int(args, &fr) || (fr <= 0)) {
> + if ((s = match_strdup(args)) == NULL) {
> err = -EINVAL;
> - } else {
> + break;
> + }
> + fr = simple_strtol(s, NULL, 0);
> + if (strcmp(s, "unlimited") == 0) {
> + forkrate = UNLIMITED;
> + } else if (fr > 0) {
> forkrate = fr;
> + } else {
> + err = -EINVAL;
> }
> + kfree(s);
> break;
> case numtasks_token_interval:
> if (match_int(args, &itvl) || (itvl <= 0)) {
> _
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> ckrm-tech mailing list
> https://lists.sourceforge.net/lists/listinfo/ckrm-tech
--
----------------------------------------------------------------------
Chandra Seetharaman | Be careful what you choose....
- [EMAIL PROTECTED] | .......you may get it.
----------------------------------------------------------------------
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech