diff options
| author | Hugo Lefeuvre <hle@owl.eu.com> | 2019-02-07 15:03:52 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2019-02-11 02:34:04 -0500 |
| commit | 2b9c2a4859ad5ac7b5a28e9db28c3e618760fe8c (patch) | |
| tree | aa5d4435267ee9206a36ef3fd5abbfec7ce83893 /include/linux/wait.h | |
| parent | 9f132742d5c4146397fef0c5b09fe220576a5bb2 (diff) | |
sched/wait: Use freezable_schedule() when possible
Replace 'schedule(); try_to_freeze();' with a call to freezable_schedule().
Tasks calling freezable_schedule() set the PF_FREEZER_SKIP flag
before calling schedule(). Unlike tasks calling schedule();
try_to_freeze() tasks calling freezable_schedule() are not awaken by
try_to_freeze_tasks(). Instead they call try_to_freeze() when they
wake up if the freeze is still underway.
It is not a problem since sleeping tasks can't do anything which isn't
allowed for a frozen task while sleeping.
The result is a potential performance gain during freeze, since less
tasks have to be awaken.
For instance on a bare Debian vm running a 4.19 stable kernel, the
number of tasks skipped in freeze_task() went up from 12 without the
patch to 32 with the patch (out of 448), an increase of > x2.5.
Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20190207200352.GA27859@behemoth.owl.eu.com.local
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/wait.h')
| -rw-r--r-- | include/linux/wait.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index ed7c122cb31f..5f3efabc36f4 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
| @@ -308,7 +308,7 @@ do { \ | |||
| 308 | 308 | ||
| 309 | #define __wait_event_freezable(wq_head, condition) \ | 309 | #define __wait_event_freezable(wq_head, condition) \ |
| 310 | ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \ | 310 | ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \ |
| 311 | schedule(); try_to_freeze()) | 311 | freezable_schedule()) |
| 312 | 312 | ||
| 313 | /** | 313 | /** |
| 314 | * wait_event_freezable - sleep (or freeze) until a condition gets true | 314 | * wait_event_freezable - sleep (or freeze) until a condition gets true |
| @@ -367,7 +367,7 @@ do { \ | |||
| 367 | #define __wait_event_freezable_timeout(wq_head, condition, timeout) \ | 367 | #define __wait_event_freezable_timeout(wq_head, condition, timeout) \ |
| 368 | ___wait_event(wq_head, ___wait_cond_timeout(condition), \ | 368 | ___wait_event(wq_head, ___wait_cond_timeout(condition), \ |
| 369 | TASK_INTERRUPTIBLE, 0, timeout, \ | 369 | TASK_INTERRUPTIBLE, 0, timeout, \ |
| 370 | __ret = schedule_timeout(__ret); try_to_freeze()) | 370 | __ret = freezable_schedule_timeout(__ret)) |
| 371 | 371 | ||
| 372 | /* | 372 | /* |
| 373 | * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid | 373 | * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid |
| @@ -588,7 +588,7 @@ do { \ | |||
| 588 | 588 | ||
| 589 | #define __wait_event_freezable_exclusive(wq, condition) \ | 589 | #define __wait_event_freezable_exclusive(wq, condition) \ |
| 590 | ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \ | 590 | ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \ |
| 591 | schedule(); try_to_freeze()) | 591 | freezable_schedule()) |
| 592 | 592 | ||
| 593 | #define wait_event_freezable_exclusive(wq, condition) \ | 593 | #define wait_event_freezable_exclusive(wq, condition) \ |
| 594 | ({ \ | 594 | ({ \ |
