[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130724142751.GI2540@dhcp22.suse.cz>
Date: Wed, 24 Jul 2013 16:27:51 +0200
From: Michal Hocko <mhocko@...e.cz>
To: Li Zefan <lizefan@...wei.com>
Cc: Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Glauber Costa <glommer@...allels.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Johannes Weiner <hannes@...xchg.org>,
LKML <linux-kernel@...r.kernel.org>,
Cgroups <cgroups@...r.kernel.org>, linux-mm@...ck.org
Subject: Re: [PATCH v2 6/8] memcg: fail to create cgroup if the cgroup id is
too big
On Wed 24-07-13 18:02:19, Li Zefan wrote:
> memcg requires the cgroup id to be smaller than 65536.
>
> Signed-off-by: Li Zefan <lizefan@...wei.com>
Acked-by: Michal Hocko <mhocko@...e.cz>
One suggestion bellow
> ---
> mm/memcontrol.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 35d8286..403c8d9 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -512,6 +512,12 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)
> return (memcg == root_mem_cgroup);
> }
>
> +/*
> + * We restrict the id in the range of [1, 65535], so it can fit into
> + * an unsigned short.
> + */
> +#define MEM_CGROUP_ID_MAX (65535)
USHRT_MAX
> +
> static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg)
> {
> /*
> @@ -6243,6 +6249,9 @@ mem_cgroup_css_alloc(struct cgroup *cont)
> long error = -ENOMEM;
> int node;
>
> + if (cont->id > MEM_CGROUP_ID_MAX)
> + return ERR_PTR(-ENOSPC);
> +
> memcg = mem_cgroup_alloc();
> if (!memcg)
> return ERR_PTR(error);
> --
> 1.8.0.2
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@...ck.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@...ck.org"> email@...ck.org </a>
--
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists