Skip to content

Commit 27270b3

Browse files
committed
cgroup/cpuset: Fix error handling in remote_partition_disable()
jira NONE_AUTOMATION Rebuild_History Non-Buildable kernel-5.14.0-570.17.1.el9_6 commit-author Waiman Long <[email protected]> commit 8bf450f When remote_partition_disable() is called to disable a remote partition, it always sets the partition to an invalid partition state. It should only do so if an error code (prs_err) has been set. Correct that and add proper error code in places where remote_partition_disable() is called due to error. Fixes: 181c8e0 ("cgroup/cpuset: Introduce remote partition") Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]> (cherry picked from commit 8bf450f) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 651daba commit 27270b3

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

kernel/cgroup/cpuset.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
16791679
list_add(&cs->remote_sibling, &remote_children);
16801680
spin_unlock_irq(&callback_lock);
16811681
update_unbound_workqueue_cpumask(isolcpus_updated);
1682+
cs->prs_err = 0;
16821683

16831684
/*
16841685
* Propagate changes in top_cpuset's effective_cpus down the hierarchy.
@@ -1709,9 +1710,11 @@ static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp)
17091710
list_del_init(&cs->remote_sibling);
17101711
isolcpus_updated = partition_xcpus_del(cs->partition_root_state,
17111712
NULL, tmp->new_cpus);
1712-
cs->partition_root_state = -cs->partition_root_state;
1713-
if (!cs->prs_err)
1714-
cs->prs_err = PERR_INVCPUS;
1713+
if (cs->prs_err)
1714+
cs->partition_root_state = -cs->partition_root_state;
1715+
else
1716+
cs->partition_root_state = PRS_MEMBER;
1717+
17151718
reset_partition_data(cs);
17161719
spin_unlock_irq(&callback_lock);
17171720
update_unbound_workqueue_cpumask(isolcpus_updated);
@@ -1744,8 +1747,10 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *newmask,
17441747

17451748
WARN_ON_ONCE(!cpumask_subset(cs->effective_xcpus, subpartitions_cpus));
17461749

1747-
if (cpumask_empty(newmask))
1750+
if (cpumask_empty(newmask)) {
1751+
cs->prs_err = PERR_CPUSEMPTY;
17481752
goto invalidate;
1753+
}
17491754

17501755
adding = cpumask_andnot(tmp->addmask, newmask, cs->effective_xcpus);
17511756
deleting = cpumask_andnot(tmp->delmask, cs->effective_xcpus, newmask);
@@ -1755,10 +1760,15 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *newmask,
17551760
* not allocated to other partitions and there are effective_cpus
17561761
* left in the top cpuset.
17571762
*/
1758-
if (adding && (!capable(CAP_SYS_ADMIN) ||
1759-
cpumask_intersects(tmp->addmask, subpartitions_cpus) ||
1760-
cpumask_subset(top_cpuset.effective_cpus, tmp->addmask)))
1761-
goto invalidate;
1763+
if (adding) {
1764+
if (!capable(CAP_SYS_ADMIN))
1765+
cs->prs_err = PERR_ACCESS;
1766+
else if (cpumask_intersects(tmp->addmask, subpartitions_cpus) ||
1767+
cpumask_subset(top_cpuset.effective_cpus, tmp->addmask))
1768+
cs->prs_err = PERR_NOCPUS;
1769+
if (cs->prs_err)
1770+
goto invalidate;
1771+
}
17621772

17631773
spin_lock_irq(&callback_lock);
17641774
if (adding)
@@ -1874,7 +1884,7 @@ static bool prstate_housekeeping_conflict(int prstate, struct cpumask *new_cpus)
18741884
* The partcmd_update command is used by update_cpumasks_hier() with newmask
18751885
* NULL and update_cpumask() with newmask set. The partcmd_invalidate is used
18761886
* by update_cpumask() with NULL newmask. In both cases, the callers won't
1877-
* check for error and so partition_root_state and prs_error will be updated
1887+
* check for error and so partition_root_state and prs_err will be updated
18781888
* directly.
18791889
*/
18801890
static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
@@ -4526,6 +4536,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
45264536

45274537
if (remote && cpumask_empty(&new_cpus) &&
45284538
partition_is_populated(cs, NULL)) {
4539+
cs->prs_err = PERR_HOTPLUG;
45294540
remote_partition_disable(cs, tmp);
45304541
compute_effective_cpumask(&new_cpus, cs, parent);
45314542
remote = false;

0 commit comments

Comments
 (0)