From 4485f579ebb0c63d46581748f4e160d58c307bbd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 7 May 2025 06:41:02 +0000 Subject: [PATCH] Revert "cgroup/cpuset: Fix race between newly created partition and dying one" This reverts commit cdb6e724e7c5713d13c5ad3340e9d71c3dd8c9fb which is commit a22b3d54de94f82ca057cc2ebf9496fa91ebf698 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I4ea3fb75e3ca0e6df8a880856205b12173028568 Signed-off-by: Greg Kroah-Hartman --- include/linux/cgroup-defs.h | 1 - include/linux/cgroup.h | 2 +- kernel/cgroup/cgroup.c | 6 ------ kernel/cgroup/cpuset.c | 20 +++----------------- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 252eed781a6e..38b2af336e4a 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -711,7 +711,6 @@ struct cgroup_subsys { void (*css_released)(struct cgroup_subsys_state *css); void (*css_free)(struct cgroup_subsys_state *css); void (*css_reset)(struct cgroup_subsys_state *css); - void (*css_killed)(struct cgroup_subsys_state *css); void (*css_rstat_flush)(struct cgroup_subsys_state *css, int cpu); int (*css_extra_stat_show)(struct seq_file *seq, struct cgroup_subsys_state *css); diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index fc1324ed597d..f8ef47f8a634 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -343,7 +343,7 @@ static inline u64 cgroup_id(const struct cgroup *cgrp) */ static inline bool css_is_dying(struct cgroup_subsys_state *css) { - return css->flags & CSS_DYING; + return !(css->flags & CSS_NO_REF) && percpu_ref_is_dying(&css->refcnt); } static inline void cgroup_get(struct cgroup *cgrp) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 3e4e0c7a2338..c5e11007504b 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5946,12 +5946,6 @@ static void kill_css(struct cgroup_subsys_state *css) if (css->flags & CSS_DYING) return; - /* - * Call css_killed(), if defined, before setting the CSS_DYING flag - */ - if (css->ss->css_killed) - css->ss->css_killed(css); - css->flags |= CSS_DYING; /* diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 11e03baafe57..7f91630d9d31 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3493,6 +3493,9 @@ static void cpuset_css_offline(struct cgroup_subsys_state *css) cpus_read_lock(); mutex_lock(&cpuset_mutex); + if (is_partition_valid(cs)) + update_prstate(cs, 0); + if (!cpuset_v2() && is_sched_load_balance(cs)) cpuset_update_flag(CS_SCHED_LOAD_BALANCE, cs, 0); @@ -3503,22 +3506,6 @@ static void cpuset_css_offline(struct cgroup_subsys_state *css) cpus_read_unlock(); } -static void cpuset_css_killed(struct cgroup_subsys_state *css) -{ - struct cpuset *cs = css_cs(css); - - cpus_read_lock(); - mutex_lock(&cpuset_mutex); - - /* Reset valid partition back to member */ - if (is_partition_valid(cs)) - update_prstate(cs, PRS_MEMBER); - - mutex_unlock(&cpuset_mutex); - cpus_read_unlock(); - -} - static void cpuset_css_free(struct cgroup_subsys_state *css) { struct cpuset *cs = css_cs(css); @@ -3640,7 +3627,6 @@ struct cgroup_subsys cpuset_cgrp_subsys = { .css_alloc = cpuset_css_alloc, .css_online = cpuset_css_online, .css_offline = cpuset_css_offline, - .css_killed = cpuset_css_killed, .css_free = cpuset_css_free, .can_attach = cpuset_can_attach, .cancel_attach = cpuset_cancel_attach,