-
Notifications
You must be signed in to change notification settings - Fork 53
RDKEMW-15176: set swap memory limit for containers #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v3.14
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -62,6 +62,10 @@ static const ctemplate::StaticTemplateString USERNS_DISABLED = | |||||||||||||||||
|
|
||||||||||||||||||
| static const ctemplate::StaticTemplateString MEM_LIMIT = | ||||||||||||||||||
| STS_INIT(MEM_LIMIT, "MEM_LIMIT"); | ||||||||||||||||||
| static const ctemplate::StaticTemplateString MEM_SWAP_LIMIT = | ||||||||||||||||||
| STS_INIT(MEM_SWAP_LIMIT, "MEM_SWAP_LIMIT"); | ||||||||||||||||||
|
|
||||||||||||||||||
| static constexpr unsigned MEM_SWAP_LIMIT_EXTRA_BYTES = 200u * 1024u * 1024u; | ||||||||||||||||||
|
|
||||||||||||||||||
| static const ctemplate::StaticTemplateString CPU_SHARES_ENABLED = | ||||||||||||||||||
| STS_INIT(CPU_SHARES_ENABLED, "CPU_SHARES_ENABLED"); | ||||||||||||||||||
|
|
@@ -1274,6 +1278,7 @@ bool DobbySpecConfig::processMemLimit(const Json::Value& value, | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
||||||||||||||||||
| // Prevent unsigned overflow when computing the swap limit | |
| if (memLimit > (UINT_MAX - MEM_SWAP_LIMIT_EXTRA_BYTES)) | |
| { | |
| AI_LOG_ERROR("memory limit too large, would overflow swap limit"); | |
| return false; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -327,7 +327,9 @@ static const char* ociJsonTemplate = R"JSON( | |||||||||
| {{/DEV_WHITELIST_SECTION}} | ||||||||||
| ], | ||||||||||
| "memory": { | ||||||||||
| "limit": {{MEM_LIMIT}} | ||||||||||
| "limit": {{MEM_LIMIT}}, | ||||||||||
| "swap": {{MEM_SWAP_LIMIT}}, | ||||||||||
| "swappiness": 60 | ||||||||||
|
Comment on lines
+330
to
+332
|
||||||||||
| "swap": {{MEM_SWAP_LIMIT}}, | |
| "swappiness": 60 | |
| "swap": {{MEM_SWAP_LIMIT}}{{#MEM_SWAPPINESS_SECTION}}, | |
| "swappiness": {{MEM_SWAPPINESS}}{{/MEM_SWAPPINESS_SECTION}} |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -338,7 +338,9 @@ static const char* ociJsonTemplate = R"JSON( | |||||||||
| {{/DEV_WHITELIST_SECTION}} | ||||||||||
| ], | ||||||||||
| "memory": { | ||||||||||
| "limit": {{MEM_LIMIT}} | ||||||||||
| "limit": {{MEM_LIMIT}}, | ||||||||||
| "swap": {{MEM_SWAP_LIMIT}}, | ||||||||||
| "swappiness": 60 | ||||||||||
|
Comment on lines
+341
to
+343
|
||||||||||
| "swap": {{MEM_SWAP_LIMIT}}, | |
| "swappiness": 60 | |
| "swap": {{MEM_SWAP_LIMIT}}{{#MEM_SWAPPINESS_ENABLED}}, | |
| "swappiness": {{MEM_SWAPPINESS}}{{/MEM_SWAPPINESS_ENABLED}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MEM_SWAP_LIMIT_EXTRA_BYTESintroduces a hard-coded 200MB policy with no rationale or configurability; this makes the runtime behavior difficult to tune across devices. Consider documenting why 200MB is required (and what it represents) or making it a configurable setting tied to platform defaults.