Skip to contentSkip to conversation

docs: scheduler: completion: Document complete_on_current_cpu()

PATCH New Javier Carrasco 1 participant 1 message Oct 16, 2025 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 docs: scheduler: completion: Document complete_on_current_cpu()

Commit 6f63904c8f3e ("sched: add a few helpers to wake up tasks on the current cpu") introduced this new function to the completion API that has not been documented yet.

Document complete_on_current_cpu() explaining what it does and when its usage is justified.

---
Changes in v3:
- Rebase onto v6.18-rc1
- Document the scenario where the gain is relevant (Andrei Vagin)
- Link to v2: https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Rebase onto v6.17-rc1
- Fix patch formatting (drop --- before the Signed-off-by tag).
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 Documentation/scheduler/completion.rst | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/scheduler/completion.rst +5 -0
index adf0c0a56d02..139700c56964 100644
@@ -272,6 +272,11 @@ Signaling completion from IRQ context is fine as it will appropriately
 lock with spin_lock_irqsave()/spin_unlock_irqrestore() and it will never
 sleep.
 
+Use complete_on_current_cpu() to wake up the task on the current CPU.
+It makes use of the WF_CURRENT_CPU flag to move the task to be woken up
+to the current CPU, achieving faster context switches. For this optimization
+to be effective, the current task must be about to go to sleep right after
+waking the target task.
 
 try_wait_for_completion()/completion_done():
 --------------------------------------------

---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20250702-complete_on_current_cpu_doc-94dfc72a39f8

Best regards,

Signature · 1 line
Javier Carrasco <[email protected]>