kthread-create-and-teardown
Installation
SKILL.md
Kernel Threads: Create & Teardown
Rules for the kthread create/stop lifecycle: what kthread_create vs
kthread_run start, what kthread_stop really does (it sets a flag and
waits), and in which order module teardown must happen. Load
references/README.md before writing any kthread code or unload path.
When to use
- Creating or reviewing a long-lived kernel thread
(
kthread_create/kthread_run). - Writing the threadfn: its poll loop, return value, and teardown.
- Shutting a thread down (
kthread_stop) from ioctl, file close, ormodule_exit. - Ordering module unload: stopping the thread vs freeing its resources.
- Debugging hangs, UAFs, or "thread kept running after driver died" bugs.