Skip to content

[Deepin-Kernel-SIG] [linux 6.18-y] [Openeuler] cgroup: disable kernel memory accounting for all memory cgroups by de… - #2012

Merged
opsiff merged 1 commit into
deepin-community:linux-6.18.yfrom
opsiff:linux-6.18.y-2026-07-23-perf
Jul 24, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.18-y] [Openeuler] cgroup: disable kernel memory accounting for all memory cgroups by de…#2012
opsiff merged 1 commit into
deepin-community:linux-6.18.yfrom
opsiff:linux-6.18.y-2026-07-23-perf

Conversation

@opsiff

@opsiff opsiff commented Jul 23, 2026

Copy link
Copy Markdown
Member

…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.

(cherry picked from commit 53fbd8c)

Summary by Sourcery

Disable kernel memory accounting for memory cgroups by default and add a kernel parameter option to re-enable it.

Bug Fixes:

  • Avoid performance regressions caused by unstable kernel memory accounting in memory cgroups by turning it off by default.

Documentation:

  • Document the ability to toggle kernel memory accounting for memory cgroups via kernel parameters.

…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>
(cherry picked from commit 53fbd8c)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR disables kernel memory accounting for memory cgroups by default and adds an explicit kernel parameter switch to re‑enable it, updating the memory cgroup documentation and kernel parameters docs accordingly.

Flow diagram for cgroup_memory kernel parameter handling

flowchart TD
    A[Boot_with_kernel_parameters] --> B[cgroup_memory parses parameters]
    B --> C{token_is_nokmem}
    B --> D{token_is_kmem}

    C -- yes --> E[set cgroup_memory_nokmem = true]
    C -- no --> F[no_change_from_nokmem]

    D -- yes --> G[set cgroup_memory_nokmem = false]
    D -- no --> H[no_change_from_kmem]

    I[default] --> J[cgroup_memory_nokmem = true]
Loading

File-Level Changes

Change Details Files
Disable kmem accounting for all memory cgroups by default, with a boot-time override.
  • Initialize cgroup_memory_nokmem to true so kernel memory accounting is off by default
  • Extend cgroup_memory kernel parameter parsing to recognize "kmem" and explicitly clear cgroup_memory_nokmem when requested
  • Retain existing handling of "nokmem" so boot parameters can still explicitly keep kmem disabled
mm/memcontrol.c
Document the default kmem accounting behavior and new kernel parameter toggle.
  • Update cgroup v1 memory controller documentation to describe default-disabled kmem accounting and the kmem/nokmem options
  • Update kernel-parameters.txt to document cgroup.memory=kmem and cgroup.memory=nokmem boot parameters and their effects
Documentation/admin-guide/cgroup-v1/memory.rst
Documentation/admin-guide/kernel-parameters.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
deepin-ci-robot requested a review from shy129 July 23, 2026 15:14
@Avenger-285714
Avenger-285714 requested review from Avenger-285714 and Copilot and removed request for shy129 July 23, 2026 15:14
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Avenger-285714

Copy link
Copy Markdown
Member

hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8QLND

So 6.6.y needs this too?

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="Documentation/admin-guide/cgroup-v1/memory.rst" line_range="332-334" />
<code_context>
-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.

 Kernel memory limits are not imposed for the root cgroup. Usage for the root
</code_context>
<issue_to_address>
**suggestion (typo):** Clarify the phrasing "kernel memory will all be accounted" for better grammar.

Consider rephrasing to "kernel memory will be fully accounted" or "all kernel memory will be accounted for" to improve grammar and clarity.

```suggestion
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 be fully accounted.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +332 to +334
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Clarify the phrasing "kernel memory will all be accounted" for better grammar.

Consider rephrasing to "kernel memory will be fully accounted" or "all kernel memory will be accounted for" to improve grammar and clarity.

Suggested change
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.
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 be fully accounted.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Disables kernel memory accounting for memory cgroups by default (to avoid reported performance regressions/instability) and adds a boot-time switch to re-enable it, updating the associated admin documentation.

Changes:

  • Set cgroup_memory_nokmem default to true, disabling kmem accounting unless overridden.
  • Extend cgroup.memory= boot parameter parsing to accept kmem (re-enables kmem accounting).
  • Update kernel parameter and cgroup-v1 memory controller documentation to describe the new default and toggle.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
mm/memcontrol.c Defaults kernel memory accounting to disabled and adds cgroup.memory=kmem parsing to re-enable it.
Documentation/admin-guide/kernel-parameters.txt Documents the new cgroup.memory=kmem option.
Documentation/admin-guide/cgroup-v1/memory.rst Updates the narrative to reflect kmem accounting being disabled by default and how to enable it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +332 to +334
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.
@opsiff

opsiff commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8QLND

So 6.6.y needs this too?

6.6.y had it long long ago.....

@opsiff
opsiff merged commit 90b0ca1 into deepin-community:linux-6.18.y Jul 24, 2026
7 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants