RDK Resources
[*RDK Preferred*]
Code Management Facility
RDK Forums
[RDK Conferences]
RDK Support
Archives
Papers & Presentations Archive
...
i) Kmemleak is a Linux kernel feature designed to detect and report memory leaks in the kernel code. Memory leaks occur when a program allocates memory dynamically but fails to release it when it is no longer needed. This can result in a gradual loss of memory over time, eventually leading to system instability or even crashes.
...
iii) Kmemleak is a useful tool for kernel developers and system administrators who want to ensure that their systems are stable and free of memory leaks. It can be enabled in the kernel configuration, and once enabled, it will run automatically in the background, periodically scanning the kernel memory for leaks.
...
CONFIG_HAVE_DEBUG_KMEMLEAK=y |
...
i) Create kmemleak.cfg file under meta-cmf-raspberrypi/recipes-kernel/linux/files with below kernel configs.
Note: Need to add this change in corresponding Platform platform OEM layer.
CONFIG_HAVE_DEBUG_KMEMLEAK=y |
ii) Add kmemleak.cfg file in meta-cmf-raspberrypi/recipes-kernel/linux/linux-raspberrypi_5.10.52.bbbb
Note: Need to add this change in corresponding Platform platform OEM layer.
Please find below diff file.
Ex:
diff --git a/recipes-kernel/linux/linux-raspberrypi_5.10.52.bb b/recipes-kernel/linux/linux-raspberrypi_5.10.52.bb |
iii) Once build done with above changes, verify the kernel configs are enabled in final kernel boot config file.
Path of kernel boot config file: build build-raspberrypi-rdk-mc/tmp/work/raspberrypi_rdk_mc-rdk-linux-gnueabi/linux-raspberrypi/1_5.10.52+gitAUTOINC+dbe03fa900_2697f74031-r0/image/boot/config-5.10.52-v7
Note: Need to verify in corresponding platform specific final kernel boot config file
Ex:
csures569@dvm-yocto3-docker-csures569:~/ |
rpi- |
stack/build-raspberrypi-rdk-mc/tmp/work/raspberrypi_rdk_mc-rdk-linux-gnueabi/linux-raspberrypi/1_5.10.52+gitAUTOINC+dbe03fa900_2697f74031-r0/image/boot$ cat config-5.10.52-v7 | grep "KMEMLEAK" |
iv) Once flash On flashing the image with above changes , verify the kmemleak enabled in the device, it will create a kmemleak folder under /sys/modules/ and kmemleak file under /sys/kernel/debug/
Ex:
root@raspberrypiroot@raspberrypi-rdk-mc:/sys/module# ls -l | grep "kmemleak" |
v) Once enabled kmemleak we will get kernel memory leaks in /sys/kernel/debug/kmemleak file if leaks are reported.
...
Note: kmemleak-test .ko test module for memory leaks ,by default in rpi3 this module not compiled , is a test module available as part of kmemleak. By default, this module is not compiled in RPI3 and so there is no kmemleak-test.ko module , so . If needed, we need to enable to build as a module and generated module fileby following the above mentioned kernel configurations.
path Path of kmemleak-test module source : feature-securestorage-rpi-2Mar/ build-raspberrypi-rdk-mc/tmp/work-shared/raspberrypi-rdk-mc/kernel-source/samples/kmemleak/kmemleak-test.c
kmemleak-test.ko
Note: Need to generate kmemleak-test.ko module file from corresponding platform specific kernel source code.
Step 1 : Copy kmemleak-test.ko module to this path /lib/modules/5.10.52-v7/ in box .
Step 2 : load the module to kernel space with insmod command.
Ex:
root@raspberrypi-rdk-mc:~# insmod /lib/modules/5.10.52-v7/kmemleak-test.ko |
Step3 : verify whether module is loaded or not
Ex: lsmod
root@raspberrypi-rdk-mc:~# lsmod |
kmemleak test module loaded. |
Step4: Perform a scan
Ex: echo scan > /sys/kernel/debug/kmemleak
root@raspberrypi-rdk-mc:~# echo scan > /sys/kernel/debug/kmemleak |
Step5: Collect memory leak data
...
View file | ||||
---|---|---|---|---|
|
View file | ||||
---|---|---|---|---|
|
TBD
...