docs: scheduler: completion: Document complete_on_current_cpu()
PATCH v2 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 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 | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/scheduler/completion.rst +4 -0
@@ -272,6 +272,10 @@ 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. To use this variant, +the context switch speed must be relevant and the optimization justified. try_wait_for_completion()/completion_done(): --------------------------------------------
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250702-complete_on_current_cpu_doc-94dfc72a39f8
Best regards,
Signature · 1 line
Javier Carrasco <[email protected]>
Jonathan Corbet
maintainerQuoted 3 lines · Javier Carrasco
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.
For a change like this, it is a really good idea to copy the author of the original patch and others who were involved in it; I have added them now.
jon
Quoted 37 lines
Document
complete_on_current_cpu()explaining what it does and when its usage is justified.Signed-off-by Javier Carrasco <[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 | 4 ++++ 1 file changed, 4 insertions(+)Documentation/scheduler/completion.rst +4
-1@@ -272,6 +272,10 @@ 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. To use this variant, +the context switch speed must be relevant and the optimization justified. try_wait_for_completion()/completion_done(): -------------------------------------------- ---base-commit:
8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250702-complete_on_current_cpu_doc-94dfc72a39f8Best regards,
Signature · 1 line
Javier Carrasco <[email protected]>
Quoted 9 lines · Jonathan Corbet
Quoted 3 lines · Javier Carrasco
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.For a change like this, it is a really good idea to copy the author of the original patch and others who were involved in it; I have added them now.
This really is a rather specialized thing -- not sure it makes sense to have in the document.
Quoted 37 lines
Quoted 37 lines
Document
complete_on_current_cpu()explaining what it does and when its usage is justified.Signed-off-by Javier Carrasco <[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 | 4 ++++ 1 file changed, 4 insertions(+)Documentation/scheduler/completion.rst +4
-1@@ -272,6 +272,10 @@ 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. To use this variant, +the context switch speed must be relevant and the optimization justified. try_wait_for_completion()/completion_done(): -------------------------------------------- ---base-commit:
8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250702-complete_on_current_cpu_doc-94dfc72a39f8Best regards,
Signature · 1 line
Javier Carrasco <[email protected]>
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Jonathan Corbet
Quoted 3 lines · Javier Carrasco
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.
Quoted 7 lines
Quoted 3 lines
For a change like this, it is a really good idea to copy the author of the original patch and others who were involved in it; I have added them now.
This really is a rather specialized thing -- not sure it makes sense to have in the document.
Hello Peter, thank you for your reply.
I agree that it is a rather specialized function, but in my opinion that should not be a reason to exclude it from the documentation. Where do you draw the line then? It is an exposed function from the API that can be called like any other function from the API if the user requires that.
This one is by the way the only undocumented function from the completion API.
Best regards,
Javier Carrasco
Quoted 24 lines · Javier Carrasco
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.Signed-off-by Javier Carrasco <[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 | 4 ++++ 1 file changed, 4 insertions(+)Documentation/scheduler/completion.rst +0
-0
Documentation/scheduler/completion.rst Signaling completion from IRQ context is fine as it will appropriately · line 278
Quoted 7 lines
Documentation/scheduler/completion.rst +4
-0@@ -272,6 +272,10 @@ 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. To use this variant, +the context switch speed must be relevant and the optimization justified.
I think it's worth mentioning that this only makes sense if the current task falls
asleep right after it wakes up the target task.
Quoted 13 lines
Documentation/scheduler/completion.rst +0
-1try_wait_for_completion()/completion_done(): -------------------------------------------- ---base-commit:
8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250702-complete_on_current_cpu_doc-94dfc72a39f8Best regards,
--
Javier Carrasco <[email protected]>