From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) by kanga.kvack.org (Postfix) with ESMTP id E0E6C6B0031 for ; Tue, 14 Jan 2014 08:30:06 -0500 (EST) Received: by mail-ee0-f41.google.com with SMTP id e49so224593eek.0 for ; Tue, 14 Jan 2014 05:30:06 -0800 (PST) Received: from mx2.suse.de (cantor2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id d46si1087500eeo.186.2014.01.14.05.30.05 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 14 Jan 2014 05:30:05 -0800 (PST) Date: Tue, 14 Jan 2014 14:30:05 +0100 From: Michal Hocko Subject: Re: [PATCH 3/3] mm/memcg: iteration skip memcgs not yet fully initialized Message-ID: <20140114133005.GC32227@dhcp22.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Hugh Dickins , Tejun Heo Cc: Johannes Weiner , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Mon 13-01-14 17:54:04, Hugh Dickins wrote: > It is surprising that the mem_cgroup iterator can return memcgs which > have not yet been fully initialized. By accident (or trial and error?) > this appears not to present an actual problem; but it may be better to > prevent such surprises, by skipping memcgs not yet online. My understanding was that !online cgroups are not visible for the iterator. it is css_online that has to be called before they are made visible. Tejun? > Signed-off-by: Hugh Dickins > --- > Decide for yourself whether to take this or not. I spent quite a while > digging into a mysterious "trying to register non-static key" issue from > lockdep, which originated from the iterator returning a vmalloc'ed memcg > a moment before the res_counter_init()s had done their spin_lock_init()s. > But the backtrace was an odd one of our own mis-devising, not a charge or > reclaim or stats trace, so probably it's never been a problem for vanilla. > > mm/memcontrol.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > --- mmotm/mm/memcontrol.c 2014-01-10 18:25:02.236448954 -0800 > +++ linux/mm/memcontrol.c 2014-01-12 22:21:10.700570471 -0800 > @@ -1119,10 +1119,8 @@ skip_node: > * protected by css_get and the tree walk is rcu safe. > */ > if (next_css) { > - struct mem_cgroup *mem = mem_cgroup_from_css(next_css); > - > - if (css_tryget(&mem->css)) > - return mem; > + if ((next_css->flags & CSS_ONLINE) && css_tryget(next_css)) > + return mem_cgroup_from_css(next_css); > else { > prev_css = next_css; > goto skip_node; -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org