1 #ifndef _LINUX_CGROUP_H
2 #define _LINUX_CGROUP_H
11 #include <linux/sched.h>
20 #include <linux/xattr.h>
48 #define SUBSYS(_x) _x ## _subsys_id,
49 #define IS_SUBSYS_ENABLED(option) IS_ENABLED(option)
50 enum cgroup_subsys_id {
54 #undef IS_SUBSYS_ENABLED
58 struct cgroup_subsys_state {
64 struct cgroup *cgroup;
90 static inline void __css_get(
struct cgroup_subsys_state *css,
int count)
102 static inline void css_get(
struct cgroup_subsys_state *css)
105 if (!
test_bit(CSS_ROOT, &css->flags))
109 static inline bool css_is_removed(
struct cgroup_subsys_state *css)
111 return test_bit(CSS_REMOVED, &css->flags);
120 extern bool __css_tryget(
struct cgroup_subsys_state *css);
121 static inline bool css_tryget(
struct cgroup_subsys_state *css)
123 if (
test_bit(CSS_ROOT, &css->flags))
133 extern void __css_put(
struct cgroup_subsys_state *css);
134 static inline void css_put(
struct cgroup_subsys_state *css)
136 if (!
test_bit(CSS_ROOT, &css->flags))
150 CGRP_NOTIFY_ON_RELEASE,
182 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
185 struct cgroup *top_cgroup;
208 struct mutex pidlist_mutex;
259 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
270 struct cgroup_map_cb {
284 #define CFTYPE_ONLY_ON_ROOT (1U << 0)
285 #define CFTYPE_NOT_ON_ROOT (1U << 1)
287 #define MAX_CFTYPE_NAME 64
295 char name[MAX_CFTYPE_NAME];
307 size_t max_write_len;
316 ssize_t (*
read)(
struct cgroup *cgrp,
struct cftype *cft,
323 u64 (*read_u64)(
struct cgroup *cgrp,
struct cftype *cft);
327 s64 (*read_s64)(
struct cgroup *cgrp,
struct cftype *cft);
334 int (*read_map)(
struct cgroup *
cont,
struct cftype *cft,
335 struct cgroup_map_cb *
cb);
340 int (*read_seq_string)(
struct cgroup *
cont,
struct cftype *cft,
343 ssize_t (*
write)(
struct cgroup *cgrp,
struct cftype *cft,
352 int (*write_u64)(
struct cgroup *cgrp,
struct cftype *cft,
u64 val);
356 int (*write_s64)(
struct cgroup *cgrp,
struct cftype *cft,
s64 val);
363 int (*write_string)(
struct cgroup *cgrp,
struct cftype *cft,
381 int (*register_event)(
struct cgroup *cgrp,
struct cftype *cft,
389 void (*unregister_event)(
struct cgroup *cgrp,
struct cftype *cft,
403 struct cgroup_scanner {
407 struct cgroup_scanner *
scan);
457 #define cgroup_taskset_for_each(task, skip_cgrp, tset) \
458 for ((task) = cgroup_taskset_first((tset)); (task); \
459 (task) = cgroup_taskset_next((tset))) \
460 if (!(skip_cgrp) || \
461 cgroup_taskset_cur_cgroup((tset)) != (skip_cgrp))
468 struct cgroup_subsys {
469 struct cgroup_subsys_state *(*create)(
struct cgroup *cgrp);
470 int (*pre_destroy)(
struct cgroup *cgrp);
476 void (*exit)(
struct cgroup *cgrp,
struct cgroup *old_cgrp,
478 void (*post_clone)(
struct cgroup *cgrp);
500 bool __DEPRECATED_clear_css_refs;
514 bool broken_hierarchy;
515 bool warned_broken_hierarchy;
517 #define MAX_CGROUP_TYPE_NAMELEN 32
534 struct cftype *base_cftypes;
535 struct cftype_set base_cftset;
541 #define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
542 #define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
544 #undef IS_SUBSYS_ENABLED
547 static inline struct cgroup_subsys_state *cgroup_subsys_state(
548 struct cgroup *cgrp,
int subsys_id)
550 return cgrp->subsys[subsys_id];
558 #define task_subsys_state_check(task, subsys_id, __c) \
559 rcu_dereference_check(task->cgroups->subsys[subsys_id], \
560 lockdep_is_held(&task->alloc_lock) || \
561 cgroup_lock_is_held() || (__c))
563 static inline struct cgroup_subsys_state *
566 return task_subsys_state_check(task, subsys_id,
false);
572 return task_subsys_state(task, subsys_id)->cgroup;
598 struct cgroup_iter *it);
621 void free_css_id(
struct cgroup_subsys *
ss,
struct cgroup_subsys_state *css);
625 struct cgroup_subsys_state *
css_lookup(
struct cgroup_subsys *
ss,
int id);
631 struct cgroup_subsys_state *
css_get_next(
struct cgroup_subsys *
ss,
int id,
632 struct cgroup_subsys_state *root,
int *foundid);
636 const struct cgroup_subsys_state *root);
639 unsigned short css_id(
struct cgroup_subsys_state *css);
640 unsigned short css_depth(
struct cgroup_subsys_state *css);