Re: [ckrm-tech] [patch 07/38] CKRM e18: Numtasks Controller

Naoaki Maeda
2005-06-28T06:27:22Z

Gerrit Huizenga wrote:

> Index: linux-2.6.12-ckrm1/kernel/fork.c
> ===================================================================
> --- linux-2.6.12-ckrm1.orig/kernel/fork.c 2005-06-20 13:08:27.000000000 -0700
> +++ linux-2.6.12-ckrm1/kernel/fork.c 2005-06-20 13:08:34.000000000 -0700
> @@ -42,6 +42,8 @@
> #include <linux/rmap.h>
> #include <linux/acct.h>
> #include <linux/ckrm_events.h>
> +#include <linux/ckrm_tsk.h>
> +#include <linux/ckrm_tc.h>
>
> #include <asm/pgtable.h>
> #include <asm/pgalloc.h>
> @@ -1211,6 +1213,9 @@ long do_fork(unsigned long clone_flags,
> clone_flags |= CLONE_PTRACE;
> }
>
> + if (numtasks_get_ref(&current->taskclass->core, 0) == 0) {
> + return -ENOMEM;
> + }
> p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid);
> /*
> * Do this prior waking up the new thread - the thread pointer
> @@ -1250,6 +1255,7 @@ long do_fork(unsigned long clone_flags,
> ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);
> }
> } else {
> + numtasks_put_ref(&current->taskclass->core);
> free_pidmap(pid);
> pid = PTR_ERR(p);
> }

Instead of returning -ENOMEM on fork fail due to numtask or forkrate
limit, I'd rather prefer returning -EAGAIN.

Because, according to IEEE Std 1003.1, if fork() fails due to
reaching limit, it shall set the errno to EAGAIN.

Thanks,
MAEDA Naoaki