PM / hibernate / memory hotplug: Rework mutual exclusion
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 <rafael.j.wysocki@intel.com> Acked-by: Toshi Kani <toshi.kani@hp.com>
This commit is contained in:
parent
8fd37a4c98
commit
942f40155a
3 changed files with 6 additions and 4 deletions
|
@ -652,6 +652,7 @@ int hibernate(void)
|
||||||
if (error)
|
if (error)
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
lock_device_hotplug();
|
||||||
/* Allocate memory management structures */
|
/* Allocate memory management structures */
|
||||||
error = create_basic_memory_bitmaps();
|
error = create_basic_memory_bitmaps();
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -685,6 +686,7 @@ int hibernate(void)
|
||||||
Free_bitmaps:
|
Free_bitmaps:
|
||||||
free_basic_memory_bitmaps();
|
free_basic_memory_bitmaps();
|
||||||
Thaw:
|
Thaw:
|
||||||
|
unlock_device_hotplug();
|
||||||
thaw_processes();
|
thaw_processes();
|
||||||
|
|
||||||
/* Don't bother checking whether freezer_test_done is true */
|
/* 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");
|
pr_debug("PM: Loading hibernation image.\n");
|
||||||
|
|
||||||
|
lock_device_hotplug();
|
||||||
error = create_basic_memory_bitmaps();
|
error = create_basic_memory_bitmaps();
|
||||||
if (error)
|
if (error)
|
||||||
goto Thaw;
|
goto Thaw;
|
||||||
|
@ -827,6 +830,7 @@ static int software_resume(void)
|
||||||
swsusp_free();
|
swsusp_free();
|
||||||
free_basic_memory_bitmaps();
|
free_basic_memory_bitmaps();
|
||||||
Thaw:
|
Thaw:
|
||||||
|
unlock_device_hotplug();
|
||||||
thaw_processes();
|
thaw_processes();
|
||||||
Finish:
|
Finish:
|
||||||
pm_notifier_call_chain(PM_POST_RESTORE);
|
pm_notifier_call_chain(PM_POST_RESTORE);
|
||||||
|
|
|
@ -201,6 +201,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
|
||||||
if (!mutex_trylock(&pm_mutex))
|
if (!mutex_trylock(&pm_mutex))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
|
lock_device_hotplug();
|
||||||
data = filp->private_data;
|
data = filp->private_data;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
@ -373,6 +374,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock_device_hotplug();
|
||||||
mutex_unlock(&pm_mutex);
|
mutex_unlock(&pm_mutex);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -51,14 +51,10 @@ DEFINE_MUTEX(mem_hotplug_mutex);
|
||||||
void lock_memory_hotplug(void)
|
void lock_memory_hotplug(void)
|
||||||
{
|
{
|
||||||
mutex_lock(&mem_hotplug_mutex);
|
mutex_lock(&mem_hotplug_mutex);
|
||||||
|
|
||||||
/* for exclusive hibernation if CONFIG_HIBERNATION=y */
|
|
||||||
lock_system_sleep();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlock_memory_hotplug(void)
|
void unlock_memory_hotplug(void)
|
||||||
{
|
{
|
||||||
unlock_system_sleep();
|
|
||||||
mutex_unlock(&mem_hotplug_mutex);
|
mutex_unlock(&mem_hotplug_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue