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