From b46a02463b2808ec3bec0ccec7f182a097487682 Mon Sep 17 00:00:00 2001 From: Marsman1996 Date: Fri, 26 Dec 2025 10:32:16 +0800 Subject: [PATCH] Replace RwLock with RwMutex for child node management in SysTree --- kernel/comps/systree/src/utils.rs | 10 +++++----- kernel/src/fs/cgroupfs/systree_node.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/comps/systree/src/utils.rs b/kernel/comps/systree/src/utils.rs index 1403bc768..60223816f 100644 --- a/kernel/comps/systree/src/utils.rs +++ b/kernel/comps/systree/src/utils.rs @@ -11,7 +11,7 @@ use alloc::{ use inherit_methods_macro::inherit_methods; use ostd::{ mm::{VmReader, VmWriter}, - sync::RwLock, + sync::RwMutex, }; use spin::Once; @@ -108,7 +108,7 @@ impl NormalNodeFields { #[derive(Debug)] pub struct AttrLessBranchNodeFields { base: ObjFields, - pub children: RwLock>>, + pub children: RwMutex>>, } #[inherit_methods(from = "self.base")] @@ -116,7 +116,7 @@ impl AttrLessBranchNodeFields { pub fn new(name: SysStr, weak_self: Weak) -> Self { Self { base: ObjFields::new(name, weak_self), - children: RwLock::new(BTreeMap::new()), + children: RwMutex::new(BTreeMap::new()), } } @@ -178,7 +178,7 @@ impl AttrLessBranchNodeFields { children.get(name).cloned() } - pub fn children_ref(&self) -> &RwLock>> { + pub fn children_ref(&self) -> &RwMutex>> { &self.children } @@ -228,7 +228,7 @@ impl BranchNodeFields { pub fn child(&self, name: &str) -> Option>; - pub fn children_ref(&self) -> &RwLock>>; + pub fn children_ref(&self) -> &RwMutex>>; pub fn attr_set(&self) -> &SysAttrSet { &self.attr_set diff --git a/kernel/src/fs/cgroupfs/systree_node.rs b/kernel/src/fs/cgroupfs/systree_node.rs index ebed2ef51..007d30d36 100644 --- a/kernel/src/fs/cgroupfs/systree_node.rs +++ b/kernel/src/fs/cgroupfs/systree_node.rs @@ -22,7 +22,7 @@ //! `inner` data. //! //! 3. **Children Lock**: Each cgroup node ([`CgroupNode`] and [`CgroupSystem`]) inherits -//! an `RwLock` from `BranchNodeFields`. This lock protects access to and +//! an `RwMutex` from `BranchNodeFields`. This lock protects access to and //! modification of the list of child cgroup nodes. //! //! 4. **Cgroup Membership Lock**: A global `Mutex` managed by [`CgroupMembership`] that