Skip to content

Commit

Permalink
memcg: fail to create cgroup if the cgroup id is too big
Browse files Browse the repository at this point in the history
memcg requires the cgroup id to be smaller than 65536.

This is a preparation to kill css id.

Signed-off-by: Li Zefan <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
lizf-os authored and htejun committed Sep 24, 2013
1 parent 34c00c3 commit 4219b2d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,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 USHRT_MAX

static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg)
{
/*
Expand Down Expand Up @@ -6059,6 +6065,9 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css));
int error = 0;

if (css->cgroup->id > MEM_CGROUP_ID_MAX)
return -ENOSPC;

if (!parent)
return 0;

Expand Down

0 comments on commit 4219b2d

Please sign in to comment.