Kernel Thread Calculator
Estimate kernel thread count and per-core distribution from kthreadd children observed via ps.
Inputs
Expected Total Kernel Threads
45
Consistency Check
Observed kthreadd child count is consistent with the expected per-CPU + global thread model.
Expected Per-CPU Threads (all cores)
32
Avg Per-CPU Threads per Core
4.0
Difference From Observed Count
0
Step by step
Values used
Total kthreadd Children (from ps --ppid 2) = 45; Per-CPU Thread Types (e.g. kworker, migration, ksoftirqd) = 4; CPU Cores = 8; Global (non-per-CPU) Kernel Threads = 13
Expected thread count
expected_total = per_cpu_thread_types × cores + global_threads
Expected Total Kernel Threads
= 45
Consistency Check
= Observed kthreadd child count is consistent with the expected per-CPU + global thread model.
Expected Per-CPU Threads (all cores)
= 32
Avg Per-CPU Threads per Core
= 4.0
Difference From Observed Count
= 0
How it works
kthreadd (PID 2) is the kernel's thread spawner — every kernel thread (kworker pools, migration/N, ksoftirqd/N, rcu_sched, writeback workers, etc.) is a descendant of it, visible via `ps --ppid 2` or `ps -ef | grep '\[.*\]'` (kernel threads are shown in square brackets). Many kernel thread types are per-CPU (one instance per core, like ksoftirqd/N and migration/N), so total kernel thread count scales with core count for that subset, plus a smaller set of global (single-instance) threads that don't multiply per core.
Formula
Expected thread count
expected_total = per_cpu_thread_types × cores + global_threads
- t_cpu
- per-CPU thread types
- c
- cores
- t_global
- global (non-per-CPU) threads
Frequently Asked Questions
How do I list all kernel threads on a running system?
`ps --ppid 2 -o pid,comm` lists direct kthreadd children (kernel threads shown in brackets), while `ps -ef | awk '$3==2'` gives a similar view; `ps -eLf | wc -l` includes all threads (kernel + userspace) for a total system thread count.
Why do kworker thread counts fluctuate over time?
Since Linux 4.10+, unbound kworker pools are created and destroyed dynamically based on workqueue demand (replacing the older fixed-per-CPU model), so the exact kworker/N:M count you observe varies with recent I/O and workqueue activity rather than being a fixed number tied only to core count.
Do kernel threads consume the same resources as user processes?
Kernel threads share the kernel's address space (no separate page tables) and never execute user-mode code, so they're lighter weight than typical user processes, but they still consume a task_struct, a kernel stack, and appear in scheduler accounting exactly like any other schedulable task.
You might also need
- Kernel Parameter CalculatorCommonly used together
- Module Dependency CalculatorCommonly used together
- CPU Scheduling CalculatorCommonly used together
- Kernel Log Size CalculatorAlso in System Administration
- Boot Time CalculatorAlso in System Administration
- Package Size CalculatorAlso in System Administration