Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752396Ab0DVWFM (ORCPT ); Thu, 22 Apr 2010 18:05:12 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:34304 "EHLO e6.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752292Ab0DVWFI (ORCPT ); Thu, 22 Apr 2010 18:05:08 -0400 Date: Thu, 22 Apr 2010 15:05:04 -0700 From: "Paul E. McKenney" To: Matt Helsley Cc: Peter Zijlstra , Li Zefan , Andrew Morton , LKML , "containers@lists.osdl.org" , Paul Menage , Ingo Molnar Subject: Re: [PATCH 3/5] sched: Fix an RCU warning in print_task() Message-ID: <20100422220504.GP2524@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <4BD016F4.8060108@cn.fujitsu.com> <4BD01740.7050805@cn.fujitsu.com> <1271931604.1776.337.camel@laptop> <20100422211212.GA32490@count0.beaverton.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100422211212.GA32490@count0.beaverton.ibm.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2492 Lines: 59 On Thu, Apr 22, 2010 at 02:12:12PM -0700, Matt Helsley wrote: > On Thu, Apr 22, 2010 at 12:20:04PM +0200, Peter Zijlstra wrote: > > > > > You can also pin a cgroup by holding whatever locks are held in the > > ->attach method. But the RCU annotation doesn't know (nor reasonably can > > know about that). > > For my future reference, what's the right way to "fix" these > situations with the RCU annotations? (I think your response re: Li's > freezer patch was correct and illustrates the problem I'm referring to.) There are several variants of rcu_dereference() for this purpose: o rcu_dereference() for code that is always called within an RCU read-side critical section -- rcu_read_lock(). o rcu_dereference_bh() for code that is always called within an RCU-bh read-side critical section -- rcu_read_lock_bh(). o rcu_dereference_sched() for code that is always called within an RCU-sched read-side critical section -- either rcu_read_lock_sched() or any other primitive that disables preemption. o srcu_dereference() for code that is always called within an SRCU read-side critical section -- srcu_read_lock(). o rcu_dereference_check() for code that might be called either in a read-side critical section or on the update side. This interface takes a second argument, which is normally a logical conjunction of rcu_read_lock_held(), rcu_read_lock_sched_held(), rcu_read_lock_bh_held(), and srcu_read_lock_held for the read side, and lockdep_is_held() for the update side. o rcu_dereference_raw(p) is rcu_dereference_check(p, 1). Expect to be asked hard questions if you include this in your patch. One legitimate use is for initialization and cleanup code sequences where the current CPU is the only one with access to the RCU-protected data structure in question. o rcu_dereference_protected() for code that is only called from the update side. This interface takes a second argument, which would normally only have a logical conjunction of lockdep_is_held() invocations. Don't even think about putting rcu_read_lock_held() and friends here!!! o rcu_access_pointer() for code that only tests the value of the RCU-protected pointer, for example, against NULL. There you have it! Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/