blob: bb8feb9feccdedaa3793b98df7d6eefb98eefc14 [file] [log] [blame]
Paul Menageddbcc7e2007-10-18 23:39:30 -07001#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>
Paul Menageddbcc7e2007-10-18 23:39:30 -070012#include <linux/cpumask.h>
13#include <linux/nodemask.h>
14#include <linux/rcupdate.h>
Balbir Singh846c7bb2007-10-18 23:39:44 -070015#include <linux/cgroupstats.h>
Cliff Wickman31a7df02008-02-07 00:14:42 -080016#include <linux/prio_heap.h>
Paul Menagecc31edc2008-10-18 20:28:04 -070017#include <linux/rwsem.h>
Paul Menageddbcc7e2007-10-18 23:39:30 -070018
19#ifdef CONFIG_CGROUPS
20
21struct cgroupfs_root;
22struct cgroup_subsys;
23struct inode;
Paul Menage84eea842008-07-25 01:47:00 -070024struct cgroup;
Paul Menageddbcc7e2007-10-18 23:39:30 -070025
26extern int cgroup_init_early(void);
27extern int cgroup_init(void);
Paul Menageddbcc7e2007-10-18 23:39:30 -070028extern void cgroup_lock(void);
Paul Menage84eea842008-07-25 01:47:00 -070029extern bool cgroup_lock_live_group(struct cgroup *cgrp);
Paul Menageddbcc7e2007-10-18 23:39:30 -070030extern void cgroup_unlock(void);
Paul Menageb4f48b62007-10-18 23:39:33 -070031extern void cgroup_fork(struct task_struct *p);
32extern void cgroup_fork_callbacks(struct task_struct *p);
Paul Menage817929e2007-10-18 23:39:36 -070033extern void cgroup_post_fork(struct task_struct *p);
Paul Menageb4f48b62007-10-18 23:39:33 -070034extern void cgroup_exit(struct task_struct *p, int run_callbacks);
Balbir Singh846c7bb2007-10-18 23:39:44 -070035extern int cgroupstats_build(struct cgroupstats *stats,
36 struct dentry *dentry);
Paul Menageddbcc7e2007-10-18 23:39:30 -070037
Paul Menagea4243162007-10-18 23:39:35 -070038extern struct file_operations proc_cgroup_operations;
39
Paul Menage817929e2007-10-18 23:39:36 -070040/* Define the enumeration of all cgroup subsystems */
41#define SUBSYS(_x) _x ## _subsys_id,
42enum cgroup_subsys_id {
43#include <linux/cgroup_subsys.h>
44 CGROUP_SUBSYS_COUNT
45};
46#undef SUBSYS
47
Paul Menageddbcc7e2007-10-18 23:39:30 -070048/* Per-subsystem/per-cgroup state maintained by the system. */
49struct cgroup_subsys_state {
Paul Menaged20a3902009-04-02 16:57:22 -070050 /*
51 * The cgroup that this subsystem is attached to. Useful
Paul Menageddbcc7e2007-10-18 23:39:30 -070052 * for subsystems that want to know about the cgroup
Paul Menaged20a3902009-04-02 16:57:22 -070053 * hierarchy structure
54 */
Paul Menageddbcc7e2007-10-18 23:39:30 -070055 struct cgroup *cgroup;
56
Paul Menaged20a3902009-04-02 16:57:22 -070057 /*
58 * State maintained by the cgroup system to allow subsystems
Paul Menagee7c5ec92009-01-07 18:08:38 -080059 * to be "busy". Should be accessed via css_get(),
Paul Menaged20a3902009-04-02 16:57:22 -070060 * css_tryget() and and css_put().
61 */
Paul Menageddbcc7e2007-10-18 23:39:30 -070062
63 atomic_t refcnt;
64
65 unsigned long flags;
66};
67
68/* bits in struct cgroup_subsys_state flags field */
69enum {
70 CSS_ROOT, /* This CSS is the root of the subsystem */
Paul Menagee7c5ec92009-01-07 18:08:38 -080071 CSS_REMOVED, /* This CSS is dead */
Paul Menageddbcc7e2007-10-18 23:39:30 -070072};
73
74/*
Paul Menagee7c5ec92009-01-07 18:08:38 -080075 * Call css_get() to hold a reference on the css; it can be used
76 * for a reference obtained via:
77 * - an existing ref-counted reference to the css
78 * - task->cgroups for a locked task
Paul Menageddbcc7e2007-10-18 23:39:30 -070079 */
80
81static inline void css_get(struct cgroup_subsys_state *css)
82{
83 /* We don't need to reference count the root state */
84 if (!test_bit(CSS_ROOT, &css->flags))
85 atomic_inc(&css->refcnt);
86}
Paul Menagee7c5ec92009-01-07 18:08:38 -080087
88static inline bool css_is_removed(struct cgroup_subsys_state *css)
89{
90 return test_bit(CSS_REMOVED, &css->flags);
91}
92
93/*
94 * Call css_tryget() to take a reference on a css if your existing
95 * (known-valid) reference isn't already ref-counted. Returns false if
96 * the css has been destroyed.
97 */
98
99static inline bool css_tryget(struct cgroup_subsys_state *css)
100{
101 if (test_bit(CSS_ROOT, &css->flags))
102 return true;
103 while (!atomic_inc_not_zero(&css->refcnt)) {
104 if (test_bit(CSS_REMOVED, &css->flags))
105 return false;
Paul Menage804b3c22009-01-29 14:25:21 -0800106 cpu_relax();
Paul Menagee7c5ec92009-01-07 18:08:38 -0800107 }
108 return true;
109}
110
Paul Menageddbcc7e2007-10-18 23:39:30 -0700111/*
112 * css_put() should be called to release a reference taken by
Paul Menagee7c5ec92009-01-07 18:08:38 -0800113 * css_get() or css_tryget()
Paul Menageddbcc7e2007-10-18 23:39:30 -0700114 */
115
Paul Menage81a6a5c2007-10-18 23:39:38 -0700116extern void __css_put(struct cgroup_subsys_state *css);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700117static inline void css_put(struct cgroup_subsys_state *css)
118{
119 if (!test_bit(CSS_ROOT, &css->flags))
Paul Menage81a6a5c2007-10-18 23:39:38 -0700120 __css_put(css);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700121}
122
Paul Menage3116f0e2008-04-29 01:00:04 -0700123/* bits in struct cgroup flags field */
124enum {
125 /* Control Group is dead */
126 CGRP_REMOVED,
Paul Menaged20a3902009-04-02 16:57:22 -0700127 /*
128 * Control Group has previously had a child cgroup or a task,
129 * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set)
130 */
Paul Menage3116f0e2008-04-29 01:00:04 -0700131 CGRP_RELEASABLE,
132 /* Control Group requires release notifications to userspace */
133 CGRP_NOTIFY_ON_RELEASE,
134};
135
Paul Menageddbcc7e2007-10-18 23:39:30 -0700136struct cgroup {
137 unsigned long flags; /* "unsigned long" so bitops work */
138
Paul Menaged20a3902009-04-02 16:57:22 -0700139 /*
140 * count users of this cgroup. >0 means busy, but doesn't
141 * necessarily indicate the number of tasks in the cgroup
142 */
Paul Menageddbcc7e2007-10-18 23:39:30 -0700143 atomic_t count;
144
145 /*
146 * We link our 'sibling' struct into our parent's 'children'.
147 * Our children link their 'sibling' into our 'children'.
148 */
149 struct list_head sibling; /* my parent's children */
150 struct list_head children; /* my children */
151
Paul Menaged20a3902009-04-02 16:57:22 -0700152 struct cgroup *parent; /* my parent */
Paul Menagea47295e2009-01-07 18:07:44 -0800153 struct dentry *dentry; /* cgroup fs entry, RCU protected */
Paul Menageddbcc7e2007-10-18 23:39:30 -0700154
155 /* Private pointers for each registered subsystem */
156 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
157
158 struct cgroupfs_root *root;
159 struct cgroup *top_cgroup;
Paul Menage817929e2007-10-18 23:39:36 -0700160
161 /*
162 * List of cg_cgroup_links pointing at css_sets with
163 * tasks in this cgroup. Protected by css_set_lock
164 */
165 struct list_head css_sets;
Paul Menage81a6a5c2007-10-18 23:39:38 -0700166
167 /*
168 * Linked list running through all cgroups that can
169 * potentially be reaped by the release agent. Protected by
170 * release_list_lock
171 */
172 struct list_head release_list;
Paul Menagecc31edc2008-10-18 20:28:04 -0700173
174 /* pids_mutex protects the fields below */
175 struct rw_semaphore pids_mutex;
176 /* Array of process ids in the cgroup */
177 pid_t *tasks_pids;
178 /* How many files are using the current tasks_pids array */
179 int pids_use_count;
180 /* Length of the current tasks_pids array */
181 int pids_length;
Paul Menagea47295e2009-01-07 18:07:44 -0800182
183 /* For RCU-protected deletion */
184 struct rcu_head rcu_head;
Paul Menage817929e2007-10-18 23:39:36 -0700185};
186
Paul Menaged20a3902009-04-02 16:57:22 -0700187/*
188 * A css_set is a structure holding pointers to a set of
Paul Menage817929e2007-10-18 23:39:36 -0700189 * 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
Paul Menaged20a3902009-04-02 16:57:22 -0700191 * list_add()/del() can bump the reference count on the entire cgroup
192 * set for a task.
Paul Menage817929e2007-10-18 23:39:36 -0700193 */
194
195struct css_set {
196
197 /* Reference count */
Lai Jiangshan146aa1b2008-10-18 20:28:03 -0700198 atomic_t refcount;
Paul Menage817929e2007-10-18 23:39:36 -0700199
200 /*
Li Zefan472b1052008-04-29 01:00:11 -0700201 * List running through all cgroup groups in the same hash
202 * slot. Protected by css_set_lock
203 */
204 struct hlist_node hlist;
205
206 /*
Paul Menage817929e2007-10-18 23:39:36 -0700207 * List running through all tasks using this cgroup
208 * group. Protected by css_set_lock
209 */
210 struct list_head tasks;
211
212 /*
213 * List of cg_cgroup_link objects on link chains from
214 * cgroups referenced from this css_set. Protected by
215 * css_set_lock
216 */
217 struct list_head cg_links;
218
219 /*
220 * Set of subsystem states, one for each subsystem. This array
221 * is immutable after creation apart from the init_css_set
222 * during subsystem registration (at boot time).
223 */
224 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
Paul Menageddbcc7e2007-10-18 23:39:30 -0700225};
226
Paul Menage91796562008-04-29 01:00:01 -0700227/*
228 * cgroup_map_cb is an abstract callback API for reporting map-valued
229 * control files
230 */
231
232struct cgroup_map_cb {
233 int (*fill)(struct cgroup_map_cb *cb, const char *key, u64 value);
234 void *state;
235};
236
Paul Menaged20a3902009-04-02 16:57:22 -0700237/*
238 * struct cftype: handler definitions for cgroup control files
Paul Menageddbcc7e2007-10-18 23:39:30 -0700239 *
240 * When reading/writing to a file:
Li Zefana043e3b2008-02-23 15:24:09 -0800241 * - the cgroup to use is file->f_dentry->d_parent->d_fsdata
Paul Menageddbcc7e2007-10-18 23:39:30 -0700242 * - the 'cftype' of the file is file->f_dentry->d_fsdata
243 */
244
245#define MAX_CFTYPE_NAME 64
246struct cftype {
Paul Menaged20a3902009-04-02 16:57:22 -0700247 /*
248 * By convention, the name should begin with the name of the
249 * subsystem, followed by a period
250 */
Paul Menageddbcc7e2007-10-18 23:39:30 -0700251 char name[MAX_CFTYPE_NAME];
252 int private;
Paul Menagedb3b1492008-07-25 01:46:58 -0700253
254 /*
255 * If non-zero, defines the maximum length of string that can
256 * be passed to write_string; defaults to 64
257 */
258 size_t max_write_len;
259
Paul Menagece16b492008-07-25 01:46:57 -0700260 int (*open)(struct inode *inode, struct file *file);
261 ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft,
262 struct file *file,
263 char __user *buf, size_t nbytes, loff_t *ppos);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700264 /*
Paul Menagef4c753b2008-04-29 00:59:56 -0700265 * read_u64() is a shortcut for the common case of returning a
Paul Menageddbcc7e2007-10-18 23:39:30 -0700266 * single integer. Use it in place of read()
267 */
Paul Menagece16b492008-07-25 01:46:57 -0700268 u64 (*read_u64)(struct cgroup *cgrp, struct cftype *cft);
Paul Menage91796562008-04-29 01:00:01 -0700269 /*
Paul Menagee73d2c62008-04-29 01:00:06 -0700270 * read_s64() is a signed version of read_u64()
271 */
Paul Menagece16b492008-07-25 01:46:57 -0700272 s64 (*read_s64)(struct cgroup *cgrp, struct cftype *cft);
Paul Menagee73d2c62008-04-29 01:00:06 -0700273 /*
Paul Menage91796562008-04-29 01:00:01 -0700274 * read_map() is used for defining a map of key/value
275 * pairs. It should call cb->fill(cb, key, value) for each
276 * entry. The key/value pairs (and their ordering) should not
277 * change between reboots.
278 */
Paul Menagece16b492008-07-25 01:46:57 -0700279 int (*read_map)(struct cgroup *cont, struct cftype *cft,
280 struct cgroup_map_cb *cb);
Serge E. Hallyn29486df2008-04-29 01:00:14 -0700281 /*
282 * read_seq_string() is used for outputting a simple sequence
283 * using seqfile.
284 */
Paul Menagece16b492008-07-25 01:46:57 -0700285 int (*read_seq_string)(struct cgroup *cont, struct cftype *cft,
286 struct seq_file *m);
Paul Menage91796562008-04-29 01:00:01 -0700287
Paul Menagece16b492008-07-25 01:46:57 -0700288 ssize_t (*write)(struct cgroup *cgrp, struct cftype *cft,
289 struct file *file,
290 const char __user *buf, size_t nbytes, loff_t *ppos);
Paul Menage355e0c42007-10-18 23:39:33 -0700291
292 /*
Paul Menagef4c753b2008-04-29 00:59:56 -0700293 * write_u64() is a shortcut for the common case of accepting
Paul Menage355e0c42007-10-18 23:39:33 -0700294 * a single integer (as parsed by simple_strtoull) from
295 * userspace. Use in place of write(); return 0 or error.
296 */
Paul Menagece16b492008-07-25 01:46:57 -0700297 int (*write_u64)(struct cgroup *cgrp, struct cftype *cft, u64 val);
Paul Menagee73d2c62008-04-29 01:00:06 -0700298 /*
299 * write_s64() is a signed version of write_u64()
300 */
Paul Menagece16b492008-07-25 01:46:57 -0700301 int (*write_s64)(struct cgroup *cgrp, struct cftype *cft, s64 val);
Paul Menage355e0c42007-10-18 23:39:33 -0700302
Pavel Emelyanovd447ea22008-04-29 01:00:08 -0700303 /*
Paul Menagedb3b1492008-07-25 01:46:58 -0700304 * write_string() is passed a nul-terminated kernelspace
305 * buffer of maximum length determined by max_write_len.
306 * Returns 0 or -ve error code.
307 */
308 int (*write_string)(struct cgroup *cgrp, struct cftype *cft,
309 const char *buffer);
310 /*
Pavel Emelyanovd447ea22008-04-29 01:00:08 -0700311 * trigger() callback can be used to get some kick from the
312 * userspace, when the actual string written is not important
313 * at all. The private field can be used to determine the
314 * kick type for multiplexing.
315 */
316 int (*trigger)(struct cgroup *cgrp, unsigned int event);
317
Paul Menagece16b492008-07-25 01:46:57 -0700318 int (*release)(struct inode *inode, struct file *file);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700319};
320
Cliff Wickman31a7df02008-02-07 00:14:42 -0800321struct cgroup_scanner {
322 struct cgroup *cg;
323 int (*test_task)(struct task_struct *p, struct cgroup_scanner *scan);
324 void (*process_task)(struct task_struct *p,
325 struct cgroup_scanner *scan);
326 struct ptr_heap *heap;
327};
328
Paul Menaged20a3902009-04-02 16:57:22 -0700329/*
330 * Add a new file to the given cgroup directory. Should only be
331 * called by subsystems from within a populate() method
332 */
Li Zefanffd2d882008-02-23 15:24:09 -0800333int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
Paul Menageddbcc7e2007-10-18 23:39:30 -0700334 const struct cftype *cft);
335
Paul Menaged20a3902009-04-02 16:57:22 -0700336/*
337 * Add a set of new files to the given cgroup directory. Should
338 * only be called by subsystems from within a populate() method
339 */
Li Zefanffd2d882008-02-23 15:24:09 -0800340int cgroup_add_files(struct cgroup *cgrp,
Paul Menageddbcc7e2007-10-18 23:39:30 -0700341 struct cgroup_subsys *subsys,
342 const struct cftype cft[],
343 int count);
344
Li Zefanffd2d882008-02-23 15:24:09 -0800345int cgroup_is_removed(const struct cgroup *cgrp);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700346
Li Zefanffd2d882008-02-23 15:24:09 -0800347int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700348
Li Zefanffd2d882008-02-23 15:24:09 -0800349int cgroup_task_count(const struct cgroup *cgrp);
Paul Menagebbcb81d2007-10-18 23:39:32 -0700350
Paul Menageddbcc7e2007-10-18 23:39:30 -0700351/* Return true if the cgroup is a descendant of the current cgroup */
Li Zefanffd2d882008-02-23 15:24:09 -0800352int cgroup_is_descendant(const struct cgroup *cgrp);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700353
354/* Control Group subsystem type. See Documentation/cgroups.txt for details */
355
356struct cgroup_subsys {
357 struct cgroup_subsys_state *(*create)(struct cgroup_subsys *ss,
Li Zefanffd2d882008-02-23 15:24:09 -0800358 struct cgroup *cgrp);
359 void (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp);
360 void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700361 int (*can_attach)(struct cgroup_subsys *ss,
Li Zefanffd2d882008-02-23 15:24:09 -0800362 struct cgroup *cgrp, struct task_struct *tsk);
363 void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
364 struct cgroup *old_cgrp, struct task_struct *tsk);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700365 void (*fork)(struct cgroup_subsys *ss, struct task_struct *task);
366 void (*exit)(struct cgroup_subsys *ss, struct task_struct *task);
367 int (*populate)(struct cgroup_subsys *ss,
Li Zefanffd2d882008-02-23 15:24:09 -0800368 struct cgroup *cgrp);
369 void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700370 void (*bind)(struct cgroup_subsys *ss, struct cgroup *root);
Hugh Dickinse5991372009-01-06 14:39:22 -0800371
Paul Menageddbcc7e2007-10-18 23:39:30 -0700372 int subsys_id;
373 int active;
Paul Menage8bab8dd2008-04-04 14:29:57 -0700374 int disabled;
Paul Menageddbcc7e2007-10-18 23:39:30 -0700375 int early_init;
376#define MAX_CGROUP_TYPE_NAMELEN 32
377 const char *name;
378
Paul Menage999cd8a2009-01-07 18:08:36 -0800379 /*
380 * Protects sibling/children links of cgroups in this
381 * hierarchy, plus protects which hierarchy (or none) the
382 * subsystem is a part of (i.e. root/sibling). To avoid
383 * potential deadlocks, the following operations should not be
384 * undertaken while holding any hierarchy_mutex:
385 *
386 * - allocating memory
387 * - initiating hotplug events
388 */
389 struct mutex hierarchy_mutex;
Li Zefancfebe562009-02-11 13:04:36 -0800390 struct lock_class_key subsys_key;
Paul Menageddbcc7e2007-10-18 23:39:30 -0700391
Paul Menage999cd8a2009-01-07 18:08:36 -0800392 /*
393 * Link to parent, and list entry in parent's children.
394 * Protected by this->hierarchy_mutex and cgroup_lock()
395 */
396 struct cgroupfs_root *root;
Paul Menageddbcc7e2007-10-18 23:39:30 -0700397 struct list_head sibling;
Paul Menageddbcc7e2007-10-18 23:39:30 -0700398};
399
400#define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
401#include <linux/cgroup_subsys.h>
402#undef SUBSYS
403
404static inline struct cgroup_subsys_state *cgroup_subsys_state(
Li Zefanffd2d882008-02-23 15:24:09 -0800405 struct cgroup *cgrp, int subsys_id)
Paul Menageddbcc7e2007-10-18 23:39:30 -0700406{
Li Zefanffd2d882008-02-23 15:24:09 -0800407 return cgrp->subsys[subsys_id];
Paul Menageddbcc7e2007-10-18 23:39:30 -0700408}
409
410static inline struct cgroup_subsys_state *task_subsys_state(
411 struct task_struct *task, int subsys_id)
412{
Paul Menage817929e2007-10-18 23:39:36 -0700413 return rcu_dereference(task->cgroups->subsys[subsys_id]);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700414}
415
416static inline struct cgroup* task_cgroup(struct task_struct *task,
417 int subsys_id)
418{
419 return task_subsys_state(task, subsys_id)->cgroup;
420}
421
Serge E. Hallyne885dcd2008-07-25 01:47:06 -0700422int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *ss,
423 char *nodename);
Paul Menage697f4162007-10-18 23:39:34 -0700424
Paul Menage817929e2007-10-18 23:39:36 -0700425/* A cgroup_iter should be treated as an opaque object */
426struct cgroup_iter {
427 struct list_head *cg_link;
428 struct list_head *task;
429};
430
Paul Menaged20a3902009-04-02 16:57:22 -0700431/*
432 * To iterate across the tasks in a cgroup:
Paul Menage817929e2007-10-18 23:39:36 -0700433 *
434 * 1) call cgroup_iter_start to intialize an iterator
435 *
436 * 2) call cgroup_iter_next() to retrieve member tasks until it
437 * returns NULL or until you want to end the iteration
438 *
439 * 3) call cgroup_iter_end() to destroy the iterator.
Cliff Wickman31a7df02008-02-07 00:14:42 -0800440 *
Paul Menaged20a3902009-04-02 16:57:22 -0700441 * Or, call cgroup_scan_tasks() to iterate through every task in a
442 * cgroup - cgroup_scan_tasks() holds the css_set_lock when calling
443 * the test_task() callback, but not while calling the process_task()
444 * callback.
Paul Menage817929e2007-10-18 23:39:36 -0700445 */
Li Zefanffd2d882008-02-23 15:24:09 -0800446void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it);
447struct task_struct *cgroup_iter_next(struct cgroup *cgrp,
Paul Menage817929e2007-10-18 23:39:36 -0700448 struct cgroup_iter *it);
Li Zefanffd2d882008-02-23 15:24:09 -0800449void cgroup_iter_end(struct cgroup *cgrp, struct cgroup_iter *it);
Cliff Wickman31a7df02008-02-07 00:14:42 -0800450int cgroup_scan_tasks(struct cgroup_scanner *scan);
Cliff Wickman956db3c2008-02-07 00:14:43 -0800451int cgroup_attach_task(struct cgroup *, struct task_struct *);
Paul Menage817929e2007-10-18 23:39:36 -0700452
Paul Menageddbcc7e2007-10-18 23:39:30 -0700453#else /* !CONFIG_CGROUPS */
454
455static inline int cgroup_init_early(void) { return 0; }
456static inline int cgroup_init(void) { return 0; }
Paul Menageb4f48b62007-10-18 23:39:33 -0700457static inline void cgroup_fork(struct task_struct *p) {}
458static inline void cgroup_fork_callbacks(struct task_struct *p) {}
Paul Menage817929e2007-10-18 23:39:36 -0700459static inline void cgroup_post_fork(struct task_struct *p) {}
Paul Menageb4f48b62007-10-18 23:39:33 -0700460static inline void cgroup_exit(struct task_struct *p, int callbacks) {}
Paul Menageddbcc7e2007-10-18 23:39:30 -0700461
462static inline void cgroup_lock(void) {}
463static inline void cgroup_unlock(void) {}
Balbir Singh846c7bb2007-10-18 23:39:44 -0700464static inline int cgroupstats_build(struct cgroupstats *stats,
465 struct dentry *dentry)
466{
467 return -EINVAL;
468}
Paul Menageddbcc7e2007-10-18 23:39:30 -0700469
470#endif /* !CONFIG_CGROUPS */
471
Paul Menageddbcc7e2007-10-18 23:39:30 -0700472#endif /* _LINUX_CGROUP_H */