From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764387AbXKNVI2 (ORCPT ); Wed, 14 Nov 2007 16:08:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755461AbXKNVIU (ORCPT ); Wed, 14 Nov 2007 16:08:20 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:48247 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755181AbXKNVIU convert rfc822-to-8bit (ORCPT ); Wed, 14 Nov 2007 16:08:20 -0500 From: "Rafael J. Wysocki" To: Andrew Morton Subject: [PATCH] Hibernation: Fix lockdep report (v2) Date: Wed, 14 Nov 2007 22:25:57 +0100 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Cc: Johannes Berg , Peter Zijlstra , LKML , Pavel Machek , pm list MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8BIT Content-Disposition: inline Message-Id: <200711142225.58033.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org [Andrew, please consider this as 2.6.24 material, thanks.] --- From: Johannes Berg Lockdep reports a circular locking dependency in the hibernate code because  - during system boot hibernate code (from an initcall) locks pm_mutex    and then a sysfs buffer mutex via name_to_dev_t  - during regular operation hibernate code locks pm_mutex under a    sysfs buffer mutex because it's called from sysfs methods. The deadlock can never happen because during initcall invocation nothing can write to sysfs yet. This removes the lockdep report by marking the initcall locking as being in a different class. Signed-off-by: Johannes Berg Cc: Alan Stern Cc: Peter Zijlstra Cc: Pavel Machek Signed-off-by: Rafael J. Wysocki --- kernel/power/disk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) Index: linux-2.6/kernel/power/disk.c =================================================================== --- linux-2.6.orig/kernel/power/disk.c +++ linux-2.6/kernel/power/disk.c @@ -456,7 +456,17 @@ static int software_resume(void) int error; unsigned int flags; - mutex_lock(&pm_mutex); + /* + * name_to_dev_t() below takes a sysfs buffer mutex when sysfs + * is configured into the kernel. Since the regular hibernate + * trigger path is via sysfs which takes a buffer mutex before + * calling hibernate functions (which take pm_mutex) this can + * cause lockdep to complain about a possible ABBA deadlock + * which cannot happen since we're in the boot code here and + * sysfs can't be invoked yet. Therefore, we use a subclass + * here to avoid lockdep complaining. + */ + mutex_lock_nested(&pm_mutex, SINGLE_DEPTH_NESTING); if (!swsusp_resume_device) { if (!strlen(resume_file)) { mutex_unlock(&pm_mutex);