Skip to content

Commit

Permalink
PM / Memory-hotplug: Avoid task freezing failures
Browse files Browse the repository at this point in the history
The lock_system_sleep() function is used in the memory hotplug code at
several places in order to implement mutual exclusion with hibernation.
However, this function tries to acquire the 'pm_mutex' lock using
mutex_lock() and hence blocks in TASK_UNINTERRUPTIBLE state if it doesn't
get the lock. This would lead to task freezing failures and hence
hibernation failure as a consequence, even though the hibernation call path
successfully acquired the lock.

But it is to be noted that, since this task tries to acquire pm_mutex, if it
blocks due to this, we are *100% sure* that this task is not going to run
as long as hibernation sequence is in progress, since hibernation releases
'pm_mutex' only at the very end, when everything is done.
And this means, this task is going to be anyway blocked for much more longer
than what the freezer intends to achieve; which means, freezing and thawing
doesn't really make any difference to this task!

So, to fix freezing failures, we just ask the freezer to skip freezing this
task, since it is already "frozen enough".

But instead of calling freezer_do_not_count() and freezer_count() as it is,
we use only the relevant parts of those functions, because restrictions
such as 'the task should be a userspace one' etc., might not be relevant in
this scenario.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Srivatsa S. Bhat authored and Rafael J. Wysocki committed Nov 23, 2011
1 parent 341d416 commit 6a76b7a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/linux/suspend.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,16 @@ static inline void unlock_system_sleep(void) {}

static inline void lock_system_sleep(void)
{
/* simplified freezer_do_not_count() */
current->flags |= PF_FREEZER_SKIP;
mutex_lock(&pm_mutex);
}

static inline void unlock_system_sleep(void)
{
mutex_unlock(&pm_mutex);
/* simplified freezer_count() */
current->flags &= ~PF_FREEZER_SKIP;
}
#endif

Expand Down

0 comments on commit 6a76b7a

Please sign in to comment.