Skip to content

Commit

Permalink
memcg: let css_get_next() rely upon rcu_read_lock()
Browse files Browse the repository at this point in the history
Remove lock and unlock around css_get_next()'s call to idr_get_next().
memcg iterators (only users of css_get_next) already did rcu_read_lock(),
and its comment demands that; but add a WARN_ON_ONCE to make sure of it.

Signed-off-by: Hugh Dickins <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Li Zefan <[email protected]>
Cc: Eric Dumazet <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hugh Dickins authored and torvalds committed Mar 22, 2012
1 parent 42aee6c commit ca464d6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -5033,17 +5033,16 @@ css_get_next(struct cgroup_subsys *ss, int id,
return NULL;

BUG_ON(!ss->use_id);
WARN_ON_ONCE(!rcu_read_lock_held());

/* fill start point for scan */
tmpid = id;
while (1) {
/*
* scan next entry from bitmap(tree), tmpid is updated after
* idr_get_next().
*/
spin_lock(&ss->id_lock);
tmp = idr_get_next(&ss->idr, &tmpid);
spin_unlock(&ss->id_lock);

if (!tmp)
break;
if (tmp->depth >= depth && tmp->stack[depth] == rootid) {
Expand Down

0 comments on commit ca464d6

Please sign in to comment.