Skip to content

Commit 3dbdb38

Browse files
committed
Merge branch 'for-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo: - cgroup.kill is added which implements atomic killing of the whole subtree. Down the line, this should be able to replace the multiple userland implementations of "keep killing till empty". - PSI can now be turned off at boot time to avoid overhead for configurations which don't care about PSI. * 'for-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: make per-cgroup pressure stall tracking configurable cgroup: Fix kernel-doc cgroup: inline cgroup_task_freeze() tests/cgroup: test cgroup.kill tests/cgroup: move cg_wait_for(), cg_prepare_for_wait() tests/cgroup: use cgroup.kill in cg_killall() docs/cgroup: add entry for cgroup.kill cgroup: introduce cgroup.kill
2 parents e267992 + 3958e2d commit 3dbdb38

File tree

13 files changed

+569
-108
lines changed

13 files changed

+569
-108
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,21 @@ All cgroup core files are prefixed with "cgroup."
953953
it's possible to delete a frozen (and empty) cgroup, as well as
954954
create new sub-cgroups.
955955

956+
cgroup.kill
957+
A write-only single value file which exists in non-root cgroups.
958+
The only allowed value is "1".
959+
960+
Writing "1" to the file causes the cgroup and all descendant cgroups to
961+
be killed. This means that all processes located in the affected cgroup
962+
tree will be killed via SIGKILL.
963+
964+
Killing a cgroup tree will deal with concurrent forks appropriately and
965+
is protected against migrations.
966+
967+
In a threaded cgroup, writing this file fails with EOPNOTSUPP as
968+
killing cgroups is a process directed operation, i.e. it affects
969+
the whole thread-group.
970+
956971
Controllers
957972
===========
958973

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,16 +497,21 @@
497497
ccw_timeout_log [S390]
498498
See Documentation/s390/common_io.rst for details.
499499

500-
cgroup_disable= [KNL] Disable a particular controller
501-
Format: {name of the controller(s) to disable}
500+
cgroup_disable= [KNL] Disable a particular controller or optional feature
501+
Format: {name of the controller(s) or feature(s) to disable}
502502
The effects of cgroup_disable=foo are:
503503
- foo isn't auto-mounted if you mount all cgroups in
504504
a single hierarchy
505505
- foo isn't visible as an individually mountable
506506
subsystem
507+
- if foo is an optional feature then the feature is
508+
disabled and corresponding cgroup files are not
509+
created
507510
{Currently only "memory" controller deal with this and
508511
cut the overhead, others just disable the usage. So
509512
only cgroup_disable=memory is actually worthy}
513+
Specifying "pressure" disables per-cgroup pressure
514+
stall information accounting feature
510515

511516
cgroup_no_v1= [KNL] Disable cgroup controllers and named hierarchies in v1
512517
Format: { { controller | "all" | "named" }

include/linux/cgroup-defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ enum {
7171

7272
/* Cgroup is frozen. */
7373
CGRP_FROZEN,
74+
75+
/* Control group has to be killed. */
76+
CGRP_KILL,
7477
};
7578

7679
/* cgroup_root->flags */
@@ -110,6 +113,7 @@ enum {
110113
CFTYPE_NO_PREFIX = (1 << 3), /* (DON'T USE FOR NEW FILES) no subsys prefix */
111114
CFTYPE_WORLD_WRITABLE = (1 << 4), /* (DON'T USE FOR NEW FILES) S_IWUGO */
112115
CFTYPE_DEBUG = (1 << 5), /* create when cgroup_debug */
116+
CFTYPE_PRESSURE = (1 << 6), /* only if pressure feature is enabled */
113117

114118
/* internal flags, do not use outside cgroup core proper */
115119
__CFTYPE_ONLY_ON_DFL = (1 << 16), /* only on default hierarchy */

include/linux/cgroup.h

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
676676
return &cgrp->psi;
677677
}
678678

679+
bool cgroup_psi_enabled(void);
680+
679681
static inline void cgroup_init_kthreadd(void)
680682
{
681683
/*
@@ -735,6 +737,11 @@ static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
735737
return NULL;
736738
}
737739

740+
static inline bool cgroup_psi_enabled(void)
741+
{
742+
return false;
743+
}
744+
738745
static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
739746
struct cgroup *ancestor)
740747
{
@@ -906,20 +913,6 @@ void cgroup_freeze(struct cgroup *cgrp, bool freeze);
906913
void cgroup_freezer_migrate_task(struct task_struct *task, struct cgroup *src,
907914
struct cgroup *dst);
908915

909-
static inline bool cgroup_task_freeze(struct task_struct *task)
910-
{
911-
bool ret;
912-
913-
if (task->flags & PF_KTHREAD)
914-
return false;
915-
916-
rcu_read_lock();
917-
ret = test_bit(CGRP_FREEZE, &task_dfl_cgroup(task)->flags);
918-
rcu_read_unlock();
919-
920-
return ret;
921-
}
922-
923916
static inline bool cgroup_task_frozen(struct task_struct *task)
924917
{
925918
return task->frozen;
@@ -929,10 +922,6 @@ static inline bool cgroup_task_frozen(struct task_struct *task)
929922

930923
static inline void cgroup_enter_frozen(void) { }
931924
static inline void cgroup_leave_frozen(bool always_leave) { }
932-
static inline bool cgroup_task_freeze(struct task_struct *task)
933-
{
934-
return false;
935-
}
936925
static inline bool cgroup_task_frozen(struct task_struct *task)
937926
{
938927
return false;

0 commit comments

Comments
 (0)