tools/deadlock: Add an option to set the maximum number of stack traces #4591
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit 77f5252 ("tools/deadlock: support specifies maxnum of threads and edge cases (#3455)") allow to set the maximum number of threads and edge cases to be able to reduce the memory usage of the deadlock tool. It however let the size of the map of stack traces fixed. It's current size, 640k (actually rounded up to 1M) takes 1Gb of vmalloced kernel memory.
This patch adds an option to make the maximum number of stack traces user defined. It also set the default value to 64k, in line with the current default for the number of edge cases and threads.
It fix the following issue on system with limited memory ressources: could not open bpf map: stack_traces, error: Cannot allocate memory Traceback (most recent call last):
File "/tmp/./deadlock.py", line 577, in
main()
File "/tmp/./deadlock.py", line 489, in main
bpf = BPF(text=text)
File "/usr/lib/python3.9/site-packages/bcc/init.py", line 479, in init
raise Exception("Failed to compile BPF module %s" % (src_file or ""))
Exception: Failed to compile BPF module