1bf5e5e70d
Config MODULE_SCMVERSION introduces a new module attribute --
`scmversion` -- which can be used to identify a given module's SCM
version. This is very useful for developers that update their kernel
independently from their kernel modules or vice-versa since the SCM
version provided by UTS_RELEASE (`uname -r`) will now differ from the
module's vermagic attribute.
For example, we have a CI setup that tests new kernel changes on the
hikey960 and db845c devices without updating their kernel modules. When
these tests fail, we need to be able to identify the exact device
configuration the test was using. By including MODULE_SCMVERSION, we can
identify the exact kernel and modules' SCM versions for debugging the
failures.
Additionally, by exposing the SCM version via the sysfs node
/sys/module/MODULENAME/scmversion, one can also verify the SCM versions
of the modules loaded from the initramfs. Currently, modinfo can only
retrieve module attributes from the module's ko on disk and not from the
actual module that is loaded in RAM.
You can retrieve the SCM version in two ways,
1) By using modinfo:
> modinfo -F scmversion MODULENAME
2) By module sysfs node:
> cat /sys/module/MODULENAME/scmversion
Bug: 180027765
Bug: 236871190
Link: https://lore.kernel.org/all/20210121213641.3477522-1-willmcvicker@google.com/
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Yifan Hong <elsk@google.com>
Change-Id: Iad77caff63c4ddef3a3c92182cdacb0b90b124c7
66 lines
2.3 KiB
Plaintext
66 lines
2.3 KiB
Plaintext
The /sys/module tree consists of the following structure:
|
|
|
|
What: /sys/module/<MODULENAME>
|
|
Description:
|
|
The name of the module that is in the kernel. This
|
|
module name will always show up if the module is loaded as a
|
|
dynamic module. If it is built directly into the kernel, it
|
|
will only show up if it has a version or at least one
|
|
parameter.
|
|
|
|
Note: The conditions of creation in the built-in case are not
|
|
by design and may be removed in the future.
|
|
|
|
What: /sys/module/<MODULENAME>/parameters
|
|
Description:
|
|
This directory contains individual files that are each
|
|
individual parameters of the module that are able to be
|
|
changed at runtime. See the individual module
|
|
documentation as to the contents of these parameters and
|
|
what they accomplish.
|
|
|
|
Note: The individual parameter names and values are not
|
|
considered stable, only the fact that they will be
|
|
placed in this location within sysfs. See the
|
|
individual driver documentation for details as to the
|
|
stability of the different parameters.
|
|
|
|
What: /sys/module/<MODULENAME>/refcnt
|
|
Description:
|
|
If the module is able to be unloaded from the kernel, this file
|
|
will contain the current reference count of the module.
|
|
|
|
Note: If the module is built into the kernel, or if the
|
|
CONFIG_MODULE_UNLOAD kernel configuration value is not enabled,
|
|
this file will not be present.
|
|
|
|
What: /sys/module/<MODULENAME>/srcversion
|
|
Date: Jun 2005
|
|
Description:
|
|
If the module source has MODULE_VERSION, this file will contain
|
|
the checksum of the source code.
|
|
|
|
What: /sys/module/<MODULENAME>/version
|
|
Date: Jun 2005
|
|
Description:
|
|
If the module source has MODULE_VERSION, this file will contain
|
|
the version of the source code.
|
|
|
|
What: /sys/module/MODULENAME/scmversion
|
|
Date: November 2020
|
|
KernelVersion: 5.12
|
|
Contact: Will McVicker <willmcvicker@google.com>
|
|
Description: This read-only file will appear if modpost was supplied with an
|
|
SCM version for the module. It can be enabled with the config
|
|
MODULE_SCMVERSION. The SCM version is retrieved by
|
|
scripts/setlocalversion, which means that the presence of this
|
|
file depends on CONFIG_LOCALVERSION_AUTO=y. When read, the SCM
|
|
version that the module was compiled with is returned. The SCM
|
|
version is returned in the following format::
|
|
|
|
===
|
|
Git: g[a-f0-9]\+(-dirty)\?
|
|
Mercurial: hg[a-f0-9]\+(-dirty)\?
|
|
Subversion: svn[0-9]\+
|
|
===
|