From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933050Ab2ASUwE (ORCPT ); Thu, 19 Jan 2012 15:52:04 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:47759 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932718Ab2ASUwB (ORCPT ); Thu, 19 Jan 2012 15:52:01 -0500 Date: Thu, 19 Jan 2012 12:51:47 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Tejun Heo cc: Eric Dumazet , Li Zefan , Andrew Morton , Manfred Spraul , KAMEZAWA Hiroyuki , Johannes Weiner , Ying Han , Greg Thelen , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] memcg: let css_get_next() rely upon rcu_read_lock() In-Reply-To: Message-ID: References: <1326958401.1113.22.camel@edumazet-laptop> <1326979818.2249.12.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: KAMEZAWA Hiroyuki Acked-by: Li Zefan --- kernel/cgroup.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- 3.2.0+.orig/kernel/cgroup.c 2012-01-19 12:16:04.000000000 -0800 +++ 3.2.0+/kernel/cgroup.c 2012-01-19 12:22:55.188244820 -0800 @@ -5087,6 +5087,8 @@ css_get_next(struct cgroup_subsys *ss, i return NULL; BUG_ON(!ss->use_id); + WARN_ON_ONCE(!rcu_read_lock_held()); + /* fill start point for scan */ tmpid = id; while (1) { @@ -5094,10 +5096,7 @@ css_get_next(struct cgroup_subsys *ss, i * 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) {