Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751969AbZFHRRs (ORCPT ); Mon, 8 Jun 2009 13:17:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750961AbZFHRRk (ORCPT ); Mon, 8 Jun 2009 13:17:40 -0400 Received: from tomts43.bellnexxia.net ([209.226.175.110]:41005 "EHLO tomts43-srv.bellnexxia.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784AbZFHRRj (ORCPT ); Mon, 8 Jun 2009 13:17:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEEADPgLEpMQW1W/2dsb2JhbACBT8xUhAoF Date: Mon, 8 Jun 2009 13:17:31 -0400 From: Mathieu Desnoyers To: "Pallipadi, Venkatesh" Cc: Dave Jones , Pekka Enberg , Dave Young , "Rafael J. Wysocki" , Linux Kernel Mailing List , Kernel Testers List , "cpufreq@vger.kernel.org" , Rusty Russell , "trenn@suse.de" , "sven.wegener@stealer.net" , "mingo@elte.hu" , "Li, Shaohua" Subject: Re: [PATCH] remove rwsem lock from CPUFREQ_GOV_STOP call (second call site) Message-ID: <20090608171731.GA24779@Krystal> References: <84144f020906070621r1f480eaeief026d23662df380@mail.gmail.com> <1244447366.13471.4.camel@penberg-laptop> <20090608124844.GA17588@Krystal> <20090608143220.GC2516@redhat.com> <20090608152316.GA21033@Krystal> <1244480254.4534.265.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <1244480254.4534.265.camel@localhost.localdomain> X-Editor: vi X-Info: http://krystal.dyndns.org:8080 X-Operating-System: Linux/2.6.21.3-grsec (i686) X-Uptime: 13:15:48 up 100 days, 13:42, 4 users, load average: 0.83, 0.90, 0.87 User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2950 Lines: 81 OK, here is the re-run, with comment and acked-by added. Thanks, Mathieu remove rwsem lock from CPUFREQ_GOV_STOP call (second call site) commit 42a06f2166f2f6f7bf04f32b4e823eacdceafdc9 Missed a call site for CPUFREQ_GOV_STOP to remove the rwlock taken around the teardown. To make a long story short, the rwlock write-lock causes a circular dependency with cancel_delayed_work_sync(), because the timer handler takes the read lock. Note that all callers to __cpufreq_set_policy are taking the rwsem. All sysfs callers (writers) hold the write rwsem at the earliest sysfs calling stage. However, the rwlock write-lock is not needed upon governor stop. Change : - Added comment from Venkyi at lock definition site. Signed-off-by: Mathieu Desnoyers Acked-by: Venkatesh Pallipadi CC: rjw@sisk.pl CC: mingo@elte.hu CC: Shaohua Li CC: Pekka Enberg CC: Dave Young CC: "Rafael J. Wysocki" CC: Rusty Russell CC: trenn@suse.de CC: sven.wegener@stealer.net CC: cpufreq@vger.kernel.org --- drivers/cpufreq/cpufreq.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) Index: linux-2.6-lttng/drivers/cpufreq/cpufreq.c =================================================================== --- linux-2.6-lttng.orig/drivers/cpufreq/cpufreq.c 2009-06-08 12:47:22.000000000 -0400 +++ linux-2.6-lttng/drivers/cpufreq/cpufreq.c 2009-06-08 12:48:38.000000000 -0400 @@ -61,6 +61,8 @@ static DEFINE_SPINLOCK(cpufreq_driver_lo * are concerned with are online after they get the lock. * - Governor routines that can be called in cpufreq hotplug path should not * take this sem as top level hotplug notifier handler takes this. + * - Lock should not be held across + * __cpufreq_governor(data, CPUFREQ_GOV_STOP); */ static DEFINE_PER_CPU(int, policy_cpu); static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); @@ -1697,8 +1699,17 @@ static int __cpufreq_set_policy(struct c dprintk("governor switch\n"); /* end old governor */ - if (data->governor) + if (data->governor) { + /* + * Need to release the rwsem around governor + * stop due to lock dependency between + * cancel_delayed_work_sync and the read lock + * taken in the delayed work handler. + */ + unlock_policy_rwsem_write(data->cpu); __cpufreq_governor(data, CPUFREQ_GOV_STOP); + lock_policy_rwsem_write(data->cpu); + } /* start new governor */ data->governor = policy->governor; -- Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 -- 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/