From patchwork Thu Aug 29 21:18:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 2851610 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7EF77C0AB5 for ; Thu, 29 Aug 2013 21:08:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 618AD2055D for ; Thu, 29 Aug 2013 21:08:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E73CC20544 for ; Thu, 29 Aug 2013 21:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303Ab3H2VIL (ORCPT ); Thu, 29 Aug 2013 17:08:11 -0400 Received: from hydra.sisk.pl ([212.160.235.94]:42995 "EHLO hydra.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751625Ab3H2VIJ (ORCPT ); Thu, 29 Aug 2013 17:08:09 -0400 Received: from vostro.rjw.lan (aavx151.neoplus.adsl.tpnet.pl [83.6.57.151]) by hydra.sisk.pl (Postfix) with ESMTPSA id CFC05E3DD2; Thu, 29 Aug 2013 23:02:27 +0200 (CEST) From: "Rafael J. Wysocki" To: ACPI Devel Maling List Cc: Toshi Kani , LKML , Linux PM list , Yasuaki Ishimatsu , linux-mm@kvack.org Subject: [PATCH 3/3] PM / hibernate / memory hotplug: Rework mutual exclusion Date: Thu, 29 Aug 2013 23:18:49 +0200 Message-ID: <1562298.ZjRvhqQzT7@vostro.rjw.lan> User-Agent: KMail/4.10.5 (Linux/3.11.0-rc6+; KDE/4.10.5; x86_64; ; ) In-Reply-To: <9589253.Co8jZpnWdd@vostro.rjw.lan> References: <9589253.Co8jZpnWdd@vostro.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki Since all of the memory hotplug operations have to be carried out under device_hotplug_lock, they won't need to acquire pm_mutex if device_hotplug_lock is held around hibernation. For this reason, make the hibernation code acquire device_hotplug_lock after freezing user space processes and release it before thawing them. At the same tim drop the lock_system_sleep() and unlock_system_sleep() calls from lock_memory_hotplug() and unlock_memory_hotplug(), respectively. Signed-off-by: Rafael J. Wysocki --- kernel/power/hibernate.c | 4 ++++ kernel/power/user.c | 2 ++ mm/memory_hotplug.c | 4 ---- 3 files changed, 6 insertions(+), 4 deletions(-) -- 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 Index: linux-pm/kernel/power/hibernate.c =================================================================== --- linux-pm.orig/kernel/power/hibernate.c +++ linux-pm/kernel/power/hibernate.c @@ -652,6 +652,7 @@ int hibernate(void) if (error) goto Exit; + lock_device_hotplug(); /* Allocate memory management structures */ error = create_basic_memory_bitmaps(); if (error) @@ -685,6 +686,7 @@ int hibernate(void) Free_bitmaps: free_basic_memory_bitmaps(); Thaw: + unlock_device_hotplug(); thaw_processes(); /* Don't bother checking whether freezer_test_done is true */ @@ -814,6 +816,7 @@ static int software_resume(void) pr_debug("PM: Loading hibernation image.\n"); + lock_device_hotplug(); error = create_basic_memory_bitmaps(); if (error) goto Thaw; @@ -827,6 +830,7 @@ static int software_resume(void) swsusp_free(); free_basic_memory_bitmaps(); Thaw: + unlock_device_hotplug(); thaw_processes(); Finish: pm_notifier_call_chain(PM_POST_RESTORE); Index: linux-pm/kernel/power/user.c =================================================================== --- linux-pm.orig/kernel/power/user.c +++ linux-pm/kernel/power/user.c @@ -201,6 +201,7 @@ static long snapshot_ioctl(struct file * if (!mutex_trylock(&pm_mutex)) return -EBUSY; + lock_device_hotplug(); data = filp->private_data; switch (cmd) { @@ -373,6 +374,7 @@ static long snapshot_ioctl(struct file * } + unlock_device_hotplug(); mutex_unlock(&pm_mutex); return error; Index: linux-pm/mm/memory_hotplug.c =================================================================== --- linux-pm.orig/mm/memory_hotplug.c +++ linux-pm/mm/memory_hotplug.c @@ -51,14 +51,10 @@ DEFINE_MUTEX(mem_hotplug_mutex); void lock_memory_hotplug(void) { mutex_lock(&mem_hotplug_mutex); - - /* for exclusive hibernation if CONFIG_HIBERNATION=y */ - lock_system_sleep(); } void unlock_memory_hotplug(void) { - unlock_system_sleep(); mutex_unlock(&mem_hotplug_mutex); }