Thread (22 messages) 22 messages, 3 authors, 2024-12-16

Re: [PATCH net-next 0/4] vsock/test: Tests for memory leaks

From: Michal Luczaj <hidden>
Date: 2024-12-13 00:42:16
Subsystem: the rest, vm sockets (af_vsock) · Maintainers: Linus Torvalds, Stefano Garzarella

On 12/10/24 17:25, Stefano Garzarella wrote:
quoted
[...]
I initially considered triggering (and parsing) a kmemleak scan after each
test, but ultimately concluded that the slowdown and the required
privileges would be too much.
Yeah, what about adding something in the README to suggest using
kmemleak and how to check that everything is okay after a run?
Something like this?
diff --git a/tools/testing/vsock/README b/tools/testing/vsock/README
index 84ee217ba8ee..0d6e73ecbf4d 100644
--- a/tools/testing/vsock/README
+++ b/tools/testing/vsock/README
@@ -36,6 +36,21 @@ Invoke test binaries in both directions as follows:
                        --control-port=1234 \
                        --peer-cid=3
 
+Some tests are designed to produce kernel memory leaks. Leaks detection,
+however, is deferred to Kernel Memory Leak Detector. It is recommended to enable
+kmemleak (CONFIG_DEBUG_KMEMLEAK=y) and explicitly trigger a scan after each test
+run, e.g.
+
+  # echo clear > /sys/kernel/debug/kmemleak
+  # $TEST_BINARY ...
+  # echo "wait for any grace periods" && sleep 2
+  # echo scan > /sys/kernel/debug/kmemleak
+  # echo "wait for kmemleak" && sleep 5
+  # echo scan > /sys/kernel/debug/kmemleak
+  # cat /sys/kernel/debug/kmemleak
+
+For more information see Documentation/dev-tools/kmemleak.rst.
+
 vsock_perf utility
 -------------------
 'vsock_perf' is a simple tool to measure vsock performance. It works in
I'd suggest also to add something about that in each patch that
introduce tests where we expects the user to check kmemleak,
at least with a comment on top of the test functions, and maybe
also in the commit description.
Sure, will do.

Thanks,
Michal
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help