module_param(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 in sysfs. 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:

  • byte
  • hexint
  • short
  • ushort
  • int
  • uint
  • long
  • ulong
  • charp β€” a character pointer
  • bool β€” a bool, values 0/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