Skip to content

Commit ea1ca66

Browse files
committed
Merge branch 'for-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo: "Nothing too interesting. The only two noticeable changes are a subtle cpuset behavior fix and trace event id field being expanded to u64 from int. Most others are code cleanups" * 'for-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cpuset: convert 'allowed' in __cpuset_node_allowed() to be boolean cgroup/rstat: check updated_next only for root cgroup: rstat: explicitly put loop variant in while cgroup: return early if it is already on preloaded list cgroup/cpuset: Don't let child cpusets restrict parent in default hierarchy cgroup: Trace event cgroup id fields should be u64 cgroup: fix a typo in comment cgroup: get the wrong css for css_alloc() during cgroup_init_subsys() cgroup: rstat: Mark benign data race to silence KCSAN
2 parents 68514da + d4296fa commit ea1ca66

File tree

5 files changed

+38
-49
lines changed

5 files changed

+38
-49
lines changed

include/linux/cgroup-defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ struct cgroup {
413413
/*
414414
* The bitmask of subsystems enabled on the child cgroups.
415415
* ->subtree_control is the one configured through
416-
* "cgroup.subtree_control" while ->child_ss_mask is the effective
416+
* "cgroup.subtree_control" while ->subtree_ss_mask is the effective
417417
* one which may have more subsystems enabled. Controller knobs
418418
* are made available iff it's enabled in ->subtree_control.
419419
*/

include/trace/events/cgroup.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ DECLARE_EVENT_CLASS(cgroup,
5959

6060
TP_STRUCT__entry(
6161
__field( int, root )
62-
__field( int, id )
6362
__field( int, level )
63+
__field( u64, id )
6464
__string( path, path )
6565
),
6666

@@ -71,7 +71,7 @@ DECLARE_EVENT_CLASS(cgroup,
7171
__assign_str(path, path);
7272
),
7373

74-
TP_printk("root=%d id=%d level=%d path=%s",
74+
TP_printk("root=%d id=%llu level=%d path=%s",
7575
__entry->root, __entry->id, __entry->level, __get_str(path))
7676
);
7777

@@ -126,8 +126,8 @@ DECLARE_EVENT_CLASS(cgroup_migrate,
126126

127127
TP_STRUCT__entry(
128128
__field( int, dst_root )
129-
__field( int, dst_id )
130129
__field( int, dst_level )
130+
__field( u64, dst_id )
131131
__field( int, pid )
132132
__string( dst_path, path )
133133
__string( comm, task->comm )
@@ -142,7 +142,7 @@ DECLARE_EVENT_CLASS(cgroup_migrate,
142142
__assign_str(comm, task->comm);
143143
),
144144

145-
TP_printk("dst_root=%d dst_id=%d dst_level=%d dst_path=%s pid=%d comm=%s",
145+
TP_printk("dst_root=%d dst_id=%llu dst_level=%d dst_path=%s pid=%d comm=%s",
146146
__entry->dst_root, __entry->dst_id, __entry->dst_level,
147147
__get_str(dst_path), __entry->pid, __get_str(comm))
148148
);
@@ -171,8 +171,8 @@ DECLARE_EVENT_CLASS(cgroup_event,
171171

172172
TP_STRUCT__entry(
173173
__field( int, root )
174-
__field( int, id )
175174
__field( int, level )
175+
__field( u64, id )
176176
__string( path, path )
177177
__field( int, val )
178178
),
@@ -185,7 +185,7 @@ DECLARE_EVENT_CLASS(cgroup_event,
185185
__entry->val = val;
186186
),
187187

188-
TP_printk("root=%d id=%d level=%d path=%s val=%d",
188+
TP_printk("root=%d id=%llu level=%d path=%s val=%d",
189189
__entry->root, __entry->id, __entry->level, __get_str(path),
190190
__entry->val)
191191
);

kernel/cgroup/cgroup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,11 +2651,11 @@ void cgroup_migrate_add_src(struct css_set *src_cset,
26512651
if (src_cset->dead)
26522652
return;
26532653

2654-
src_cgrp = cset_cgroup_from_root(src_cset, dst_cgrp->root);
2655-
26562654
if (!list_empty(&src_cset->mg_preload_node))
26572655
return;
26582656

2657+
src_cgrp = cset_cgroup_from_root(src_cset, dst_cgrp->root);
2658+
26592659
WARN_ON(src_cset->mg_src_cgrp);
26602660
WARN_ON(src_cset->mg_dst_cgrp);
26612661
WARN_ON(!list_empty(&src_cset->mg_tasks));
@@ -5743,7 +5743,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
57435743

57445744
/* Create the root cgroup state for this subsystem */
57455745
ss->root = &cgrp_dfl_root;
5746-
css = ss->css_alloc(cgroup_css(&cgrp_dfl_root.cgrp, ss));
5746+
css = ss->css_alloc(NULL);
57475747
/* We don't handle early failures gracefully */
57485748
BUG_ON(IS_ERR(css));
57495749
init_and_link_css(css, ss, &cgrp_dfl_root.cgrp);

kernel/cgroup/cpuset.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -616,19 +616,11 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
616616
struct cpuset *c, *par;
617617
int ret;
618618

619-
rcu_read_lock();
620-
621-
/* Each of our child cpusets must be a subset of us */
622-
ret = -EBUSY;
623-
cpuset_for_each_child(c, css, cur)
624-
if (!is_cpuset_subset(c, trial))
625-
goto out;
626-
627-
/* Remaining checks don't apply to root cpuset */
628-
ret = 0;
619+
/* The checks don't apply to root cpuset */
629620
if (cur == &top_cpuset)
630-
goto out;
621+
return 0;
631622

623+
rcu_read_lock();
632624
par = parent_cs(cur);
633625

634626
/* On legacy hierarchy, we must be a subset of our parent cpuset. */
@@ -3536,7 +3528,7 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs)
35363528
bool __cpuset_node_allowed(int node, gfp_t gfp_mask)
35373529
{
35383530
struct cpuset *cs; /* current cpuset ancestors */
3539-
int allowed; /* is allocation in zone z allowed? */
3531+
bool allowed; /* is allocation in zone z allowed? */
35403532
unsigned long flags;
35413533

35423534
if (in_interrupt())

kernel/cgroup/rstat.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
3535
* instead of NULL, we can tell whether @cgrp is on the list by
3636
* testing the next pointer for NULL.
3737
*/
38-
if (cgroup_rstat_cpu(cgrp, cpu)->updated_next)
38+
if (data_race(cgroup_rstat_cpu(cgrp, cpu)->updated_next))
3939
return;
4040

4141
raw_spin_lock_irqsave(cpu_lock, flags);
@@ -88,6 +88,7 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
8888
struct cgroup *root, int cpu)
8989
{
9090
struct cgroup_rstat_cpu *rstatc;
91+
struct cgroup *parent;
9192

9293
if (pos == root)
9394
return NULL;
@@ -96,10 +97,14 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
9697
* We're gonna walk down to the first leaf and visit/remove it. We
9798
* can pick whatever unvisited node as the starting point.
9899
*/
99-
if (!pos)
100+
if (!pos) {
100101
pos = root;
101-
else
102+
/* return NULL if this subtree is not on-list */
103+
if (!cgroup_rstat_cpu(pos, cpu)->updated_next)
104+
return NULL;
105+
} else {
102106
pos = cgroup_parent(pos);
107+
}
103108

104109
/* walk down to the first leaf */
105110
while (true) {
@@ -115,33 +120,25 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
115120
* However, due to the way we traverse, @pos will be the first
116121
* child in most cases. The only exception is @root.
117122
*/
118-
if (rstatc->updated_next) {
119-
struct cgroup *parent = cgroup_parent(pos);
120-
121-
if (parent) {
122-
struct cgroup_rstat_cpu *prstatc;
123-
struct cgroup **nextp;
124-
125-
prstatc = cgroup_rstat_cpu(parent, cpu);
126-
nextp = &prstatc->updated_children;
127-
while (true) {
128-
struct cgroup_rstat_cpu *nrstatc;
129-
130-
nrstatc = cgroup_rstat_cpu(*nextp, cpu);
131-
if (*nextp == pos)
132-
break;
133-
WARN_ON_ONCE(*nextp == parent);
134-
nextp = &nrstatc->updated_next;
135-
}
136-
*nextp = rstatc->updated_next;
137-
}
123+
parent = cgroup_parent(pos);
124+
if (parent) {
125+
struct cgroup_rstat_cpu *prstatc;
126+
struct cgroup **nextp;
138127

139-
rstatc->updated_next = NULL;
140-
return pos;
128+
prstatc = cgroup_rstat_cpu(parent, cpu);
129+
nextp = &prstatc->updated_children;
130+
while (*nextp != pos) {
131+
struct cgroup_rstat_cpu *nrstatc;
132+
133+
nrstatc = cgroup_rstat_cpu(*nextp, cpu);
134+
WARN_ON_ONCE(*nextp == parent);
135+
nextp = &nrstatc->updated_next;
136+
}
137+
*nextp = rstatc->updated_next;
141138
}
142139

143-
/* only happens for @root */
144-
return NULL;
140+
rstatc->updated_next = NULL;
141+
return pos;
145142
}
146143

147144
/* see cgroup_rstat_flush() */

0 commit comments

Comments
 (0)