* [PATCH] cgroup: replace BUG_ON()s in compare_css_sets() with WARN_ON_ONCE()
@ 2026-11-05 12:48 Shaojie Sun
2026-11-05 15:52 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Shaojie Sun @ 2026-11-05 12:48 UTC (permalink / raw)
To: Tejun Heo, Johannes Weiner, Michal Koutný
Cc: cgroups, linux-kernel, Shaojie Sun
compare_css_sets() walks the cgrp_links lists of two css_sets in
lockstep. Both lists carry exactly one link per hierarchy root, so a
length or ordering mismatch just means the two css_sets are not the same
one, which is what the function already reports with "return false".
The caller keeps walking the hash chain and allocates a new css_set if
nothing matches.
None of these checks is a user-reachable error path; they are invariant
checks on kernel-internal bookkeeping that are expected never to fire,
and each one has a way out.
No functional change for a consistent state.
Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
---
kernel/cgroup/cgroup.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index a284225f8dc9..81c82d137fa2 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1024,10 +1024,12 @@ static bool compare_css_sets(struct css_set *cset,
l2 = l2->next;
/* See if we reached the end - both lists are equal length. */
if (l1 == &cset->cgrp_links) {
- BUG_ON(l2 != &old_cset->cgrp_links);
+ if (WARN_ON_ONCE(l2 != &old_cset->cgrp_links))
+ return false;
break;
} else {
- BUG_ON(l2 == &old_cset->cgrp_links);
+ if (WARN_ON_ONCE(l2 == &old_cset->cgrp_links))
+ return false;
}
/* Locate the cgroups associated with these links. */
link1 = list_entry(l1, struct cgrp_cset_link, cgrp_link);
@@ -1035,7 +1037,8 @@ static bool compare_css_sets(struct css_set *cset,
cgrp1 = link1->cgrp;
cgrp2 = link2->cgrp;
/* Hierarchies should be linked in the same order. */
- BUG_ON(cgrp1->root != cgrp2->root);
+ if (WARN_ON_ONCE(cgrp1->root != cgrp2->root))
+ return false;
/*
* If this hierarchy is the hierarchy of the cgroup
--
2.50.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] cgroup: replace BUG_ON()s in compare_css_sets() with WARN_ON_ONCE()
2026-11-05 12:48 [PATCH] cgroup: replace BUG_ON()s in compare_css_sets() with WARN_ON_ONCE() Shaojie Sun
@ 2026-11-05 15:52 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2026-11-05 15:52 UTC (permalink / raw)
To: Shaojie Sun; +Cc: Johannes Weiner, Michal Koutný, cgroups, linux-kernel
On Thu, Nov 05, 2026 at 08:48:13PM +0800, Shaojie Sun wrote:
> compare_css_sets() walks the cgrp_links lists of two css_sets in
> lockstep. Both lists carry exactly one link per hierarchy root, so a
> length or ordering mismatch just means the two css_sets are not the same
> one, which is what the function already reports with "return false".
> The caller keeps walking the hash chain and allocates a new css_set if
> nothing matches.
>
> None of these checks is a user-reachable error path; they are invariant
> checks on kernel-internal bookkeeping that are expected never to fire,
> and each one has a way out.
>
> No functional change for a consistent state.
Why are we changing this now? These never fired, and if they ever fire,
we're in a very deep doodoo.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 12:48 [PATCH] cgroup: replace BUG_ON()s in compare_css_sets() with WARN_ON_ONCE() Shaojie Sun
2026-11-05 15:52 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®