diff options
author | Li Zefan <lizefan@huawei.com> | 2013-09-23 04:56:29 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-09-23 21:44:14 -0400 |
commit | 4219b2da206b3787dea4950ec53ccbc203f50e5e (patch) | |
tree | 84f8a343acee2da6eacc8e5453b7ce102e8f371b | |
parent | 34c00c319ce7eddf79be0cd307acd5630addcbb8 (diff) |
memcg: fail to create cgroup if the cgroup id is too big
memcg requires the cgroup id to be smaller than 65536.
This is a preparation to kill css id.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | mm/memcontrol.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 404a13a09efa..c14039575608 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -488,6 +488,12 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) | |||
488 | return (memcg == root_mem_cgroup); | 488 | return (memcg == root_mem_cgroup); |
489 | } | 489 | } |
490 | 490 | ||
491 | /* | ||
492 | * We restrict the id in the range of [1, 65535], so it can fit into | ||
493 | * an unsigned short. | ||
494 | */ | ||
495 | #define MEM_CGROUP_ID_MAX USHRT_MAX | ||
496 | |||
491 | static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) | 497 | static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) |
492 | { | 498 | { |
493 | /* | 499 | /* |
@@ -6059,6 +6065,9 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) | |||
6059 | struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css)); | 6065 | struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css)); |
6060 | int error = 0; | 6066 | int error = 0; |
6061 | 6067 | ||
6068 | if (css->cgroup->id > MEM_CGROUP_ID_MAX) | ||
6069 | return -ENOSPC; | ||
6070 | |||
6062 | if (!parent) | 6071 | if (!parent) |
6063 | return 0; | 6072 | return 0; |
6064 | 6073 | ||