bpf: Adjust PID-related BPF map sizes to the current pid_max#84
Merged
Conversation
mjura
approved these changes
Oct 18, 2021
Collaborator
mjura
left a comment
There was a problem hiding this comment.
I think that we should make PID_MAX as configuration option or explain how to tune system for it. On IoT devices there will be less than 2GB of memory.
Great job, thank you for fixing it
Member
Author
|
It's tuned through a sysctl - |
Before this change, we assumed the worst case scenario about the number
of processes which can be schedules - the upper configurable limit for
x86_64 - which in theory is 4194304.
Allocating such a map size resulted in huge memory usage by lockc BPF
programs, over 500 MB, which is unacceptable for nodes with <=2 GB RAM
(which is usual both in IoT/ARM world and public clouds).
This change reads the currently configured limit by reading the
kernel.pid_max sysctl. On the most of systems it's configured to 32768.
That's way less than the maximum worst case scenario.
Memory usage before this change:
lockc-control-plane-0:~ # free -m
total used free shared buff/cache available
Mem: 1968 811 689 8 467 1011
Swap: 0 0 0
lockc-control-plane-0:~ # systemctl start lockcd
lockc-control-plane-0:~ # free -m
total used free shared buff/cache available
Mem: 1968 1420 154 8 393 339
Swap: 0 0 0
After this change:
lockc-control-plane-0:~ # free -m
total used free shared buff/cache available
Mem: 1968 793 220 3 955 1037
Swap: 0 0 0
lockc-control-plane-0:~ # systemctl start lockcd
lockc-control-plane-0:~ # free -m
total used free shared buff/cache available
Mem: 1968 803 210 3 955 1028
Swap: 0 0
Fixes: lockc-project#82
Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
eccb7ce to
fd978ac
Compare
Member
Author
|
@mjura done, PTAL |
mjura
approved these changes
Oct 19, 2021
Collaborator
mjura
left a comment
There was a problem hiding this comment.
Awesome, thank you Michal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before this change, we assumed the worst case scenario about the number
of processes which can be schedules - the upper configurable limit for
x86_64 - which in theory is 4194304.
Allocating such a map size resulted in huge memory usage by lockc BPF
programs, over 500 MB, which is unacceptable for nodes with <=2 GB RAM
(which is usual both in IoT/ARM world and public clouds).
This change reads the currently configured limit by reading the
kernel.pid_max sysctl. On the most of systems it's configured to 32768.
That's way less than the maximum worst case scenario.
Memory usage before this change:
After this change:
Fixes: #82
Signed-off-by: Michal Rostecki mrostecki@opensuse.org