|
| 1 | +From bfe1ecf46ad4f125703d01d23b292b80dfb22365 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Patrick Yavitz <pyavitz@gmail.com> |
| 3 | +Date: Wed, 4 Feb 2026 07:41:54 -0500 |
| 4 | +Subject: [PATCH] Add a wait_for_completion_idle_timeout to normalize load avg |
| 5 | + |
| 6 | +Source: https://strl.cat/posts/2025/08/2025-08-07-qzowm |
| 7 | + |
| 8 | +Signed-off-by: Patrick Yavitz <pyavitz@gmail.com> |
| 9 | +--- |
| 10 | + include/linux/completion.h | 2 ++ |
| 11 | + kernel/sched/completion.c | 7 +++++++ |
| 12 | + 2 files changed, 9 insertions(+) |
| 13 | + |
| 14 | +diff --git a/include/linux/completion.h b/include/linux/completion.h |
| 15 | +index fb2915676..c62abe10c 100644 |
| 16 | +--- a/include/linux/completion.h |
| 17 | ++++ b/include/linux/completion.h |
| 18 | +@@ -106,6 +106,8 @@ extern int wait_for_completion_killable(struct completion *x); |
| 19 | + extern int wait_for_completion_state(struct completion *x, unsigned int state); |
| 20 | + extern unsigned long wait_for_completion_timeout(struct completion *x, |
| 21 | + unsigned long timeout); |
| 22 | ++extern unsigned long wait_for_completion_idle_timeout(struct completion *x, |
| 23 | ++ unsigned long timeout); |
| 24 | + extern unsigned long wait_for_completion_io_timeout(struct completion *x, |
| 25 | + unsigned long timeout); |
| 26 | + extern long wait_for_completion_interruptible_timeout( |
| 27 | +diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c |
| 28 | +index 19ee70227..74e5dc660 100644 |
| 29 | +--- a/kernel/sched/completion.c |
| 30 | ++++ b/kernel/sched/completion.c |
| 31 | +@@ -173,6 +173,13 @@ wait_for_completion_timeout(struct completion *x, unsigned long timeout) |
| 32 | + } |
| 33 | + EXPORT_SYMBOL(wait_for_completion_timeout); |
| 34 | + |
| 35 | ++unsigned long __sched |
| 36 | ++wait_for_completion_idle_timeout(struct completion *x, unsigned long timeout) |
| 37 | ++{ |
| 38 | ++ return wait_for_common(x, timeout, TASK_IDLE); |
| 39 | ++} |
| 40 | ++EXPORT_SYMBOL(wait_for_completion_idle_timeout); |
| 41 | ++ |
| 42 | + /** |
| 43 | + * wait_for_completion_io: - waits for completion of a task |
| 44 | + * @x: holds the state of this particular completion |
| 45 | +-- |
| 46 | +2.51.0 |
| 47 | + |
0 commit comments