cgroup.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. #ifndef _LINUX_CGROUP_H
  2. #define _LINUX_CGROUP_H
  3. /*
  4. * cgroup interface
  5. *
  6. * Copyright (C) 2003 BULL SA
  7. * Copyright (C) 2004-2006 Silicon Graphics, Inc.
  8. *
  9. */
  10. #include <linux/sched.h>
  11. #include <linux/cpumask.h>
  12. #include <linux/nodemask.h>
  13. #include <linux/rcupdate.h>
  14. #include <linux/cgroupstats.h>
  15. #include <linux/prio_heap.h>
  16. #include <linux/rwsem.h>
  17. #include <linux/idr.h>
  18. #include <linux/workqueue.h>
  19. #ifdef CONFIG_CGROUPS
  20. struct cgroupfs_root;
  21. struct cgroup_subsys;
  22. struct inode;
  23. struct cgroup;
  24. struct css_id;
  25. extern int cgroup_init_early(void);
  26. extern int cgroup_init(void);
  27. extern void cgroup_lock(void);
  28. extern int cgroup_lock_is_held(void);
  29. extern bool cgroup_lock_live_group(struct cgroup *cgrp);
  30. extern void cgroup_unlock(void);
  31. extern void cgroup_fork(struct task_struct *p);
  32. extern void cgroup_fork_callbacks(struct task_struct *p);
  33. extern void cgroup_post_fork(struct task_struct *p);
  34. extern void cgroup_exit(struct task_struct *p, int run_callbacks);
  35. extern int cgroupstats_build(struct cgroupstats *stats,
  36. struct dentry *dentry);
  37. extern int cgroup_load_subsys(struct cgroup_subsys *ss);
  38. extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
  39. extern const struct file_operations proc_cgroup_operations;
  40. /* Define the enumeration of all builtin cgroup subsystems */
  41. #define SUBSYS(_x) _x ## _subsys_id,
  42. enum cgroup_subsys_id {
  43. #include <linux/cgroup_subsys.h>
  44. CGROUP_BUILTIN_SUBSYS_COUNT
  45. };
  46. #undef SUBSYS
  47. /*
  48. * This define indicates the maximum number of subsystems that can be loaded
  49. * at once. We limit to this many since cgroupfs_root has subsys_bits to keep
  50. * track of all of them.
  51. */
  52. #define CGROUP_SUBSYS_COUNT (BITS_PER_BYTE*sizeof(unsigned long))
  53. /* Per-subsystem/per-cgroup state maintained by the system. */
  54. struct cgroup_subsys_state {
  55. /*
  56. * The cgroup that this subsystem is attached to. Useful
  57. * for subsystems that want to know about the cgroup
  58. * hierarchy structure
  59. */
  60. struct cgroup *cgroup;
  61. /*
  62. * State maintained by the cgroup system to allow subsystems
  63. * to be "busy". Should be accessed via css_get(),
  64. * css_tryget() and and css_put().
  65. */
  66. atomic_t refcnt;
  67. unsigned long flags;
  68. /* ID for this css, if possible */
  69. struct css_id __rcu *id;
  70. /* Used to put @cgroup->dentry on the last css_put() */
  71. struct work_struct dput_work;
  72. };
  73. /* bits in struct cgroup_subsys_state flags field */
  74. enum {
  75. CSS_ROOT, /* This CSS is the root of the subsystem */
  76. CSS_REMOVED, /* This CSS is dead */
  77. CSS_CLEAR_CSS_REFS, /* @ss->__DEPRECATED_clear_css_refs */
  78. };
  79. /* Caller must verify that the css is not for root cgroup */
  80. static inline void __css_get(struct cgroup_subsys_state *css, int count)
  81. {
  82. atomic_add(count, &css->refcnt);
  83. }
  84. /*
  85. * Call css_get() to hold a reference on the css; it can be used
  86. * for a reference obtained via:
  87. * - an existing ref-counted reference to the css
  88. * - task->cgroups for a locked task
  89. */
  90. static inline void css_get(struct cgroup_subsys_state *css)
  91. {
  92. /* We don't need to reference count the root state */
  93. if (!test_bit(CSS_ROOT, &css->flags))
  94. __css_get(css, 1);
  95. }
  96. static inline bool css_is_removed(struct cgroup_subsys_state *css)
  97. {
  98. return test_bit(CSS_REMOVED, &css->flags);
  99. }
  100. /*
  101. * Call css_tryget() to take a reference on a css if your existing
  102. * (known-valid) reference isn't already ref-counted. Returns false if
  103. * the css has been destroyed.
  104. */
  105. extern bool __css_tryget(struct cgroup_subsys_state *css);
  106. static inline bool css_tryget(struct cgroup_subsys_state *css)
  107. {
  108. if (test_bit(CSS_ROOT, &css->flags))
  109. return true;
  110. return __css_tryget(css);
  111. }
  112. /*
  113. * css_put() should be called to release a reference taken by
  114. * css_get() or css_tryget()
  115. */
  116. extern void __css_put(struct cgroup_subsys_state *css);
  117. static inline void css_put(struct cgroup_subsys_state *css)
  118. {
  119. if (!test_bit(CSS_ROOT, &css->flags))
  120. __css_put(css);
  121. }
  122. /* bits in struct cgroup flags field */
  123. enum {
  124. /* Control Group is dead */
  125. CGRP_REMOVED,
  126. /*
  127. * Control Group has previously had a child cgroup or a task,
  128. * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set)
  129. */
  130. CGRP_RELEASABLE,
  131. /* Control Group requires release notifications to userspace */
  132. CGRP_NOTIFY_ON_RELEASE,
  133. /*
  134. * A thread in rmdir() is wating for this cgroup.
  135. */
  136. CGRP_WAIT_ON_RMDIR,
  137. /*
  138. * Clone cgroup values when creating a new child cgroup
  139. */
  140. CGRP_CLONE_CHILDREN,
  141. };
  142. struct cgroup {
  143. unsigned long flags; /* "unsigned long" so bitops work */
  144. /*
  145. * count users of this cgroup. >0 means busy, but doesn't
  146. * necessarily indicate the number of tasks in the cgroup
  147. */
  148. atomic_t count;
  149. /*
  150. * We link our 'sibling' struct into our parent's 'children'.
  151. * Our children link their 'sibling' into our 'children'.
  152. */
  153. struct list_head sibling; /* my parent's children */
  154. struct list_head children; /* my children */
  155. struct list_head files; /* my files */
  156. struct cgroup *parent; /* my parent */
  157. struct dentry __rcu *dentry; /* cgroup fs entry, RCU protected */
  158. /* Private pointers for each registered subsystem */
  159. struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
  160. struct cgroupfs_root *root;
  161. struct cgroup *top_cgroup;
  162. /*
  163. * List of cg_cgroup_links pointing at css_sets with
  164. * tasks in this cgroup. Protected by css_set_lock
  165. */
  166. struct list_head css_sets;
  167. struct list_head allcg_node; /* cgroupfs_root->allcg_list */
  168. struct list_head cft_q_node; /* used during cftype add/rm */
  169. /*
  170. * Linked list running through all cgroups that can
  171. * potentially be reaped by the release agent. Protected by
  172. * release_list_lock
  173. */
  174. struct list_head release_list;
  175. /*
  176. * list of pidlists, up to two for each namespace (one for procs, one
  177. * for tasks); created on demand.
  178. */
  179. struct list_head pidlists;
  180. struct mutex pidlist_mutex;
  181. /* For RCU-protected deletion */
  182. struct rcu_head rcu_head;
  183. /* List of events which userspace want to receive */
  184. struct list_head event_list;
  185. spinlock_t event_list_lock;
  186. };
  187. /*
  188. * A css_set is a structure holding pointers to a set of
  189. * cgroup_subsys_state objects. This saves space in the task struct
  190. * object and speeds up fork()/exit(), since a single inc/dec and a
  191. * list_add()/del() can bump the reference count on the entire cgroup
  192. * set for a task.
  193. */
  194. struct css_set {
  195. /* Reference count */
  196. atomic_t refcount;
  197. /*
  198. * List running through all cgroup groups in the same hash
  199. * slot. Protected by css_set_lock
  200. */
  201. struct hlist_node hlist;
  202. /*
  203. * List running through all tasks using this cgroup
  204. * group. Protected by css_set_lock
  205. */
  206. struct list_head tasks;
  207. /*
  208. * List of cg_cgroup_link objects on link chains from
  209. * cgroups referenced from this css_set. Protected by
  210. * css_set_lock
  211. */
  212. struct list_head cg_links;
  213. /*
  214. * Set of subsystem states, one for each subsystem. This array
  215. * is immutable after creation apart from the init_css_set
  216. * during subsystem registration (at boot time) and modular subsystem
  217. * loading/unloading.
  218. */
  219. struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
  220. /* For RCU-protected deletion */
  221. struct rcu_head rcu_head;
  222. };
  223. /*
  224. * cgroup_map_cb is an abstract callback API for reporting map-valued
  225. * control files
  226. */
  227. struct cgroup_map_cb {
  228. int (*fill)(struct cgroup_map_cb *cb, const char *key, u64 value);
  229. void *state;
  230. };
  231. /*
  232. * struct cftype: handler definitions for cgroup control files
  233. *
  234. * When reading/writing to a file:
  235. * - the cgroup to use is file->f_dentry->d_parent->d_fsdata
  236. * - the 'cftype' of the file is file->f_dentry->d_fsdata
  237. */
  238. /* cftype->flags */
  239. #define CFTYPE_ONLY_ON_ROOT (1U << 0) /* only create on root cg */
  240. #define CFTYPE_NOT_ON_ROOT (1U << 1) /* don't create onp root cg */
  241. #define MAX_CFTYPE_NAME 64
  242. struct cftype {
  243. /*
  244. * By convention, the name should begin with the name of the
  245. * subsystem, followed by a period. Zero length string indicates
  246. * end of cftype array.
  247. */
  248. char name[MAX_CFTYPE_NAME];
  249. int private;
  250. /*
  251. * If not 0, file mode is set to this value, otherwise it will
  252. * be figured out automatically
  253. */
  254. umode_t mode;
  255. /*
  256. * If non-zero, defines the maximum length of string that can
  257. * be passed to write_string; defaults to 64
  258. */
  259. size_t max_write_len;
  260. /* CFTYPE_* flags */
  261. unsigned int flags;
  262. int (*open)(struct inode *inode, struct file *file);
  263. ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft,
  264. struct file *file,
  265. char __user *buf, size_t nbytes, loff_t *ppos);
  266. /*
  267. * read_u64() is a shortcut for the common case of returning a
  268. * single integer. Use it in place of read()
  269. */
  270. u64 (*read_u64)(struct cgroup *cgrp, struct cftype *cft);
  271. /*
  272. * read_s64() is a signed version of read_u64()
  273. */
  274. s64 (*read_s64)(struct cgroup *cgrp, struct cftype *cft);
  275. /*
  276. * read_map() is used for defining a map of key/value
  277. * pairs. It should call cb->fill(cb, key, value) for each
  278. * entry. The key/value pairs (and their ordering) should not
  279. * change between reboots.
  280. */
  281. int (*read_map)(struct cgroup *cont, struct cftype *cft,
  282. struct cgroup_map_cb *cb);
  283. /*
  284. * read_seq_string() is used for outputting a simple sequence
  285. * using seqfile.
  286. */
  287. int (*read_seq_string)(struct cgroup *cont, struct cftype *cft,
  288. struct seq_file *m);
  289. ssize_t (*write)(struct cgroup *cgrp, struct cftype *cft,
  290. struct file *file,
  291. const char __user *buf, size_t nbytes, loff_t *ppos);
  292. /*
  293. * write_u64() is a shortcut for the common case of accepting
  294. * a single integer (as parsed by simple_strtoull) from
  295. * userspace. Use in place of write(); return 0 or error.
  296. */
  297. int (*write_u64)(struct cgroup *cgrp, struct cftype *cft, u64 val);
  298. /*
  299. * write_s64() is a signed version of write_u64()
  300. */
  301. int (*write_s64)(struct cgroup *cgrp, struct cftype *cft, s64 val);
  302. /*
  303. * write_string() is passed a nul-terminated kernelspace
  304. * buffer of maximum length determined by max_write_len.
  305. * Returns 0 or -ve error code.
  306. */
  307. int (*write_string)(struct cgroup *cgrp, struct cftype *cft,
  308. const char *buffer);
  309. /*
  310. * trigger() callback can be used to get some kick from the
  311. * userspace, when the actual string written is not important
  312. * at all. The private field can be used to determine the
  313. * kick type for multiplexing.
  314. */
  315. int (*trigger)(struct cgroup *cgrp, unsigned int event);
  316. int (*release)(struct inode *inode, struct file *file);
  317. /*
  318. * register_event() callback will be used to add new userspace
  319. * waiter for changes related to the cftype. Implement it if
  320. * you want to provide this functionality. Use eventfd_signal()
  321. * on eventfd to send notification to userspace.
  322. */
  323. int (*register_event)(struct cgroup *cgrp, struct cftype *cft,
  324. struct eventfd_ctx *eventfd, const char *args);
  325. /*
  326. * unregister_event() callback will be called when userspace
  327. * closes the eventfd or on cgroup removing.
  328. * This callback must be implemented, if you want provide
  329. * notification functionality.
  330. */
  331. void (*unregister_event)(struct cgroup *cgrp, struct cftype *cft,
  332. struct eventfd_ctx *eventfd);
  333. };
  334. /*
  335. * cftype_sets describe cftypes belonging to a subsystem and are chained at
  336. * cgroup_subsys->cftsets. Each cftset points to an array of cftypes
  337. * terminated by zero length name.
  338. */
  339. struct cftype_set {
  340. struct list_head node; /* chained at subsys->cftsets */
  341. const struct cftype *cfts;
  342. };
  343. struct cgroup_scanner {
  344. struct cgroup *cg;
  345. int (*test_task)(struct task_struct *p, struct cgroup_scanner *scan);
  346. void (*process_task)(struct task_struct *p,
  347. struct cgroup_scanner *scan);
  348. struct ptr_heap *heap;
  349. void *data;
  350. };
  351. int cgroup_add_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts);
  352. int cgroup_rm_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts);
  353. int cgroup_is_removed(const struct cgroup *cgrp);
  354. int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
  355. int cgroup_task_count(const struct cgroup *cgrp);
  356. /* Return true if cgrp is a descendant of the task's cgroup */
  357. int cgroup_is_descendant(const struct cgroup *cgrp, struct task_struct *task);
  358. /*
  359. * When the subsys has to access css and may add permanent refcnt to css,
  360. * it should take care of racy conditions with rmdir(). Following set of
  361. * functions, is for stop/restart rmdir if necessary.
  362. * Because these will call css_get/put, "css" should be alive css.
  363. *
  364. * cgroup_exclude_rmdir();
  365. * ...do some jobs which may access arbitrary empty cgroup
  366. * cgroup_release_and_wakeup_rmdir();
  367. *
  368. * When someone removes a cgroup while cgroup_exclude_rmdir() holds it,
  369. * it sleeps and cgroup_release_and_wakeup_rmdir() will wake him up.
  370. */
  371. void cgroup_exclude_rmdir(struct cgroup_subsys_state *css);
  372. void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css);
  373. /*
  374. * Control Group taskset, used to pass around set of tasks to cgroup_subsys
  375. * methods.
  376. */
  377. struct cgroup_taskset;
  378. struct task_struct *cgroup_taskset_first(struct cgroup_taskset *tset);
  379. struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset);
  380. struct cgroup *cgroup_taskset_cur_cgroup(struct cgroup_taskset *tset);
  381. int cgroup_taskset_size(struct cgroup_taskset *tset);
  382. /**
  383. * cgroup_taskset_for_each - iterate cgroup_taskset
  384. * @task: the loop cursor
  385. * @skip_cgrp: skip if task's cgroup matches this, %NULL to iterate through all
  386. * @tset: taskset to iterate
  387. */
  388. #define cgroup_taskset_for_each(task, skip_cgrp, tset) \
  389. for ((task) = cgroup_taskset_first((tset)); (task); \
  390. (task) = cgroup_taskset_next((tset))) \
  391. if (!(skip_cgrp) || \
  392. cgroup_taskset_cur_cgroup((tset)) != (skip_cgrp))
  393. /*
  394. * Control Group subsystem type.
  395. * See Documentation/cgroups/cgroups.txt for details
  396. */
  397. struct cgroup_subsys {
  398. struct cgroup_subsys_state *(*create)(struct cgroup *cgrp);
  399. int (*pre_destroy)(struct cgroup *cgrp);
  400. void (*destroy)(struct cgroup *cgrp);
  401. int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
  402. void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
  403. void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
  404. void (*fork)(struct task_struct *task);
  405. void (*exit)(struct cgroup *cgrp, struct cgroup *old_cgrp,
  406. struct task_struct *task);
  407. void (*post_clone)(struct cgroup *cgrp);
  408. void (*bind)(struct cgroup *root);
  409. int subsys_id;
  410. int active;
  411. int disabled;
  412. int early_init;
  413. /*
  414. * True if this subsys uses ID. ID is not available before cgroup_init()
  415. * (not available in early_init time.)
  416. */
  417. bool use_id;
  418. /*
  419. * If %true, cgroup removal will try to clear css refs by retrying
  420. * ss->pre_destroy() until there's no css ref left. This behavior
  421. * is strictly for backward compatibility and will be removed as
  422. * soon as the current user (memcg) is updated.
  423. *
  424. * If %false, ss->pre_destroy() can't fail and cgroup removal won't
  425. * wait for css refs to drop to zero before proceeding.
  426. */
  427. bool __DEPRECATED_clear_css_refs;
  428. #define MAX_CGROUP_TYPE_NAMELEN 32
  429. const char *name;
  430. /*
  431. * Link to parent, and list entry in parent's children.
  432. * Protected by cgroup_lock()
  433. */
  434. struct cgroupfs_root *root;
  435. struct list_head sibling;
  436. /* used when use_id == true */
  437. struct idr idr;
  438. spinlock_t id_lock;
  439. /* list of cftype_sets */
  440. struct list_head cftsets;
  441. /* base cftypes, automatically [de]registered with subsys itself */
  442. struct cftype *base_cftypes;
  443. struct cftype_set base_cftset;
  444. /* should be defined only by modular subsystems */
  445. struct module *module;
  446. };
  447. #define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
  448. #include <linux/cgroup_subsys.h>
  449. #undef SUBSYS
  450. static inline struct cgroup_subsys_state *cgroup_subsys_state(
  451. struct cgroup *cgrp, int subsys_id)
  452. {
  453. return cgrp->subsys[subsys_id];
  454. }
  455. /*
  456. * function to get the cgroup_subsys_state which allows for extra
  457. * rcu_dereference_check() conditions, such as locks used during the
  458. * cgroup_subsys::attach() methods.
  459. */
  460. #define task_subsys_state_check(task, subsys_id, __c) \
  461. rcu_dereference_check(task->cgroups->subsys[subsys_id], \
  462. lockdep_is_held(&task->alloc_lock) || \
  463. cgroup_lock_is_held() || (__c))
  464. static inline struct cgroup_subsys_state *
  465. task_subsys_state(struct task_struct *task, int subsys_id)
  466. {
  467. return task_subsys_state_check(task, subsys_id, false);
  468. }
  469. static inline struct cgroup* task_cgroup(struct task_struct *task,
  470. int subsys_id)
  471. {
  472. return task_subsys_state(task, subsys_id)->cgroup;
  473. }
  474. /* A cgroup_iter should be treated as an opaque object */
  475. struct cgroup_iter {
  476. struct list_head *cg_link;
  477. struct list_head *task;
  478. };
  479. /*
  480. * To iterate across the tasks in a cgroup:
  481. *
  482. * 1) call cgroup_iter_start to initialize an iterator
  483. *
  484. * 2) call cgroup_iter_next() to retrieve member tasks until it
  485. * returns NULL or until you want to end the iteration
  486. *
  487. * 3) call cgroup_iter_end() to destroy the iterator.
  488. *
  489. * Or, call cgroup_scan_tasks() to iterate through every task in a
  490. * cgroup - cgroup_scan_tasks() holds the css_set_lock when calling
  491. * the test_task() callback, but not while calling the process_task()
  492. * callback.
  493. */
  494. void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it);
  495. struct task_struct *cgroup_iter_next(struct cgroup *cgrp,
  496. struct cgroup_iter *it);
  497. void cgroup_iter_end(struct cgroup *cgrp, struct cgroup_iter *it);
  498. int cgroup_scan_tasks(struct cgroup_scanner *scan);
  499. int cgroup_attach_task(struct cgroup *, struct task_struct *);
  500. int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
  501. /*
  502. * CSS ID is ID for cgroup_subsys_state structs under subsys. This only works
  503. * if cgroup_subsys.use_id == true. It can be used for looking up and scanning.
  504. * CSS ID is assigned at cgroup allocation (create) automatically
  505. * and removed when subsys calls free_css_id() function. This is because
  506. * the lifetime of cgroup_subsys_state is subsys's matter.
  507. *
  508. * Looking up and scanning function should be called under rcu_read_lock().
  509. * Taking cgroup_mutex is not necessary for following calls.
  510. * But the css returned by this routine can be "not populated yet" or "being
  511. * destroyed". The caller should check css and cgroup's status.
  512. */
  513. /*
  514. * Typically Called at ->destroy(), or somewhere the subsys frees
  515. * cgroup_subsys_state.
  516. */
  517. void free_css_id(struct cgroup_subsys *ss, struct cgroup_subsys_state *css);
  518. /* Find a cgroup_subsys_state which has given ID */
  519. struct cgroup_subsys_state *css_lookup(struct cgroup_subsys *ss, int id);
  520. /*
  521. * Get a cgroup whose id is greater than or equal to id under tree of root.
  522. * Returning a cgroup_subsys_state or NULL.
  523. */
  524. struct cgroup_subsys_state *css_get_next(struct cgroup_subsys *ss, int id,
  525. struct cgroup_subsys_state *root, int *foundid);
  526. /* Returns true if root is ancestor of cg */
  527. bool css_is_ancestor(struct cgroup_subsys_state *cg,
  528. const struct cgroup_subsys_state *root);
  529. /* Get id and depth of css */
  530. unsigned short css_id(struct cgroup_subsys_state *css);
  531. unsigned short css_depth(struct cgroup_subsys_state *css);
  532. struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id);
  533. #else /* !CONFIG_CGROUPS */
  534. static inline int cgroup_init_early(void) { return 0; }
  535. static inline int cgroup_init(void) { return 0; }
  536. static inline void cgroup_fork(struct task_struct *p) {}
  537. static inline void cgroup_fork_callbacks(struct task_struct *p) {}
  538. static inline void cgroup_post_fork(struct task_struct *p) {}
  539. static inline void cgroup_exit(struct task_struct *p, int callbacks) {}
  540. static inline void cgroup_lock(void) {}
  541. static inline void cgroup_unlock(void) {}
  542. static inline int cgroupstats_build(struct cgroupstats *stats,
  543. struct dentry *dentry)
  544. {
  545. return -EINVAL;
  546. }
  547. /* No cgroups - nothing to do */
  548. static inline int cgroup_attach_task_all(struct task_struct *from,
  549. struct task_struct *t)
  550. {
  551. return 0;
  552. }
  553. #endif /* !CONFIG_CGROUPS */
  554. #endif /* _LINUX_CGROUP_H */