[Devel] [kpatch-build VZ7] kmod/patch: Allow the patch to get settings from sysfs and to show data there
Evgenii Shatokhin
evgenii.shatokhin at openvz.org
Mon Apr 18 01:03:37 MSK 2022
Hi,
Here is the demo patch to show passing data to the RK patch module and
printing stats there (attached).
I also attached the zstd'd binary patch built from it for VHS7, kernel
3.10.0-1160.53.1.vz7.185.3. You can unzstd it, load it with kpatch load
and check /sys/kernel/kpatch/kpatch_cb_demo/data_*.
Pasha, please, see if it suits your needs with your debugging patches.
kpatch.ko remains unchanged in this case, no API/ABI breaks happens
because everything is implemented in the patch module itself.
How to try it:
1. Apply "[kpatch-build VZ7] kmod/patch: Allow the patch to get settings
from sysfs and to show data there", which I sent earlier, to the branch
"vz7" of kpatch tools.
2. Use the kpatch tools to build binary patches for VZ7.
E.g., for the attached cb-demo.patch:
$ kpatch-build --patch-format=kpatch -s path/to/linux-src -v
path/to/vmlinux -c path/to/config
3. Load the built binary patch and see what can be done with it via sysfs:
---------------------------------
[root at workvm temp]# kpatch load ./kpatch-cb-demo.ko
loaded core module
loading patch module: ./kpatch-cb-demo.ko
[root at workvm temp]# ls -l /sys/kernel/kpatch/kpatch_cb_demo/
total 0
-r--r--r-- 1 root root 4096 Apr 17 23:51 checksum
--w------- 1 root root 4096 Apr 17 23:52 data_in
-r-------- 1 root root 4096 Apr 17 23:51 data_out
-rw-r--r-- 1 root root 4096 Apr 17 23:51 enabled
drwxr-xr-x 3 root root 0 Apr 17 23:51 vmlinux
[root at workvm temp]# cat /sys/kernel/kpatch/kpatch_cb_demo/data_out
Total mem: 728317 page(s), free mem: 508303 page(s), available: 611511
page(s).
[root at workvm temp]# echo 42 > /sys/kernel/kpatch/kpatch_cb_demo/data_in
[root at workvm temp]# dmesg | tail
[25035.857493] kpatch: loaded patch module 'kpatch_cb_demo'
...
[25089.251328] [DBG] my_threshold is now 42
---------------------------------
cb-demo.patch defines the functions to be called when
/sys/kernel/kpatch/kpatch_cb_demo/data_out is read and
/sys/kernel/kpatch/kpatch_cb_demo/data_in is written to by the user. See
KPATCH_DATA_SHOW_CALLBACK() and KPATCH_DATA_STORE_CALLBACK().
This way, you can pass parameters to the patch module in runtime and
report any stats your debugging patches collect.
The files are maintained by the patch module, kpatch-cb-demo.ko in this
example, and, of course, disappear when it is unloaded.
Please see if this proposed enhancement is OK for you.
Naming of files (currently, data_in and data_out) can be discussed too,
if anyone has better idea how to name these.
Regards,
Evgenii.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cb-demo.patch
Type: text/x-patch
Size: 3349 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20220418/62a0d373/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpatch-cb-demo.ko.zst
Type: application/zstd
Size: 120538 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20220418/62a0d373/attachment-0003.bin>
More information about the Devel
mailing list