diff --git a/backport-fix-enable-subtree_control-for-sub-cgroup-on-hongmen.patch b/backport-fix-enable-subtree_control-for-sub-cgroup-on-hongmen.patch new file mode 100644 index 0000000..0002cdc --- /dev/null +++ b/backport-fix-enable-subtree_control-for-sub-cgroup-on-hongmen.patch @@ -0,0 +1,52 @@ +From b95071b3d24ef2211b3fed059d31497cd62ccbb6 Mon Sep 17 00:00:00 2001 +From: licunlong +Date: Thu, 24 Aug 2023 16:01:24 +0800 +Subject: [PATCH] fix: enable subtree_control for sub cgroup on hongmeng + +--- + core/sysmaster/src/main.rs | 5 +++++ + core/sysmaster/src/mount/setup.rs | 12 ++++++++++++ + 2 files changed, 17 insertions(+) + +diff --git a/core/sysmaster/src/main.rs b/core/sysmaster/src/main.rs +index 95aea65b..7d30fb64 100755 +--- a/core/sysmaster/src/main.rs ++++ b/core/sysmaster/src/main.rs +@@ -146,6 +146,11 @@ fn initialize_runtime(self_recovery_enable: bool) -> Result<()> { + msg: format!("mount cgroup controllers failed: {}", e), + })?; + ++ #[cfg(feature = "hongmeng")] ++ setup::enable_subtree_control(cgroup::CG_BASE_DIR).map_err(|e| Error::Other { ++ msg: format!("enable hongmeng resmgr subtree_control failed: {}", e), ++ })?; ++ + set_child_reaper(); + + Ok(()) +diff --git a/core/sysmaster/src/mount/setup.rs b/core/sysmaster/src/mount/setup.rs +index 953ff4d9..56efdac4 100755 +--- a/core/sysmaster/src/mount/setup.rs ++++ b/core/sysmaster/src/mount/setup.rs +@@ -460,6 +460,18 @@ pub fn mount_cgroup_controllers() -> Result<()> { + Ok(()) + } + ++#[cfg(feature = "hongmeng")] ++/// enable memory controller for sub cgroup ++pub fn enable_subtree_control(cg_base_dir: &str) -> Result<()> { ++ /* hongmeng doesn't enable cgroup controller for sub cgroup. So when we create a directory under ++ * /run/sysmaster/cgroup, i.e. foo.service, the file /run/sysmaster/cgroup/foo.service/controllers ++ * is empty. If controllers file is empty, we can't migrate our process to this cgroup. To avoid ++ * this problem, we forcely enable memory controller for sub cgroup. */ ++ let sub_tree_control = Path::new(cg_base_dir).join("subtree_control"); ++ fs::write(sub_tree_control, "+memory").context(IoSnafu)?; ++ Ok(()) ++} ++ + // return the pair controller which will join with the original controller + fn pair_controller(controller: &str) -> Option { + let mut pairs = HashMap::new(); +-- +2.30.2 + diff --git a/sysmaster.spec b/sysmaster.spec index 3b5ae68..0895bd8 100644 --- a/sysmaster.spec +++ b/sysmaster.spec @@ -17,7 +17,7 @@ Name: sysmaster Version: 0.5.0 -Release: 2 +Release: 3 Summary: redesign and reimplement process1. License: Mulan PSL v2 @@ -30,6 +30,7 @@ Patch2: backport-fix-devmaster-avoid-coredump-when-rules-directory-is.patch Patch3: backport-fix-device-avoid-inserting-empty-tag.patch Patch4: backport-fix-devmaster-append-trailing-white-line-in-99-defau.patch Patch5: backport-fix-disable-User-Group-feature-for-hongmeng.patch +Patch6: backport-fix-enable-subtree_control-for-sub-cgroup-on-hongmen.patch ExclusiveArch: x86_64 aarch64 @@ -131,6 +132,9 @@ ln -s /usr/lib/sysmaster/system/sshd.service %{buildroot}/etc/sysmaster/system/m %attr(0550,-,-) /usr/lib/devmaster/devmaster %changelog +* Fri Aug 25 2023 licunlong - 0.5.0-3 +- enable subtree_control for sub cgroup on hongmeng + * Wed Aug 23 2023 licunlong - 0.5.0-2 - disable User/Group on hongmeng