Freezer cleanups
Subsystems (2)
cover Freezer cleanups
Hi,
The following three patches contain minor freezer cleanups. Please have a look.
Greetings,
Rafael
PATCH 1/3 Freezer: Use __set_current_state in refrigerator
From: Rafael J. Wysocki <[email protected]>
Use __set_current_state() as appropriate in refrigerator() instead of accessing current->state directly.
--- kernel/power/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/process.c +1 -1
@@ -72,7 +72,7 @@ void refrigerator(void)schedule (); }pr_debug ("%s left refrigerator\n" , current->comm); - current->state = save; +__set_current_state (save); }static void freeze_task (struct task_struct *p)
PATCH 2/3 Freezer: Return int from freeze_processes
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make try_to_freeze_tasks() and freeze_processes() return -EBUSY on failure instead of the number of unfrozen tasks (none of the callers actually uses this number).
--- kernel/power/process.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
kernel/power/process.c +9 -12
@@ -105,7 +105,7 @@ static void cancel_freezing(struct task_ } } -static unsigned int try_to_freeze_tasks (int freeze_user_space) +static int try_to_freeze_tasks (int freeze_user_space) {struct task_struct *g, *p;unsigned long end_time;
@@ -175,28 +175,25 @@ static unsigned int try_to_freeze_tasks(read_unlock (&tasklist_lock); } -return todo; +return todo ? -EBUSY :0 ; }/** * freeze_processes - tell processes to enter the refrigerator -* -* Returns 0 on success, or the number of processes that didn't freeze, -* although they were told to. */ int freeze_processes (void ) { -unsigned int nr_unfrozen; +int error;printk ("Stopping tasks ... " ); - nr_unfrozen =try_to_freeze_tasks (FREEZER_USER_SPACE ); -if (nr_unfrozen) -return nr_unfrozen; + error =try_to_freeze_tasks (FREEZER_USER_SPACE ); +if (error) +return error;sys_sync (); - nr_unfrozen =try_to_freeze_tasks (FREEZER_KERNEL_THREADS ); -if (nr_unfrozen) -return nr_unfrozen; + error =try_to_freeze_tasks (FREEZER_KERNEL_THREADS ); +if (error) +return error;printk ("done.\n" );BUG_ON (in_atomic ());
PATCH 3/3 Freezer: Remove redundant check in try_to_freeze_tasks
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
We don't need to check if todo is positive before calling time_after() in try_to_freeze_tasks(), because if todo is zero at this point, the loop will be broken anyway due to the while () condition being false.
--- kernel/power/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/process.c +1 -1
@@ -149,7 +149,7 @@ static int try_to_freeze_tasks(int freez }while_each_thread (g, p);read_unlock (&tasklist_lock);yield ();/* Yield is okay here */ -if (todo &&time_after (jiffies, end_time)) +if (time_after (jiffies, end_time))break ; }while (todo);
Re: [PATCH 1/3] Freezer: Use __set_current_state in refrigerator
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Use
__set_current_state()as appropriate inrefrigerator()instead of accessingcurrent->statedirectly.Signed-off-by Rafael J. Wysocki <[email protected]>
ACK.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 2/3] Freezer: Return int from freeze_processes
In reply to Rafael J. WysockiQuoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make
try_to_freeze_tasks()andfreeze_processes()return-EBUSYon failure instead of the number of unfrozen tasks (none of the callers actually uses this number).Signed-off-by Rafael J. Wysocki <[email protected]>
ACK.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 3/3] Freezer: Remove redundant check in try_to_freeze_tasks
In reply to Rafael J. WysockiQuoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
We don't need to check if todo is positive before calling
time_after()intry_to_freeze_tasks(), because if todo is zero at this point, the loop will be broken anyway due to the while () condition being false.Signed-off-by Rafael J. Wysocki <[email protected]>
ACK. Thanks for the cleanups!
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html