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, or module_exit.
  • Ordering module unload: stopping the thread vs freeing its resources.
  • Debugging hangs, UAFs, or "thread kept running after driver died" bugs.

When not to use

Installs
1
GitHub Stars
2
First Seen
Oct 3, 2026