-
Notifications
You must be signed in to change notification settings - Fork 94
[Deepin-Kernel-SIG] [linux 6.6-y] [Openeuler] cgroup: disable kernel memory accounting for all memory cgroups by de… #967
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: linux-6.6.y
Are you sure you want to change the base?
Conversation
…fault hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8QLND CVE: NA ---------------------------------------- The kernel memory accounting for all memory cgroups is not stable, and it will cause a 100% regression in hackbench compared with kernel-4.19, so disable it by default. We can use the following command line to enable or disable it: cgroup.memory=kmem or cgroup.memory=nokmem. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> Signed-off-by: chenridong <chenridong@huawei.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's GuideDisable kernel memory accounting for all memory cgroups by default and introduce a "kmem" kernel parameter to re-enable it, with corresponding documentation updates. Class diagram for cgroup memory kernel parameter handlingclassDiagram
class memcontrol.c {
+bool cgroup_memory_nokmem
+int __init cgroup_memory(char *s)
}
memcontrol.c : cgroup_memory_nokmem = true (default)
memcontrol.c : cgroup_memory(char *s) parses "kmem" and "nokmem" tokens
Flow diagram for cgroup.memory kernel parameter parsingflowchart TD
A[Boot with kernel parameters] --> B{cgroup.memory token}
B -->|kmem| C[Set cgroup_memory_nokmem = false]
B -->|nokmem| D[Set cgroup_memory_nokmem = true]
B -->|other| E[No change to cgroup_memory_nokmem]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
deepin pr auto review代码审查意见:
综上所述,代码的更改看起来是为了调整内核内存计费的行为,但是需要确保这些更改与文档和代码的其他部分保持一致,并且进行了充分的测试以确保没有引入新的问题。 |
Test result: After patch:Benchmark Run: 二 7月 22 2025 18:35:19 - 18:42:02 Dhrystone 2 using register variables 50758627.6 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX Benchmark Run: 二 7月 22 2025 18:42:02 - 18:48:45 Dhrystone 2 using register variables 207921797.3 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX before: Dhrystone 2 using register variables 49626251.2 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX Benchmark Run: 日 7月 20 2025 15:44:59 - 15:51:42 Dhrystone 2 using register variables 207921608.7 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX |
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.
Hey @opsiff - I've reviewed your changes - here's some feedback:
- Consider using the kernel’s match_token helper instead of manual strcmp loops for parsing the cgroup.memory tokens to make the code more maintainable and extensible.
- Add explicit conflict detection or precedence handling when both “kmem” and “nokmem” are passed so users aren’t left with ambiguous behavior.
- Double-check that cgroup v2’s memory controller either matches this default-off kmem behavior or provides its own symmetric option to avoid inconsistent defaults across cgroup versions.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using the kernel’s match_token helper instead of manual strcmp loops for parsing the cgroup.memory tokens to make the code more maintainable and extensible.
- Add explicit conflict detection or precedence handling when both “kmem” and “nokmem” are passed so users aren’t left with ambiguous behavior.
- Double-check that cgroup v2’s memory controller either matches this default-off kmem behavior or provides its own symmetric option to avoid inconsistent defaults across cgroup versions.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Tldr: execl from 5356 to 5573(+4%) |
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.
Pull Request Overview
This PR disables kernel memory accounting for all memory cgroups by default to address performance regression issues, specifically a 100% regression in hackbench compared to kernel-4.19. The change introduces a command-line option to re-enable the feature when needed.
- Changes the default state of kernel memory accounting from enabled to disabled
- Adds a new "kmem" command-line parameter to explicitly enable kernel memory accounting
- Updates documentation to reflect the new default behavior and available options
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
mm/memcontrol.c | Changes default value of cgroup_memory_nokmem to true and adds kmem parameter handling |
Documentation/admin-guide/kernel-parameters.txt | Documents the new kmem command-line option |
Documentation/admin-guide/cgroup-v1/memory.rst | Updates memory cgroup documentation to reflect disabled-by-default behavior |
@@ -7618,6 +7618,8 @@ static int __init cgroup_memory(char *s) | |||
cgroup_memory_nosocket = true; | |||
if (!strcmp(token, "nokmem")) | |||
cgroup_memory_nokmem = true; | |||
else if (!strcmp(token, "kmem")) |
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.
The else-if condition should be changed to a separate if statement for consistency with the existing pattern. The current code has separate if statements for 'nosocket', 'nokmem', and 'nobpf' tokens, but uses else-if for 'kmem', which creates inconsistent structure.
else if (!strcmp(token, "kmem")) | |
if (!strcmp(token, "kmem")) |
Copilot uses AI. Check for mistakes.
at boot time. In this case, kernel memory will not be accounted at all. | ||
Kernel memory accounting is disabled for all memory cgroups by default. But | ||
it can be enabled system-wide by passing cgroup.memory=kmem to the kernel | ||
at boot time. In this case, kernel memory will all be accounted. |
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.
The phrase 'kernel memory will all be accounted' is grammatically awkward. It should be 'all kernel memory will be accounted' or 'kernel memory will be accounted'.
at boot time. In this case, kernel memory will all be accounted. | |
at boot time. In this case, all kernel memory will be accounted. |
Copilot uses AI. Check for mistakes.
@winnscode 你怎么看 |
@@ -87,7 +87,7 @@ EXPORT_PER_CPU_SYMBOL_GPL(int_active_memcg); | |||
static bool cgroup_memory_nosocket __ro_after_init; | |||
|
|||
/* Kernel memory accounting disabled? */ | |||
static bool cgroup_memory_nokmem __ro_after_init; | |||
static bool cgroup_memory_nokmem __ro_after_init = true; |
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.
如果不修改这里,会不会侵入性更小些
…fault
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8QLND CVE: NA
The kernel memory accounting for all memory cgroups is not stable, and it will cause a 100% regression in hackbench compared with kernel-4.19, so disable it by default. We can use the following command line to enable or disable it:
cgroup.memory=kmem or cgroup.memory=nokmem.
Summary by Sourcery
Disable kernel memory accounting for all memory cgroups by default to avoid performance regressions and introduce a command-line option to re-enable it.
New Features:
Bug Fixes:
Documentation: