feat(thp): disable transparent huge pages for DDE daemon services#1126
feat(thp): disable transparent huge pages for DDE daemon services#1126mhduiy wants to merge 1 commit into
Conversation
1. Add dde-thp-disable script to disable THP at cgroup level before service startup 2. Integrate as ExecStartPre in dde-lock, dde-system-daemon, and dde-session-daemon services 3. Update Makefile and Debian packaging to install the script to /usr/libexec/ Log: Disable THP for DDE daemon processes to optimize memory behavior feat(thp): 禁用 DDE 守护进程的透明大页 1. 新增 dde-thp-disable 脚本,在服务启动前通过 cgroup 禁用 THP 2. 将脚本作为 ExecStartPre 集成到 dde-lock、dde-system-daemon 和 dde-session-daemon 服务中 3. 更新 Makefile 和 Debian 打包规则,将脚本安装到 /usr/libexec/ Log: 为 DDE 守护进程禁用透明大页以优化内存行为 PMS: TASK-390043
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a helper script to disable transparent huge pages (THP) via cgroup for key DDE daemons, wires it into their systemd units as an ExecStartPre step, and updates build/packaging to install the script under /usr/libexec. Sequence diagram for DDE daemon startup with THP disablingsequenceDiagram
participant systemd
participant dde_thp_disable as dde_thp_disable
participant cgroup
participant dde_daemon as DDE_daemon
systemd->>dde_thp_disable: ExecStartPre /usr/libexec/dde-thp-disable
dde_thp_disable->>cgroup: disable THP for daemon cgroup
dde_thp_disable-->>systemd: exit 0
systemd->>dde_daemon: ExecStart (dde-lock / dde-system-daemon / dde-session-daemon)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider marking the new ExecStartPre invocation of
dde-thp-disableas non-fatal (e.g., prefixing with-in the unit) so that any unexpected failure in the helper script doesn’t prevent the main daemon from starting. - Within
dde-thp-disable, ensure you robustly handle different cgroup layouts (v1 vs v2, non-existent paths, permission issues) and clearly no-op with a successful exit code when THP cannot be adjusted for the current environment. - Since
install -Dalready creates parent directories, you can simplify the Makefile install target by dropping the explicitmkdir -pv ${DESTDIR}${PREFIX}/libexecto avoid redundant directory creation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider marking the new ExecStartPre invocation of `dde-thp-disable` as non-fatal (e.g., prefixing with `-` in the unit) so that any unexpected failure in the helper script doesn’t prevent the main daemon from starting.
- Within `dde-thp-disable`, ensure you robustly handle different cgroup layouts (v1 vs v2, non-existent paths, permission issues) and clearly no-op with a successful exit code when THP cannot be adjusted for the current environment.
- Since `install -D` already creates parent directories, you can simplify the Makefile install target by dropping the explicit `mkdir -pv ${DESTDIR}${PREFIX}/libexec` to avoid redundant directory creation.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff,该补丁的主要目的是在多个DDE核心服务启动前,通过systemd的 以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的详细审查意见和改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进后的代码建议1. 改进后的 #!/bin/sh
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
# 获取cgroup v2的路径
CG=$(awk -F: '$1=="0" && $2=="" {print $3; exit}' /proc/self/cgroup)
# 校验路径非空且为绝对路径,防止路径遍历
if [ -z "$CG" ] || [ "${CG#/}" = "$CG" ]; then
exit 0
fi
FILE="/sys/fs/cgroup${CG}/memory.thp_mode"
# 直接尝试写入,避免TOCTOU问题,减少系统调用
if ! echo disable > "$FILE" 2>/dev/null; then
logger -t thp-disable "failed to write disable to $FILE"
fi
exit 02. 改进后的 install: build install-dde-data install-icons
# 移除了冗余的 mkdir -pv ${DESTDIR}${PREFIX}/libexec
install -Dm755 misc/thp/dde-thp-disable ${DESTDIR}${PREFIX}/libexec/dde-thp-disable
mkdir -pv ${DESTDIR}${PREFIX}/lib/deepin-daemon
cp -f out/bin/* ${DESTDIR}${PREFIX}/lib/deepin-daemon/3. 关于 systemd 服务的建议: |
|
此 PR 暂不合并 |
|
TAG Bot New tag: 6.1.92 |
Log: Disable THP for DDE daemon processes to optimize memory behavior
feat(thp): 禁用 DDE 守护进程的透明大页
Log: 为 DDE 守护进程禁用透明大页以优化内存行为
PMS: TASK-390043
Summary by Sourcery
Disable transparent huge pages for core DDE daemon services via a new helper script and service unit integration.
New Features:
Enhancements: