memcg requires the cgroup id to be smaller than 65536. Signed-off-by: Li Zefan <lizefan@xxxxxxxxxx> --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c4e0173..947dff1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -492,6 +492,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 [0, 65535], so it can fit into + * an unsigned short. + */ +#define MEM_CGROUP_ID_MAX (65535) + static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) { return memcg->css.cgroup->id; @@ -6125,6 +6131,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@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>