Skip to contentSkip to conversation

cgroup: pair max limit READ_ONCE() with WRITE_ONCE()

PATCH Applied Ren Tamura 2 participants 2 messages May 28 cgroup

lore
Share & tools
lore

Ren Tamura

author
#0 lore raw

PATCH 1/1 cgroup: pair max limit READ_ONCE() with WRITE_ONCE()

cgroup.max.descendants and cgroup.max.depth are shown through seq_file. Their show callbacks read cgrp->max_descendants and cgrp->max_depth with READ_ONCE(), respectively.

The corresponding write callbacks update the same scalar fields while holding the cgroup lock, but the seq_file show path does not serialize against those stores. This leaves the lockless show-side loads annotated with READ_ONCE(), while the corresponding stores remain plain stores.

Use WRITE_ONCE() for the updates so the intended lockless access is marked consistently on both sides. This does not change locking, ordering, or user-visible semantics.

Assisted-by OpenAI-Codex:gpt-5.5
---
 kernel/cgroup/cgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cgroup.c +2 -2
index 6152add0c..daddfc2b9 100644
@@ -3726,7 +3726,7 @@ static ssize_t cgroup_max_descendants_write(struct kernfs_open_file *of,
 	if (!cgrp)
 		return -ENOENT;
 
-	cgrp->max_descendants = descendants;
+	WRITE_ONCE(cgrp->max_descendants, descendants);
 
 	cgroup_kn_unlock(of->kn);
 
@@ -3769,7 +3769,7 @@ static ssize_t cgroup_max_depth_write(struct kernfs_open_file *of,
 	if (!cgrp)
 		return -ENOENT;
 
-	cgrp->max_depth = depth;
+	WRITE_ONCE(cgrp->max_depth, depth);
 
 	cgroup_kn_unlock(of->kn);
 

base-commit: eb3f4b7426cfd2b79d65b7d37155480b32259a11

Signature · 1 line
2.53.0
maintainer Applied
#1 lore raw

Hello,

Applied to cgroup/for-7.2.

Thanks.

--
tejun