Issue
I have enable the "Kernel memory leak detector" option inside kernel hacking and rebuilt/reboot the system, for now the kmemleak file exists inside the /sys/kernel/debug
folder but seems like I cannot trigger the scan by echo scan > /sys/kernel/debug/kmemleak
, I have mounted debugfs onto /sys/kernel/debug
, but when I try to trigger the scan it gives me
-bash: echo: write error: Device or resource busy
My guessing is that this is because I do not have write permission inside /sys folder even I'm a root user. Any suggestion how to solve this issue?
Solution
You need to check few things when using kmemleak.
Check whether any bootargs or commandline parameter kmemleak=off
is being passed.
In your boot log, check if you have got any kmemleak related logs, especially something like below logs
kmemleak: Kernel memory leak detector disabled
kmemleak: Early log buffer exceeded (919), please increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE
Most probably, I think you need to configure CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE
. If during boot, the log size for kmemleak increases beyond the limit set in linux kernel config, kmemleak is disabled.
So, configure CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE
and increase the size. This option is also under kernel hacking
. I am using kernel source 4.19.9 and attaching the screenshot for reference. Maximum kmemleak early log entries
is the field, you may need to set it to some higher value(e.g 4096).
Answered By - bornfree Answer Checked By - Timothy Miller (WPSolving Admin)