diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2015-04-15 19:13:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:16 -0400 |
commit | adbe427b92d18cf3f801e82e9cd664fbe31cea3c (patch) | |
tree | e1fe1512cd36f2b7a5a978f473be7dc9d05021fa /kernel | |
parent | d7e4a2ea51c1b0ac0b2d53f5ab4a2e878b1c4aec (diff) |
memcg: zap mem_cgroup_lookup()
mem_cgroup_lookup() is a wrapper around mem_cgroup_from_id(), which
checks that id != 0 before issuing the function call. Today, there is
no point in this additional check apart from optimization, because there
is no css with id <= 0, so that css_from_id, called by
mem_cgroup_from_id, will return NULL for any id <= 0.
Since mem_cgroup_from_id is only called from mem_cgroup_lookup, let us
zap mem_cgroup_lookup, substituting calls to it with mem_cgroup_from_id
and moving the check if id > 0 to css_from_id.
Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index a220fdb66568..59aa339a245c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -5451,7 +5451,7 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry, | |||
5451 | struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss) | 5451 | struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss) |
5452 | { | 5452 | { |
5453 | WARN_ON_ONCE(!rcu_read_lock_held()); | 5453 | WARN_ON_ONCE(!rcu_read_lock_held()); |
5454 | return idr_find(&ss->css_idr, id); | 5454 | return id > 0 ? idr_find(&ss->css_idr, id) : NULL; |
5455 | } | 5455 | } |
5456 | 5456 | ||
5457 | #ifdef CONFIG_CGROUP_DEBUG | 5457 | #ifdef CONFIG_CGROUP_DEBUG |