Re: [-mm][PATCH 4/4] Add memrlimit controller accounting and control(v4)

From: Pavel Emelyanov
Date: Wed May 14 2008 - 09:41:29 EST


Balbir Singh wrote:
> This patch adds support for accounting and control of virtual address space
> limits. The accounting is done via the rlimit_cgroup_(un)charge_as functions.
> The core of the accounting takes place during fork time in copy_process(),
> may_expand_vm(), remove_vma_list() and exit_mmap(). There are some special
> cases that are handled here as well (arch/ia64/kernel/perform.c,
> arch/x86/kernel/ptrace.c, insert_special_mapping())
>
> Signed-off-by: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx>
> ---
>
> Signed-off-by: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx>
> ---
>
> arch/ia64/kernel/perfmon.c | 6 ++
> arch/x86/kernel/ptrace.c | 17 +++++--
> fs/exec.c | 5 ++
> include/linux/memrlimitcgroup.h | 21 ++++++++
> kernel/fork.c | 8 +++
> mm/memrlimitcgroup.c | 94 ++++++++++++++++++++++++++++++++++++++++
> mm/mmap.c | 11 ++++
> 7 files changed, 157 insertions(+), 5 deletions(-)
>
> diff -puN arch/ia64/kernel/perfmon.c~memrlimit-controller-address-space-accounting-and-control arch/ia64/kernel/perfmon.c
> --- linux-2.6.26-rc2/arch/ia64/kernel/perfmon.c~memrlimit-controller-address-space-accounting-and-control 2008-05-14 18:09:32.000000000 +0530
> +++ linux-2.6.26-rc2-balbir/arch/ia64/kernel/perfmon.c 2008-05-14 18:09:32.000000000 +0530
> @@ -40,6 +40,7 @@
> #include <linux/capability.h>
> #include <linux/rcupdate.h>
> #include <linux/completion.h>
> +#include <linux/memrlimitcgroup.h>
>
> #include <asm/errno.h>
> #include <asm/intrinsics.h>
> @@ -2294,6 +2295,9 @@ pfm_smpl_buffer_alloc(struct task_struct
>
> DPRINT(("sampling buffer rsize=%lu size=%lu bytes\n", rsize, size));
>
> + if (memrlimit_cgroup_charge_as(mm, size >> PAGE_SHIFT))
> + return -ENOMEM;
> +

AFAIS you didn't cover all the cases when VM expands. At least all
the arch/ia64/ia32/binfmt_elf32.c is missed.

I'd insert this charge into insert_vm_struct. This would a) cover
all of the missed cases and b) reduce the amount of places to patch.

[snip the rest of the patch]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/