diff options
author | Tejun Heo <tj@kernel.org> | 2014-05-04 15:09:13 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-05-04 15:09:13 -0400 |
commit | 7d699ddb2b181a2c76e5ea18b1bdf102c4bebe4b (patch) | |
tree | 0811810b37ff735921b689aa1ca273ecf253e29c /mm/memcontrol.c | |
parent | 69dfa00ccb72a37f3810687ca110e5a8154c6eed (diff) |
cgroup, memcg: allocate cgroup ID from 1
Currently, cgroup->id is allocated from 0, which is always assigned to
the root cgroup; unfortunately, memcg wants to use ID 0 to indicate
invalid IDs and ends up incrementing all IDs by one.
It's reasonable to reserve 0 for special purposes. This patch updates
cgroup core so that ID 0 is not used and the root cgroups get ID 1.
The ID incrementing is removed form memcg.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 29501f040568..1d0b29715b73 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -527,18 +527,14 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) | |||
527 | 527 | ||
528 | static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) | 528 | static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) |
529 | { | 529 | { |
530 | /* | 530 | return memcg->css.cgroup->id; |
531 | * The ID of the root cgroup is 0, but memcg treat 0 as an | ||
532 | * invalid ID, so we return (cgroup_id + 1). | ||
533 | */ | ||
534 | return memcg->css.cgroup->id + 1; | ||
535 | } | 531 | } |
536 | 532 | ||
537 | static inline struct mem_cgroup *mem_cgroup_from_id(unsigned short id) | 533 | static inline struct mem_cgroup *mem_cgroup_from_id(unsigned short id) |
538 | { | 534 | { |
539 | struct cgroup_subsys_state *css; | 535 | struct cgroup_subsys_state *css; |
540 | 536 | ||
541 | css = css_from_id(id - 1, &memory_cgrp_subsys); | 537 | css = css_from_id(id, &memory_cgrp_subsys); |
542 | return mem_cgroup_from_css(css); | 538 | return mem_cgroup_from_css(css); |
543 | } | 539 | } |
544 | 540 | ||