module_param(9)
πΈ module_param πΈ
okay bestie, so we're in module_param(9) β kernel API manual territory β and this one is literally the typesafe helper for a module/cmdline parameter. it's giving "tiny macro, huge responsibilities" and honestly? iconic. π
β¨ SYNOPSIS β¨
module_param (name , type , perm );
like yes that's it, three little args, that's the whole vibe check π«Ά
π ARGUMENTS π
nameβ the variable you're gonna alter, and also the parameter name that gets exposed to the world. it's doing double duty, main character energy fr.typeβ the type of the parameter. yes you have to tell it, no it won't guess. πpermβ visibility insysfs. that's the permissions situation.
π DESCRIPTION π
so name becomes the module parameter β or, when it's prefixed by KBUILD_MODNAME and a ., it becomes the kernel commandline parameter. and here's the cute part: note that - is changed to _, so the user can use "foo-bar=1" even for the variable "foo_bar". thoughtful! considerate! we love a forgiving interface π§
perm is 0 if the variable is not to appear in sysfs, or 0444 for world-readable, 0644 for root-writable, etc. and listen β if it is writable, you may need to use kernel_param_lock around accesses (esp. charp, which can be kfreed when it changes). so like, don't just go touching things concurrently without locking, that's not the move π
the type is simply pasted to refer to a param_ops_##type and a param_check_##type. for convenience many standard types are provided, but you can create your own by defining those variables. build-your-own-parameter, we stan a customizable queen π
standard types are:
bytehexintshortushortintuintlongulongcharpβ a character pointerboolβ a bool, values0/1,y/n,Y/N.invboolβ the above, only sense-reversed (N= true). yes it's backwards on purpose, she's quirky like that π
π¦ SEE ALSO π¦
kernel file ./include/linux/moduleparam.h, plus the whole friend group:
module_param_unsafe(9), module_param_named(9), module_param_named_unsafe(9), module_param_cb(9), core_param_cb(9), postcore_param_cb(9), arch_param_cb(9), subsys_param_cb(9), fs_param_cb(9), device_param_cb(9), late_param_cb(9), core_param(9), core_param_unsafe(9), __core_param_cb(9), module_param_string(9), parameq(9), parameqn(9), module_param_array(9), module_param_array_named(9), module_param_hw_named(9), module_param_hw_array(9)
like. that's a lot of siblings. one big happy moduleparam.h family reunion π
and that's the page, bestie! this one lives down in ./include/linux, dated October 2026 β so go forth, parameterize responsibly, and remember: typesafe is a lifestyle πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms