Skip to content
ENExplore Calculators

Kernel Thread Calculator

Calculate the number of kernel threads spawned per CPU core for common kernel subsystems.

About Kernel Thread Calculator

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

Worked example

With the default values below, Kernel Thread Calculator returns Expected Total Kernel Threads of 45. Change any input above and every figure here is recalculated in your browser.

Inputs used

Total kthreadd Children (from ps --ppid 2)minimum 0
45
Per-CPU Thread Types (e.g. kworker, migration, ksoftirqd)minimum 0
4
CPU Coresminimum 1
8
Global (non-per-CPU) Kernel Threadsminimum 0
13

Results

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

  1. 1Values used
  2. 2Expected thread count
  3. 3Expected Total Kernel Threads= 45
  4. 4Consistency Check= Observed kthreadd child count is consistent with the expected per-CPU + global thread model.
  5. 5Expected Per-CPU Threads (all cores)= 32
  6. 6Avg Per-CPU Threads per Core= 4.0
  7. 7Difference From Observed Count= 0

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 1 decimal place, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

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.

Kernel Thread Calculator | Calcrivo