Lines Matching +full:keep +full:- +full:a +full:- +full:live

1 // SPDX-License-Identifier: GPL-2.0-or-later
28 * The current module debugging statistics supported help keep track of module
29 * loading failures to enable improvements either for kernel module auto-loading
33 * to a type of module loading failure which is known to incur a certain amount
34 * of memory allocation loss. In the worst case loading a module will fail after
35 * a 3 step memory allocation process:
37 * a) memory allocated with kernel_read_file_from_fd()
40 * the decompressed module to a new local buffer which represents
41 * a copy of the decompressed module passed from userspace. The buffer
44 * place where we would keep the module if it were to be processed
47 * If a failure occurs after these three different allocations only one
50 * step b) a separate counter is used and incremented for the bytes freed and
64 * DOC: dup_failed_modules - tracks duplicate failed modules
77 * In practice on a typical boot today most finit_module() calls fail due to
83 * failed to load due to the fact that a module was already loaded or being
88 * a) FAIL_DUP_MOD_BECOMING: at the end of early_mod_check() before
90 * - with module decompression: 2 virtual memory allocation calls
91 * - without module decompression: 1 virtual memory allocation calls
93 * - with module decompression 3 virtual memory allocation calls
94 * - without module decompression 2 virtual memory allocation calls
97 * is not empty it is a reflection of possible work or optimizations possible
98 * either in-kernel or in userspace.
131 * failures can happen if we had a check in between a successful kernel_read_file_from_fd()
134 * reason for this failure is when userspace is racing to load a module
136 * add_unformed_module() will add a module to our &modules list and
141 * duplicate failed modules are non-fatal, however they typically are
142 * indicative of userspace not seeing a module in userspace loaded yet and
143 * unnecessarily trying to load a module before the kernel even has a chance
145 * non-fatal, we should try to reduce vmalloc() pressure proactively, so
153 * * module_sig_check() - module signature checks
154 * * elf_validity_cache_copy() - some ELF validation issue
160 * * live patch requirements didn't check out
166 * is unique. A module can still fail to load if we detect the module is
168 * this check right before processing the module as live and run its
169 * initialization routines. Note that you have a failure of this type it
191 * but it is perhaps not easy to fix them. A recent example are the modules
192 * requests incurred for frequency modules, a separate module request was
193 * being issued for each CPU on a system.
210 if (test_bit(FAIL_DUP_MOD_BECOMING, &mod_fail->dup_fail_mask) && in mod_fail_to_str()
211 test_bit(FAIL_DUP_MOD_LOAD, &mod_fail->dup_fail_mask)) in mod_fail_to_str()
213 if (test_bit(FAIL_DUP_MOD_BECOMING, &mod_fail->dup_fail_mask)) in mod_fail_to_str()
215 if (test_bit(FAIL_DUP_MOD_LOAD, &mod_fail->dup_fail_mask)) in mod_fail_to_str()
217 return "Bug-on-stats"; in mod_fail_to_str()
222 atomic_long_add(info->len * 2, &invalid_mod_bytes); in mod_stat_bump_invalid()
226 atomic_long_add(info->compressed_len, &invalid_mod_bytes); in mod_stat_bump_invalid()
233 atomic_long_add(info->len, &invalid_becoming_bytes); in mod_stat_bump_becoming()
236 atomic_long_add(info->compressed_len, &invalid_becoming_bytes); in mod_stat_bump_becoming()
246 if (!strcmp(mod_fail->name, name)) { in try_add_failed_module()
247 atomic_long_inc(&mod_fail->count); in try_add_failed_module()
248 __set_bit(reason, &mod_fail->dup_fail_mask); in try_add_failed_module()
255 return -ENOMEM; in try_add_failed_module()
256 memcpy(mod_fail->name, name, strlen(name)); in try_add_failed_module()
257 __set_bit(reason, &mod_fail->dup_fail_mask); in try_add_failed_module()
258 atomic_long_inc(&mod_fail->count); in try_add_failed_module()
259 list_add_rcu(&mod_fail->list, &dup_failed_modules); in try_add_failed_module()
265 * At 64 bytes per module and assuming a 1024 bytes preamble we can fit the
303 return -ENOMEM; in read_file_mod_stats()
308 len += scnprintf(buf + len, size - len, "%25s\t%u\n", "Mods failed on kread", fkreads); in read_file_mod_stats()
310 len += scnprintf(buf + len, size - len, "%25s\t%u\n", "Mods failed on decompress", in read_file_mod_stats()
312 len += scnprintf(buf + len, size - len, "%25s\t%u\n", "Mods failed on becoming", fbecoming); in read_file_mod_stats()
314 len += scnprintf(buf + len, size - len, "%25s\t%u\n", "Mods failed on load", floads); in read_file_mod_stats()
316 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Total module size", total_size); in read_file_mod_stats()
317 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Total mod text size", text_size); in read_file_mod_stats()
319 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Failed kread bytes", ikread_bytes); in read_file_mod_stats()
321 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Failed decompress bytes", in read_file_mod_stats()
324 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Failed becoming bytes", ibecoming_bytes); in read_file_mod_stats()
326 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Failed kmod bytes", imod_bytes); in read_file_mod_stats()
328 …len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Virtual mem wasted bytes", total_virtual_l… in read_file_mod_stats()
331 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Average mod size", in read_file_mod_stats()
336 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Average mod text size", in read_file_mod_stats()
342 * for keeping tabs on a type of failure with one type of byte counter. in read_file_mod_stats()
349 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Avg fail kread bytes", in read_file_mod_stats()
355 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Avg fail becoming bytes", in read_file_mod_stats()
361 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Avg fail decomp bytes", in read_file_mod_stats()
367 len += scnprintf(buf + len, size - len, "%25s\t%lu\n", "Average fail load bytes", in read_file_mod_stats()
379 len += scnprintf(buf + len, size - len, "Duplicate failed modules:\n"); in read_file_mod_stats()
380 len += scnprintf(buf + len, size - len, "%25s\t%15s\t%25s\n", in read_file_mod_stats()
381 "Module-name", "How-many-times", "Reason"); in read_file_mod_stats()
388 len += scnprintf(buf + len, size - len, "%25s\t%15lu\t%25s\n", mod_fail->name, in read_file_mod_stats()
389 atomic_long_read(&mod_fail->count), mod_fail_to_str(mod_fail)); in read_file_mod_stats()