From patchwork Tue Feb 12 15:59:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 2131481 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7114BDFB7B for ; Tue, 12 Feb 2013 20:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752329Ab3BLUt0 (ORCPT ); Tue, 12 Feb 2013 15:49:26 -0500 Received: from e32.co.us.ibm.com ([32.97.110.150]:35422 "EHLO e32.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759149Ab3BLUtX (ORCPT ); Tue, 12 Feb 2013 15:49:23 -0500 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Feb 2013 13:49:22 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Feb 2013 13:49:21 -0700 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 527CD1FF004C; Tue, 12 Feb 2013 13:49:15 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1CKn7RR294138; Tue, 12 Feb 2013 13:49:07 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1CKn3p4008558; Tue, 12 Feb 2013 13:49:07 -0700 Received: from paulmck-ThinkPad-W500 ([9.70.82.77]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1CKmuUQ007402; Tue, 12 Feb 2013 13:48:58 -0700 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 98B95E4A4A; Tue, 12 Feb 2013 07:59:54 -0800 (PST) Date: Tue, 12 Feb 2013 07:59:54 -0800 From: "Paul E. McKenney" To: "Rafael J. Wysocki" Cc: Nathan Zimmer , "viresh.kumar@linaro.org" , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" , "cpufreq@vger.kernel.org" Subject: Re: [PATCH v2 linux-next 2/2] cpufreq: Convert the cpufreq_driver_lock to use the rcu Message-ID: <20130212155954.GP2666@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <74F10842A85F514CA8D8C487E74474BB2D2F925E@P-EXMB1-DC21.corp.sgi.com> <16615226.2vj4EkkIZJ@vostro.rjw.lan> <74F10842A85F514CA8D8C487E74474BB2D30DC9E@P-EXMB1-DC21.corp.sgi.com> <1953281.cgEiiBGo0f@vostro.rjw.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1953281.cgEiiBGo0f@vostro.rjw.lan> User-Agent: Mutt/1.5.21 (2010-09-15) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13021220-5406-0000-0000-00000536EBEF Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Mon, Feb 11, 2013 at 08:36:17PM +0100, Rafael J. Wysocki wrote: > On Monday, February 11, 2013 05:13:30 PM Nathan Zimmer wrote: > > There are some spots that I need to give a much deeper review, cpufreq_register_driver for example. > > > > But I believe > > > @@ -196,7 +195,7 @@ static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs) > > > { > > > if (!sysfs) > > > kobject_put(&data->kobj); > > > - module_put(cpufreq_driver->owner); > > > + module_put(rcu_dereference(cpufreq_driver)->owner); > > > } > > would be ok. In the documentation whatisRCU.txt they give a very similar example. > > Well, the very same document states the following: > > Note that the value returned by rcu_dereference() is valid > only within the enclosing RCU read-side critical section. Ah, there is a code sample in that document showing a bug. I added comments to the code sample making it clear even to someone skimming the document that the code is buggy. Thanx, Paul ------------------------------------------------------------------------ rcu: Make bugginess of code sample more evident One of the code samples in whatisRCU.txt shows a bug, but someone scanning the document quickly might mistake it for a valid use of RCU. Add some screaming comments to help keep speed-readers on track. Reported-by: Nathan Zimmer Signed-off-by: Paul E. McKenney Acked-by: Rafael J. Wysocki --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt index 0cc7820..10df0b8 100644 --- a/Documentation/RCU/whatisRCU.txt +++ b/Documentation/RCU/whatisRCU.txt @@ -265,9 +265,9 @@ rcu_dereference() rcu_read_lock(); p = rcu_dereference(head.next); rcu_read_unlock(); - x = p->address; + x = p->address; /* BUG!!! */ rcu_read_lock(); - y = p->data; + y = p->data; /* BUG!!! */ rcu_read_unlock(); Holding a reference from one RCU read-side critical section