summaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup-defs.h
diff options
context:
space:
mode:
authorAleksa Sarai <cyphar@cyphar.com>2015-06-09 07:32:09 -0400
committerTejun Heo <tj@kernel.org>2015-07-14 17:29:23 -0400
commit7e47682ea555e7c1edef1d8fd96e2aa4c12abe59 (patch)
tree6012cbc180ae7d633be4ed2ff1f1f6f7f188c1a0 /include/linux/cgroup-defs.h
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
cgroup: allow a cgroup subsystem to reject a fork
Add a new cgroup subsystem callback can_fork that conditionally states whether or not the fork is accepted or rejected by a cgroup policy. In addition, add a cancel_fork callback so that if an error occurs later in the forking process, any state modified by can_fork can be reverted. Allow for a private opaque pointer to be passed from cgroup_can_fork to cgroup_post_fork, allowing for the fork state to be stored by each subsystem separately. Also add a tagging system for cgroup_subsys.h to allow for CGROUP_<TAG> enumerations to be be defined and used. In addition, explicitly add a CGROUP_CANFORK_COUNT macro to make arrays easier to define. This is in preparation for implementing the pids cgroup subsystem. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/cgroup-defs.h')
-rw-r--r--include/linux/cgroup-defs.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 93755a629299..83e37d8c4d80 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -34,12 +34,17 @@ struct seq_file;
34 34
35/* define the enumeration of all cgroup subsystems */ 35/* define the enumeration of all cgroup subsystems */
36#define SUBSYS(_x) _x ## _cgrp_id, 36#define SUBSYS(_x) _x ## _cgrp_id,
37#define SUBSYS_TAG(_t) CGROUP_ ## _t, \
38 __unused_tag_ ## _t = CGROUP_ ## _t - 1,
37enum cgroup_subsys_id { 39enum cgroup_subsys_id {
38#include <linux/cgroup_subsys.h> 40#include <linux/cgroup_subsys.h>
39 CGROUP_SUBSYS_COUNT, 41 CGROUP_SUBSYS_COUNT,
40}; 42};
43#undef SUBSYS_TAG
41#undef SUBSYS 44#undef SUBSYS
42 45
46#define CGROUP_CANFORK_COUNT (CGROUP_CANFORK_END - CGROUP_CANFORK_START)
47
43/* bits in struct cgroup_subsys_state flags field */ 48/* bits in struct cgroup_subsys_state flags field */
44enum { 49enum {
45 CSS_NO_REF = (1 << 0), /* no reference counting for this css */ 50 CSS_NO_REF = (1 << 0), /* no reference counting for this css */
@@ -406,7 +411,9 @@ struct cgroup_subsys {
406 struct cgroup_taskset *tset); 411 struct cgroup_taskset *tset);
407 void (*attach)(struct cgroup_subsys_state *css, 412 void (*attach)(struct cgroup_subsys_state *css,
408 struct cgroup_taskset *tset); 413 struct cgroup_taskset *tset);
409 void (*fork)(struct task_struct *task); 414 int (*can_fork)(struct task_struct *task, void **priv_p);
415 void (*cancel_fork)(struct task_struct *task, void *priv);
416 void (*fork)(struct task_struct *task, void *priv);
410 void (*exit)(struct cgroup_subsys_state *css, 417 void (*exit)(struct cgroup_subsys_state *css,
411 struct cgroup_subsys_state *old_css, 418 struct cgroup_subsys_state *old_css,
412 struct task_struct *task); 419 struct task_struct *task);
@@ -491,6 +498,7 @@ static inline void cgroup_threadgroup_change_end(struct task_struct *tsk)
491 498
492#else /* CONFIG_CGROUPS */ 499#else /* CONFIG_CGROUPS */
493 500
501#define CGROUP_CANFORK_COUNT 0
494#define CGROUP_SUBSYS_COUNT 0 502#define CGROUP_SUBSYS_COUNT 0
495 503
496static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) {} 504static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) {}