Module lunatik
Manages Lunatik runtimes — isolated Lua states running in the kernel.
lunatik
| _ENV | Shared global environment; scripts exchange objects (e.g. |
| cpu () | Returns the CPU id of a percpu runtime instance. |
| percpu (script[, context="process"]) | Creates one runtime per CPU id, each loading the given script in the calling context. |
| runtime (script[, context="process"]) | Creates a new Lunatik runtime executing the given script. |
Class runtime
| runtime:resume (...) | Resumes a yielded runtime, analogous to coroutine.resume. |
| runtime:stop () | Stops the runtime and releases all associated kernel resources. |
Class percpu
| percpu:stop () | Closes every instance, releasing their Lua states. |
lunatik
- _ENV
-
Shared global environment; scripts exchange objects (e.g. RCU tables) through it.
- _ENV
- cpu ()
-
Returns the CPU id of a percpu runtime instance.
Ranges from
0tolinux.numcpus() - 1; seerunner.run.Returns:
-
integer
instance CPU id, or
nilon a plain runtime - percpu (script[, context="process"])
-
Creates one runtime per CPU id, each loading the given script in the calling context.
The instances are dispatched by CPU: see lunatik.cpu and
runner.run.Parameters:
- script
string
script name (e.g.,
"mymod"loads/lib/modules/lua/mymod.lua) - context string execution context, as in lunatik.runtime (default "process")
Returns:
Raises:
if allocation fails or the script errors on load, after releasing the instances already created - script
string
script name (e.g.,
- runtime (script[, context="process"])
-
Creates a new Lunatik runtime executing the given script.
Parameters:
- script
string
script name (e.g.,
"mymod"loads/lib/modules/lua/mymod.lua) - context
string
execution context:
"process"(sleepable, GFP_KERNEL, mutex),"softirq"(atomic, GFP_ATOMIC, spinlock), or"irq"(atomic, GFP_ATOMIC, spinlock with IRQs disabled). Use"softirq"for hooks that fire in softirq context (netfilter, XDP). Use"hardirq"for hooks that fire in hardirq context (kprobes). (default "process")
Returns:
Raises:
if allocation fails or the script errors on load - script
string
script name (e.g.,
Class runtime
Isolated Lua state running within the Linux kernel.
- runtime:resume (...)
-
Resumes a yielded runtime, analogous to coroutine.resume.
Parameters:
- ...
values delivered to the script as return values of
coroutine.yield()
Returns:
-
vararg
values passed to the next
coroutine.yield(), or returned by the scriptRaises:
if the runtime errors on resumption - ...
values delivered to the script as return values of
- runtime:stop ()
- Stops the runtime and releases all associated kernel resources.
Class percpu
Set of runtimes, one per CPU id, running the same script. A callback dispatched
through it reaches the instance of the CPU it fired on.