module: show module version directly in print_modules()
PATCH 1/1 module: show module version directly in print_modules()
We maintain a vmcore analysis script on each server that automatically parses /var/crash/XXXX/vmcore-dmesg.txt to categorize vmcores. This helps us save considerable effort by avoiding analysis of known bugs.
For vmcores triggered by a driver bug, the system calls print_modules() to list the loaded modules. However, print_modules() does not output module version information. Across a large fleet of servers, there are often many different module versions running simultaneously, and we need to know which driver version caused a given vmcore.
Currently, the only reliable way to obtain the module version associated with a vmcore is to analyze the /var/crash/XXXX/vmcore file itself—an operation that is resource-intensive. Therefore, we propose printing the driver version directly in the log, which is far more efficient.
- Before this patch
Modules linked in: xfs nvidia-535.274.02(PO) nvme_core-1.0 mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1
- After this patch
Modules linked in: xfs nvidia(PO) nvme_core mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1
--- kernel/module/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/module/main.c +4 -1
@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +if (mod->version) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules ();
Signature · 1 line
2.43.5
Quoted 49 lines · Yafang Shao
We maintain a vmcore analysis script on each server that automatically parses
/var/crash/XXXX/vmcore-dmesg.txtto categorize vmcores. This helps us save considerable effort by avoiding analysis of known bugs.For vmcores triggered by a driver bug, the system calls
print_modules()to list the loaded modules. However,print_modules()does not output module version information. Across a large fleet of servers, there are often many different module versions running simultaneously, and we need to know which driver version caused a given vmcore.Currently, the only reliable way to obtain the module version associated with a vmcore is to analyze the
/var/crash/XXXX/vmcorefile itself—an operation that is resource-intensive. Therefore, we propose printing the driver version directly in the log, which is far more efficient.- Before this patch
Modules linked in: xfs nvidia-535.274.02(PO) nvme_core-1.0 mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1- After this patch
Modules linked in: xfs nvidia(PO) nvme_core mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1Signed-off-by Yafang Shao <[email protected]>--- kernel/module/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kernel/module/main.c +4
-1@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +if (mod->version) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules ();Signature · 1 line
2.43.5
Hi Yafang,
While I certainly appreciate the operational burden of managing a large-scale fleet and the desire to automate crash triage, I am somewhat hesitant to support this change in its current form.
Perhaps the more appropriate approach would be to extend the existing module information infrastructure to include the version only when it is explicitly requested: introduce print_module_versions().
In my view, while the requirement for better version visibility is valid, we must ensure that the change does not compromise the readability of the crash report for the rest of the community.
Kind regards,
Signature · 1 line
Aaron Tomlin
Quoted 54 lines · Aaron Tomlin
Quoted 47 lines · Yafang Shao
We maintain a vmcore analysis script on each server that automatically parses
/var/crash/XXXX/vmcore-dmesg.txtto categorize vmcores. This helps us save considerable effort by avoiding analysis of known bugs.For vmcores triggered by a driver bug, the system calls
print_modules()to list the loaded modules. However,print_modules()does not output module version information. Across a large fleet of servers, there are often many different module versions running simultaneously, and we need to know which driver version caused a given vmcore.Currently, the only reliable way to obtain the module version associated with a vmcore is to analyze the
/var/crash/XXXX/vmcorefile itself—an operation that is resource-intensive. Therefore, we propose printing the driver version directly in the log, which is far more efficient.- Before this patch
Modules linked in: xfs nvidia-535.274.02(PO) nvme_core-1.0 mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1- After this patch
Modules linked in: xfs nvidia(PO) nvme_core mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1Signed-off-by Yafang Shao <[email protected]>--- kernel/module/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kernel/module/main.c +4
-2@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +if (mod->version) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules (); --Quoted 2 lines
2.43.5
Hi Yafang,
Quoted 7 lines
While I certainly appreciate the operational burden of managing a large-scale fleet and the desire to automate crash triage, I am somewhat hesitant to support this change in its current form.
Perhaps the more appropriate approach would be to extend the existing module information infrastructure to include the version only when it is explicitly requested: introduce
print_module_versions().
Isn't that redundant since print_modules() already outputs module names?
Quoted 4 lines
In my view, while the requirement for better version visibility is valid, we must ensure that the change does not compromise the readability of the crash report for the rest of the community.
I understand your concern, but could you elaborate on the potential troubles? The extraction is straightforward with simple text processing.
$ cat vmcore-dmesg.txt | awk -F': ' '/Modules linked
in:/{gsub(/\([^)]*\)/, "", $2); n=split($2,a," "); for(i=1;i<=n;i++)
if(a[i]!="") print a[i]}'Besides, kernel logs aren't an ABI—developers are expected to adapt to upstream changes. Otherwise, the kernel itself would become unmaintainable.
Quoted 2 lines
Nacked-by Aaron Tomlin <[email protected]>
Signature · 2 lines
Regards Yafang
Petr Pavlu
maintainerQuoted 17 lines · Yafang Shao
We maintain a vmcore analysis script on each server that automatically parses
/var/crash/XXXX/vmcore-dmesg.txtto categorize vmcores. This helps us save considerable effort by avoiding analysis of known bugs.For vmcores triggered by a driver bug, the system calls
print_modules()to list the loaded modules. However,print_modules()does not output module version information. Across a large fleet of servers, there are often many different module versions running simultaneously, and we need to know which driver version caused a given vmcore.Currently, the only reliable way to obtain the module version associated with a vmcore is to analyze the
/var/crash/XXXX/vmcorefile itself—an operation that is resource-intensive. Therefore, we propose printing the driver version directly in the log, which is far more efficient.- Before this patch
Quoted 7 lines
Modules linked in: xfs nvidia-535.274.02(PO) nvme_core-1.0 mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1- After this patch
Modules linked in: xfs nvidia(PO) nvme_core mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1
I feel that module versions are not particularly useful for in-tree modules nowadays. They rarely change and therefore provide little information about what code is actually running.
This is supported by their limited use in the kernel. In v6.19-rc3, I see the following:
$ git grep '^MODULE_LICENSE(.*);$' | wc -l 12481 $ git grep '^MODULE_VERSION(.*);$' | wc -l 605
Moreover, in the event of a crash, the log should contain the kernel version and usually also the vmlinux build ID, which should provide enough information to identify in-tree modules.
However, based on the example in your patch description, it seems to me that your main interest is likely in identifying external modules. If that is correct, I see why it might be helpful to quickly identify their versions. This assumes that developers of external modules actually update MODULE_VERSION() in their releases, but I don't know if this is generally true.
As mentioned, most in-tree modules do not specify an explicit version, so in terms of bloating the information about loaded modules, the patch should have minimal impact in practice. Alternatively, the version information could be printed only for external modules.
Signature · 2 lines
Thanks, Petr
Quoted 38 lines · Petr Pavlu
Quoted 17 lines · Yafang Shao
We maintain a vmcore analysis script on each server that automatically parses
/var/crash/XXXX/vmcore-dmesg.txtto categorize vmcores. This helps us save considerable effort by avoiding analysis of known bugs.For vmcores triggered by a driver bug, the system calls
print_modules()to list the loaded modules. However,print_modules()does not output module version information. Across a large fleet of servers, there are often many different module versions running simultaneously, and we need to know which driver version caused a given vmcore.Currently, the only reliable way to obtain the module version associated with a vmcore is to analyze the
/var/crash/XXXX/vmcorefile itself—an operation that is resource-intensive. Therefore, we propose printing the driver version directly in the log, which is far more efficient.- Before this patch
Quoted 7 lines
Modules linked in: xfs nvidia-535.274.02(PO) nvme_core-1.0 mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1- After this patch
Modules linked in: xfs nvidia(PO) nvme_core mlx_compat(O) Unloaded tainted modules: nvidia_peermem(PO):1I feel that module versions are not particularly useful for in-tree modules nowadays. They rarely change and therefore provide little information about what code is actually running.
This is supported by their limited use in the kernel. In v6.19-rc3, I see the following:
$ git grep '^MODULE_LICENSE(.*);$' | wc -l 12481 $ git grep '^MODULE_VERSION(.*);$' | wc -l 605
Quoted 8 lines
Moreover, in the event of a crash, the log should contain the kernel version and usually also the vmlinux build ID, which should provide enough information to identify in-tree modules.
However, based on the example in your patch description, it seems to me that your main interest is likely in identifying external modules. If that is correct, I see why it might be helpful to quickly identify their versions.
That's correct.
The motivation behind this change is that the external NVIDIA driver
[0] frequently causes kernel panics across our server fleet. While we continuously upgrade to newer NVIDIA driver versions, upgrading the entire fleet is time‑consuming.
Therefore, we need to identify which driver version is responsible for each panic.
[0] https://github.com/NVIDIA/open-gpu-kernel-modules/tags
Quoted 3 lines
This assumes that developers of external modules actually update
MODULE_VERSION()in their releases, but I don't know if this is generally true.
The external modules we currently use include the NVIDIA GPU driver, the mlx5 network driver, and related drivers such as gdrcopy. All of them carry module versions, such as:
gdrdrv-2.5(PO)
nvidia-535.274.02(PO)
nvidia_uvm-535.274.02(PO)
nvidia_drm-535.274.02(PO)
mlx5_core-5.8-2.0.3(O)
nvidia_modeset-535.274.02(PO)
Quoted 5 lines
As mentioned, most in-tree modules do not specify an explicit version, so in terms of bloating the information about loaded modules, the patch should have minimal impact in practice. Alternatively, the version information could be printed only for external modules.
Good suggestion.
I believe it’s sufficient to print only for external modules.
Does the following change look good to you?
kernel/module/main.c +4 -1
@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +if (mod->version &&test_bit (TAINT_OOT_MUDLE , &mod->taints)) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules ();
Signature · 2 lines
Regards Yafang
Quoted 15 lines · Yafang Shao
Quoted 4 lines
As mentioned, most in-tree modules do not specify an explicit version, so in terms of bloating the information about loaded modules, the patch should have minimal impact in practice. Alternatively, the version information could be printed only for external modules.
Good suggestion.
I believe it’s sufficient to print only for external modules.Does the following change look good to you?
kernel/module/main.c +0
-0@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {
kernel/module/main.c void print_modules(void) · line 3910
Quoted 10 lines
kernel/module/main.c +4
-1if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +if (mod->version &&test_bit (TAINT_OOT_MUDLE , &mod->taints)) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules ();
Hi Yafang,
This refined approach is significantly more palatable and addresses the primary concerns regarding log bloat. By gating the version output behind the TAINT_OOT_MODULE bit, we strike an excellent balance between operational necessity and kernel log cleanliness.
From a maintenance perspective, this is a much "tidier" solution. In-tree modules are tied to the specific kernel version already, so printing their versions is redundant. However, for external drivers (like proprietary networking or GPU stacks), the version is the single most critical piece of metadata for triage.
The logic is sound, though there is a minor typo in the bit name that will cause a build failure. Here is the corrected implementation:
@@ -3901,7 +3901,10 @@ void print_modules(void)
list_for_each_entry_rcu(mod, &modules, list) {
if (mod->state == MODULE_STATE_UNFORMED)
continue;
- pr_cont(" %s%s", mod->name, module_flags(mod, buf, true));
+ pr_cont(" %s", mod->name);
+ /* Only append version for out-of-tree modules */
+ if (mod->version && test_bit(TAINT_OOT_MODULE, &mod->taints))
+ pr_cont("-%s", mod->version);
+ pr_cont("%s", module_flags(mod, buf, true));
}
print_unloaded_tainted_modules();
Kind regards,
Signature · 1 line
Aaron Tomlin
Quoted 60 lines · Aaron Tomlin
Quoted 15 lines · Yafang Shao
Quoted 4 lines
As mentioned, most in-tree modules do not specify an explicit version, so in terms of bloating the information about loaded modules, the patch should have minimal impact in practice. Alternatively, the version information could be printed only for external modules.
Good suggestion.
I believe it’s sufficient to print only for external modules.Does the following change look good to you?
kernel/module/main.c +0
-0@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {kernel/module/main.c void print_modules(void) · line 3910
Quoted 10 lines
kernel/module/main.c +4
-1if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +if (mod->version &&test_bit (TAINT_OOT_MUDLE , &mod->taints)) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules ();Hi Yafang,
This refined approach is significantly more palatable and addresses the primary concerns regarding log bloat. By gating the version output behind the
TAINT_OOT_MODULEbit, we strike an excellent balance between operational necessity and kernel log cleanliness.From a maintenance perspective, this is a much "tidier" solution. In-tree modules are tied to the specific kernel version already, so printing their versions is redundant. However, for external drivers (like proprietary networking or GPU stacks), the version is the single most critical piece of metadata for triage.
The logic is sound, though there is a minor typo in the bit name that will cause a build failure. Here is the corrected implementation:
kernel/module/main.c +5
-1@@ -3901,7 +3901,10 @@ void print_modules(void)list_for_each_entry_rcu (mod, &modules, list) {if (mod->state ==MODULE_STATE_UNFORMED )continue ; -pr_cont (" %s%s" , mod->name,module_flags (mod, buf, true)); +pr_cont (" %s" , mod->name); +/* Only append version for out-of-tree modules */ +if (mod->version &&test_bit (TAINT_OOT_MODULE , &mod->taints)) +pr_cont ("-%s" , mod->version); +pr_cont ("%s" ,module_flags (mod, buf, true)); }print_unloaded_tainted_modules ();
Quoted 1 line
Reviewed-by Aaron Tomlin <[email protected]>
Thanks for your review.
v2 is sent: https://lore.kernel.org/linux-modules/[email protected]/
Signature · 2 lines
Regards Yafang