MODULE STATISTICS DEBUGFS COUNTERS(9)
π module statistics debugfs counters π
okay bestie, welcome to module statistics debugfs counters(9) from the Kernel API Manual π
β¨ this is the group-chat breakdown of module-loading debugfs counters, and yes, we are keeping every last detail β no cap, fr fr π«Ά
the total amount of wasted virtual memory allocation space during module loading can be computed by adding the total from the summation:
invalid_kread_bytes + invalid_decompress_bytes +
invalid_becoming_bytes + invalid_mod_bytes
the following debugfs counters are available to inspect module loading failures π:
total_mod_sizeβ total bytes ever used by all modules we've dealt with on this system πtotal_text_sizeβ total bytes of the.textand.init.textELF section sizes we've dealt with on this system β¨invalid_kread_bytesβ bytes allocated and then freed on failures which happen due to the initialkernel_read_file_from_fd.kernel_read_file_from_fdusesvmalloc. these should typically not happen unless your system is under memory pressure πinvalid_decompress_bytesβ number of bytes allocated and freed due to memory allocations in the module decompression path that usevmap. these typically should not happen unless your system is under memory pressure πinvalid_becoming_bytesβ total number of bytes allocated and freed used to read the kernel module userspace wants us to read before we promote it to be processed to be added to our modules linked list. these failures can happen if we had a check in between a successfulkernel_read_file_from_fdcall and right before we allocate our private memory for the module which would be kept if the module is successfully loaded. the most common reason for this failure is when userspace is racing to load a module which it does not yet see loaded. the first module to succeed inadd_unformed_modulewill add a module to our modules list and subsequent loads of modules with the same name will error out at the end ofearly_mod_check. the check formodule_patient_check_existsat the end ofearly_mod_checkprevents duplicate allocations onlayout_and_allocatefor modules already being processed. these duplicate failed modules are non-fatal, however they typically are indicative of userspace not seeing a module in userspace loaded yet and unnecessarily trying to load a module before the kernel even has a chance to begin to process prior requests. although duplicate failures can be non-fatal, we should try to reducevmallocpressure proactively, so ideally after boot this will be close to as 0 as possible. if module decompression was used we also add to this counter the cost of the initialkernel_read_file_from_fdof the compressed module. if module decompression was not used the value represents the total allocated and freed bytes inkernel_read_file_from_fdcalls for these type of failures. these failures can occur because:module_sig_check- module signature checkself_validity_cache_copy- some ELF validation issueearly_mod_check:- blacklisting
- failed to rewrite section headers
- version magic
- live patch requirements didn't check out
- the module was detected as being already present
invalid_mod_bytesβ these are the total number of bytes allocated and freed due to failures after we did all the sanity checks of the module which userspace passed to us and after our first check that the module is unique. a module can still fail to load if we detect the module is loaded after we allocate space for it withlayout_and_allocate, we do this check right before processing the module as live and run its initialization routines. note that if you have a failure of this type it also means the respectivekernel_read_file_from_fdmemory space was also freed and not used, and so we increment this counter with twice the size of the module. additionally if you used module decompression the size of the compressed module is also added to this counter π₯modcountβ how many modules we've loaded in our kernel life time πfailed_kreadsβ how many modules failed due to failedkernel_read_file_from_fdπΈfailed_decompressβ how many failed module decompression attempts we've had. these really should not happen unless your compression / decompression might be broken πfailed_becomingβ how many modules failed after wekernel_read_file_from_fdit and before we allocate memory for it withlayout_and_allocate. this counter is never incremented if you manage to validate the module and calllayout_and_allocatefor it πfailed_load_modulesβ how many modules failed once we've allocated our private space for our module usinglayout_and_allocate. these failures should hopefully mostly be dealt with already. races in theory could still exist here, but it would just mean the kernel had started processing two threads concurrently up toearly_mod_checkand one thread won. these failures are good signs the kernel or userspace is doing something seriously stupid or that could be improved. we should strive to fix these, but it is perhaps not easy to fix them. a recent example are the modules requests incurred for frequency modules, a separate module request was being issued for each CPU on a system π
π SEE ALSO π
Kernel file ./kernel/module/stats.c module debugging statistics overview(9)β the Kernel file reference, quoted exactly for the girlies who need it πdup_failed_modules - tracks duplicate failed modules(9)β and this one tracks duplicate failed modules, iykyk π
mwah π β this pageβs source/version is ./kernel/module, dated October 2026, and the manual tag is module stati...gfs counters(9) β¨π«Ά
π¦ 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