cpuModule
Lua interface to Linux CPU abstractions.
A possible CPU is one the system can ever bring up, a present one is plugged in, and an online one runs tasks.maxid() is the highest possible CPU id, one less than num_possible when
those ids have no gaps.
Functions
| maxid () | Returns the highest possible CPU id, the kernel’s nr_cpu_ids - 1. |
| num_online () | Returns the number of online CPUs. |
| num_possible () | Returns the number of possible CPUs. |
| num_present () | Returns the number of present CPUs. |
| online () | Iterates over the online CPUs, in ascending order. |
| possible () | Iterates over the possible CPUs, in ascending order. |
| present () | Iterates over the present CPUs, in ascending order. |
| stats (cpu) | Returns the time a CPU spent in each state since boot, in nanoseconds. |
Functions in detail
- maxid ()
-
Returns the highest possible CPU id, the kernel’s
nr_cpu_ids - 1.Returns
-
integer
the highest possible CPU id
- num_online ()
-
Returns the number of online CPUs.
Returns
-
integer
number of online CPUs
- num_possible ()
-
Returns the number of possible CPUs.
Returns
-
integer
number of possible CPUs
- num_present ()
-
Returns the number of present CPUs.
Returns
-
integer
number of present CPUs
- online ()
-
Iterates over the online CPUs, in ascending order.
Returns
-
function
iterator for the generic
for, yielding each online CPU idUsage
for id in cpu.online() do print(id) end
- possible ()
-
Iterates over the possible CPUs, in ascending order.
Returns
-
function
iterator for the generic
for, yielding each possible CPU idUsage
for id in cpu.possible() do print(id) end
- present ()
-
Iterates over the present CPUs, in ascending order.
Returns
-
function
iterator for the generic
for, yielding each present CPU idUsage
for id in cpu.present() do print(id) end
- stats (cpu)
-
Returns the time a CPU spent in each state since boot, in nanoseconds.
idleandiowaitare what the tick accounts, which lags/proc/staton a tickless CPU while it idles.Parameters
- cpu
integer
CPU number, from
0tomaxid()
Returns
-
table
fields:
user,nice,system,idle,iowait,irq,softirq,steal,guest,guest_nice,forceidle(if CONFIG_SCHED_CORE), or nil for a CPU that is not online, which hotplug can take away betweenonline()and this callRaises
“out of bounds” if cpu is outside that range - cpu
integer
CPU number, from