Skip to content

Commit 0f3adb8

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Miscellaneous code cleanup
Use more descriptive variable names for update_prstate(), remove unnecessary code and fix some typos. There is no functional change. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 1f8c543 commit 0f3adb8

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

kernel/cgroup/cpuset.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ enum subparts_cmd {
11141114
* cpus_allowed can be granted or an error code will be returned.
11151115
*
11161116
* For partcmd_disable, the cpuset is being transofrmed from a partition
1117-
* root back to a non-partition root. any CPUs in cpus_allowed that are in
1117+
* root back to a non-partition root. Any CPUs in cpus_allowed that are in
11181118
* parent's subparts_cpus will be taken away from that cpumask and put back
11191119
* into parent's effective_cpus. 0 should always be returned.
11201120
*
@@ -1225,7 +1225,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,
12251225
/*
12261226
* partcmd_update w/o newmask:
12271227
*
1228-
* addmask = cpus_allowed & parent->effectiveb_cpus
1228+
* addmask = cpus_allowed & parent->effective_cpus
12291229
*
12301230
* Note that parent's subparts_cpus may have been
12311231
* pre-shrunk in case there is a change in the cpu list.
@@ -1365,12 +1365,12 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)
13651365
case PRS_DISABLED:
13661366
/*
13671367
* If parent is not a partition root or an
1368-
* invalid partition root, clear the state
1369-
* state and the CS_CPU_EXCLUSIVE flag.
1368+
* invalid partition root, clear its state
1369+
* and its CS_CPU_EXCLUSIVE flag.
13701370
*/
13711371
WARN_ON_ONCE(cp->partition_root_state
13721372
!= PRS_ERROR);
1373-
cp->partition_root_state = 0;
1373+
cp->partition_root_state = PRS_DISABLED;
13741374

13751375
/*
13761376
* clear_bit() is an atomic operation and
@@ -1937,30 +1937,28 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
19371937

19381938
/*
19391939
* update_prstate - update partititon_root_state
1940-
* cs: the cpuset to update
1941-
* val: 0 - disabled, 1 - enabled
1940+
* cs: the cpuset to update
1941+
* new_prs: new partition root state
19421942
*
19431943
* Call with cpuset_mutex held.
19441944
*/
1945-
static int update_prstate(struct cpuset *cs, int val)
1945+
static int update_prstate(struct cpuset *cs, int new_prs)
19461946
{
19471947
int err;
19481948
struct cpuset *parent = parent_cs(cs);
1949-
struct tmpmasks tmp;
1949+
struct tmpmasks tmpmask;
19501950

1951-
if ((val != 0) && (val != 1))
1952-
return -EINVAL;
1953-
if (val == cs->partition_root_state)
1951+
if (new_prs == cs->partition_root_state)
19541952
return 0;
19551953

19561954
/*
19571955
* Cannot force a partial or invalid partition root to a full
19581956
* partition root.
19591957
*/
1960-
if (val && cs->partition_root_state)
1958+
if (new_prs && (cs->partition_root_state < 0))
19611959
return -EINVAL;
19621960

1963-
if (alloc_cpumasks(NULL, &tmp))
1961+
if (alloc_cpumasks(NULL, &tmpmask))
19641962
return -ENOMEM;
19651963

19661964
err = -EINVAL;
@@ -1978,7 +1976,7 @@ static int update_prstate(struct cpuset *cs, int val)
19781976
goto out;
19791977

19801978
err = update_parent_subparts_cpumask(cs, partcmd_enable,
1981-
NULL, &tmp);
1979+
NULL, &tmpmask);
19821980
if (err) {
19831981
update_flag(CS_CPU_EXCLUSIVE, cs, 0);
19841982
goto out;
@@ -1990,18 +1988,18 @@ static int update_prstate(struct cpuset *cs, int val)
19901988
* CS_CPU_EXCLUSIVE bit.
19911989
*/
19921990
if (cs->partition_root_state == PRS_ERROR) {
1993-
cs->partition_root_state = 0;
1991+
cs->partition_root_state = PRS_DISABLED;
19941992
update_flag(CS_CPU_EXCLUSIVE, cs, 0);
19951993
err = 0;
19961994
goto out;
19971995
}
19981996

19991997
err = update_parent_subparts_cpumask(cs, partcmd_disable,
2000-
NULL, &tmp);
1998+
NULL, &tmpmask);
20011999
if (err)
20022000
goto out;
20032001

2004-
cs->partition_root_state = 0;
2002+
cs->partition_root_state = PRS_DISABLED;
20052003

20062004
/* Turning off CS_CPU_EXCLUSIVE will not return error */
20072005
update_flag(CS_CPU_EXCLUSIVE, cs, 0);
@@ -2015,11 +2013,11 @@ static int update_prstate(struct cpuset *cs, int val)
20152013
update_tasks_cpumask(parent);
20162014

20172015
if (parent->child_ecpus_count)
2018-
update_sibling_cpumasks(parent, cs, &tmp);
2016+
update_sibling_cpumasks(parent, cs, &tmpmask);
20192017

20202018
rebuild_sched_domains_locked();
20212019
out:
2022-
free_cpumasks(NULL, &tmp);
2020+
free_cpumasks(NULL, &tmpmask);
20232021
return err;
20242022
}
20252023

@@ -3060,7 +3058,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
30603058
goto retry;
30613059
}
30623060

3063-
parent = parent_cs(cs);
3061+
parent = parent_cs(cs);
30643062
compute_effective_cpumask(&new_cpus, cs, parent);
30653063
nodes_and(new_mems, cs->mems_allowed, parent->effective_mems);
30663064

0 commit comments

Comments
 (0)