Skip to content

Commit de6fef5

Browse files
committed
Merge tag 'cgroup-for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo: - The locking around cpuset hotplug processing has always been a bit of mess which was worked around by making hotplug processing asynchronous. The asynchronity isn't great and led to other issues. We tried to make the behavior synchronous a while ago but that led to lockdep splats. Waiman took another stab at cleaning up and making it synchronous. The patch has been in -next for well over a month and there haven't been any complaints, so fingers crossed. - Tracepoints added to help understanding rstat lock contentions. - A bunch of minor changes - doc updates, code cleanups and selftests. * tag 'cgroup-for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: (24 commits) cgroup/rstat: add cgroup_rstat_cpu_lock helpers and tracepoints selftests/cgroup: Drop define _GNU_SOURCE docs: cgroup-v1: Update page cache removal functions selftests/cgroup: fix uninitialized variables in test_zswap.c selftests/cgroup: cpu_hogger init: use {} instead of {NULL} selftests/cgroup: fix clang warnings: uninitialized fd variable selftests/cgroup: fix clang build failures for abs() calls cgroup/cpuset: Remove outdated comment in sched_partition_write() cgroup/cpuset: Fix incorrect top_cpuset flags cgroup/cpuset: Avoid clearing CS_SCHED_LOAD_BALANCE twice cgroup/cpuset: Statically initialize more members of top_cpuset cgroup: Avoid unnecessary looping in cgroup_no_v1() cgroup, legacy_freezer: update comment for freezer_css_offline() docs, cgroup: add entries for pids to cgroup-v2.rst cgroup: don't call cgroup1_pidlist_destroy_all() for v2 cgroup_freezer: update comment for freezer_css_online() cgroup/rstat: desc member cgrp in cgroup_rstat_flush_release cgroup/rstat: add cgroup_rstat_lock helpers and tracepoints cgroup/pids: Remove superfluous zeroing docs: cgroup-v1: Fix description for css_online ...
2 parents f4b0c4b + 21c38a3 commit de6fef5

27 files changed

+358
-223
lines changed

Documentation/admin-guide/cgroup-v1/cgroups.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ visible to cgroup_for_each_child/descendant_*() iterators. The
570570
subsystem may choose to fail creation by returning -errno. This
571571
callback can be used to implement reliable state sharing and
572572
propagation along the hierarchy. See the comment on
573-
cgroup_for_each_descendant_pre() for details.
573+
cgroup_for_each_live_descendant_pre() for details.
574574

575575
``void css_offline(struct cgroup *cgrp);``
576576
(cgroup_mutex held by caller)

Documentation/admin-guide/cgroup-v1/memcg_test.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Under below explanation, we assume CONFIG_SWAP=y.
102102
The logic is very clear. (About migration, see below)
103103

104104
Note:
105-
__remove_from_page_cache() is called by remove_from_page_cache()
105+
__filemap_remove_folio() is called by filemap_remove_folio()
106106
and __remove_mapping().
107107

108108
6. Shmem(tmpfs) Page Cache

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,15 @@ cpufreq governor about the minimum desired frequency which should always be
10581058
provided by a CPU, as well as the maximum desired frequency, which should not
10591059
be exceeded by a CPU.
10601060

1061-
WARNING: cgroup2 doesn't yet support control of realtime processes and
1062-
the cpu controller can only be enabled when all RT processes are in
1063-
the root cgroup. Be aware that system management software may already
1064-
have placed RT processes into nonroot cgroups during the system boot
1065-
process, and these processes may need to be moved to the root cgroup
1066-
before the cpu controller can be enabled.
1061+
WARNING: cgroup2 doesn't yet support control of realtime processes. For
1062+
a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group
1063+
scheduling of realtime processes, the cpu controller can only be enabled
1064+
when all RT processes are in the root cgroup. This limitation does
1065+
not apply if CONFIG_RT_GROUP_SCHED is disabled. Be aware that system
1066+
management software may already have placed RT processes into nonroot
1067+
cgroups during the system boot process, and these processes may need
1068+
to be moved to the root cgroup before the cpu controller can be enabled
1069+
with a CONFIG_RT_GROUP_SCHED enabled kernel.
10671070

10681071

10691072
CPU Interface Files
@@ -2190,11 +2193,25 @@ PID Interface Files
21902193
Hard limit of number of processes.
21912194

21922195
pids.current
2193-
A read-only single value file which exists on all cgroups.
2196+
A read-only single value file which exists on non-root cgroups.
21942197

21952198
The number of processes currently in the cgroup and its
21962199
descendants.
21972200

2201+
pids.peak
2202+
A read-only single value file which exists on non-root cgroups.
2203+
2204+
The maximum value that the number of processes in the cgroup and its
2205+
descendants has ever reached.
2206+
2207+
pids.events
2208+
A read-only flat-keyed file which exists on non-root cgroups. The
2209+
following entries are defined. Unless specified otherwise, a value
2210+
change in this file generates a file modified event.
2211+
2212+
max
2213+
Number of times fork failed because limit was hit.
2214+
21982215
Organisational operations are not blocked by cgroup policies, so it is
21992216
possible to have pids.current > pids.max. This can be done by either
22002217
setting the limit to be smaller than pids.current, or attaching enough

include/linux/cgroup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
690690
void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
691691
void cgroup_rstat_flush(struct cgroup *cgrp);
692692
void cgroup_rstat_flush_hold(struct cgroup *cgrp);
693-
void cgroup_rstat_flush_release(void);
693+
void cgroup_rstat_flush_release(struct cgroup *cgrp);
694694

695695
/*
696696
* Basic resource stats.

include/linux/cpuset.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ extern int cpuset_init(void);
7070
extern void cpuset_init_smp(void);
7171
extern void cpuset_force_rebuild(void);
7272
extern void cpuset_update_active_cpus(void);
73-
extern void cpuset_wait_for_hotplug(void);
7473
extern void inc_dl_tasks_cs(struct task_struct *task);
7574
extern void dec_dl_tasks_cs(struct task_struct *task);
7675
extern void cpuset_lock(void);
@@ -185,8 +184,6 @@ static inline void cpuset_update_active_cpus(void)
185184
partition_sched_domains(1, NULL, NULL);
186185
}
187186

188-
static inline void cpuset_wait_for_hotplug(void) { }
189-
190187
static inline void inc_dl_tasks_cs(struct task_struct *task) { }
191188
static inline void dec_dl_tasks_cs(struct task_struct *task) { }
192189
static inline void cpuset_lock(void) { }

include/trace/events/cgroup.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,98 @@ DEFINE_EVENT(cgroup_event, cgroup_notify_frozen,
204204
TP_ARGS(cgrp, path, val)
205205
);
206206

207+
DECLARE_EVENT_CLASS(cgroup_rstat,
208+
209+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
210+
211+
TP_ARGS(cgrp, cpu, contended),
212+
213+
TP_STRUCT__entry(
214+
__field( int, root )
215+
__field( int, level )
216+
__field( u64, id )
217+
__field( int, cpu )
218+
__field( bool, contended )
219+
),
220+
221+
TP_fast_assign(
222+
__entry->root = cgrp->root->hierarchy_id;
223+
__entry->id = cgroup_id(cgrp);
224+
__entry->level = cgrp->level;
225+
__entry->cpu = cpu;
226+
__entry->contended = contended;
227+
),
228+
229+
TP_printk("root=%d id=%llu level=%d cpu=%d lock contended:%d",
230+
__entry->root, __entry->id, __entry->level,
231+
__entry->cpu, __entry->contended)
232+
);
233+
234+
/* Related to global: cgroup_rstat_lock */
235+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_lock_contended,
236+
237+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
238+
239+
TP_ARGS(cgrp, cpu, contended)
240+
);
241+
242+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_locked,
243+
244+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
245+
246+
TP_ARGS(cgrp, cpu, contended)
247+
);
248+
249+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_unlock,
250+
251+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
252+
253+
TP_ARGS(cgrp, cpu, contended)
254+
);
255+
256+
/* Related to per CPU: cgroup_rstat_cpu_lock */
257+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_lock_contended,
258+
259+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
260+
261+
TP_ARGS(cgrp, cpu, contended)
262+
);
263+
264+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_lock_contended_fastpath,
265+
266+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
267+
268+
TP_ARGS(cgrp, cpu, contended)
269+
);
270+
271+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_locked,
272+
273+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
274+
275+
TP_ARGS(cgrp, cpu, contended)
276+
);
277+
278+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_locked_fastpath,
279+
280+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
281+
282+
TP_ARGS(cgrp, cpu, contended)
283+
);
284+
285+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_unlock,
286+
287+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
288+
289+
TP_ARGS(cgrp, cpu, contended)
290+
);
291+
292+
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_unlock_fastpath,
293+
294+
TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),
295+
296+
TP_ARGS(cgrp, cpu, contended)
297+
);
298+
207299
#endif /* _TRACE_CGROUP_H */
208300

209301
/* This part must be outside protection */

kernel/cgroup/cgroup-v1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ static int __init cgroup_no_v1(char *str)
13351335
continue;
13361336

13371337
cgroup_no_v1_mask |= 1 << i;
1338+
break;
13381339
}
13391340
}
13401341
return 1;

kernel/cgroup/cgroup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5368,7 +5368,8 @@ static void css_free_rwork_fn(struct work_struct *work)
53685368
} else {
53695369
/* cgroup free path */
53705370
atomic_dec(&cgrp->root->nr_cgrps);
5371-
cgroup1_pidlist_destroy_all(cgrp);
5371+
if (!cgroup_on_dfl(cgrp))
5372+
cgroup1_pidlist_destroy_all(cgrp);
53725373
cancel_work_sync(&cgrp->release_agent_work);
53735374
bpf_cgrp_storage_free(cgrp);
53745375

0 commit comments

Comments
 (0)