blob: a593e299162eb0f318f1d9647adfc3c236599661 [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>
Tejun Heoeb6fd502012-11-09 09:12:29 -080014#include <linux/rculist.h>
Balbir Singh846c7bb2007-10-18 23:39:44 -070015#include <linux/cgroupstats.h>
Paul Menagecc31edc2008-10-18 20:28:04 -070016#include <linux/rwsem.h>
Tejun Heo25a7e682013-04-14 20:15:25 -070017#include <linux/fs.h>
Tejun Heo7da11272013-12-05 12:28:04 -050018#include <linux/seq_file.h>
Tejun Heo2bd59d42014-02-11 11:52:49 -050019#include <linux/kernfs.h>
Tejun Heob4a04ab2015-05-13 15:38:40 -040020
21#include <linux/cgroup-defs.h>
Paul Menageddbcc7e2007-10-18 23:39:30 -070022
23#ifdef CONFIG_CGROUPS
24
Tejun Heoc326aa22015-05-13 16:24:16 -040025/* a css_task_iter should be treated as an opaque object */
26struct css_task_iter {
27 struct cgroup_subsys *ss;
Paul Menageddbcc7e2007-10-18 23:39:30 -070028
Tejun Heoc326aa22015-05-13 16:24:16 -040029 struct list_head *cset_pos;
30 struct list_head *cset_head;
Paul Menageddbcc7e2007-10-18 23:39:30 -070031
Tejun Heoc326aa22015-05-13 16:24:16 -040032 struct list_head *task_pos;
33 struct list_head *tasks_head;
34 struct list_head *mg_tasks_head;
Paul Menage817929e2007-10-18 23:39:36 -070035};
Tejun Heoc326aa22015-05-13 16:24:16 -040036
37extern struct cgroup_root cgrp_dfl_root;
38extern struct css_set init_css_set;
39
40#define SUBSYS(_x) extern struct cgroup_subsys _x ## _cgrp_subsys;
41#include <linux/cgroup_subsys.h>
Paul Menage817929e2007-10-18 23:39:36 -070042#undef SUBSYS
43
Tejun Heoc326aa22015-05-13 16:24:16 -040044bool css_has_online_children(struct cgroup_subsys_state *css);
45struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
46struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup,
47 struct cgroup_subsys *ss);
48struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
49 struct cgroup_subsys *ss);
50
51bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
52int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
53int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
54
55int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
56int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
57int cgroup_rm_cftypes(struct cftype *cfts);
58
59char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
60int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
61int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
62 struct pid *pid, struct task_struct *tsk);
63
64void cgroup_fork(struct task_struct *p);
65void cgroup_post_fork(struct task_struct *p);
66void cgroup_exit(struct task_struct *p);
67
68int cgroup_init_early(void);
69int cgroup_init(void);
70
Tejun Heo5c9d5352014-05-16 13:22:48 -040071/*
Tejun Heoc326aa22015-05-13 16:24:16 -040072 * Iteration helpers and macros.
Tejun Heo5c9d5352014-05-16 13:22:48 -040073 */
Paul Menageddbcc7e2007-10-18 23:39:30 -070074
Tejun Heoc326aa22015-05-13 16:24:16 -040075struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos,
76 struct cgroup_subsys_state *parent);
77struct cgroup_subsys_state *css_next_descendant_pre(struct cgroup_subsys_state *pos,
78 struct cgroup_subsys_state *css);
79struct cgroup_subsys_state *css_rightmost_descendant(struct cgroup_subsys_state *pos);
80struct cgroup_subsys_state *css_next_descendant_post(struct cgroup_subsys_state *pos,
81 struct cgroup_subsys_state *css);
Tejun Heo72c97e52013-08-08 20:11:22 -040082
Tejun Heoc326aa22015-05-13 16:24:16 -040083struct task_struct *cgroup_taskset_first(struct cgroup_taskset *tset);
84struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset);
Paul Menageddbcc7e2007-10-18 23:39:30 -070085
Tejun Heoc326aa22015-05-13 16:24:16 -040086void css_task_iter_start(struct cgroup_subsys_state *css,
87 struct css_task_iter *it);
88struct task_struct *css_task_iter_next(struct css_task_iter *it);
89void css_task_iter_end(struct css_task_iter *it);
Tejun Heo0ae78e02013-08-13 11:01:54 -040090
Tejun Heoc326aa22015-05-13 16:24:16 -040091/**
92 * css_for_each_child - iterate through children of a css
93 * @pos: the css * to use as the loop cursor
94 * @parent: css whose children to walk
95 *
96 * Walk @parent's children. Must be called under rcu_read_lock().
97 *
98 * If a subsystem synchronizes ->css_online() and the start of iteration, a
99 * css which finished ->css_online() is guaranteed to be visible in the
100 * future iterations and will stay visible until the last reference is put.
101 * A css which hasn't finished ->css_online() or already finished
102 * ->css_offline() may show up during traversal. It's each subsystem's
103 * responsibility to synchronize against on/offlining.
104 *
105 * It is allowed to temporarily drop RCU read lock during iteration. The
106 * caller is responsible for ensuring that @pos remains accessible until
107 * the start of the next iteration by, for example, bumping the css refcnt.
108 */
109#define css_for_each_child(pos, parent) \
110 for ((pos) = css_next_child(NULL, (parent)); (pos); \
111 (pos) = css_next_child((pos), (parent)))
Tejun Heod5c419b2014-05-16 13:22:48 -0400112
Tejun Heoc326aa22015-05-13 16:24:16 -0400113/**
114 * css_for_each_descendant_pre - pre-order walk of a css's descendants
115 * @pos: the css * to use as the loop cursor
116 * @root: css whose descendants to walk
117 *
118 * Walk @root's descendants. @root is included in the iteration and the
119 * first node to be visited. Must be called under rcu_read_lock().
120 *
121 * If a subsystem synchronizes ->css_online() and the start of iteration, a
122 * css which finished ->css_online() is guaranteed to be visible in the
123 * future iterations and will stay visible until the last reference is put.
124 * A css which hasn't finished ->css_online() or already finished
125 * ->css_offline() may show up during traversal. It's each subsystem's
126 * responsibility to synchronize against on/offlining.
127 *
128 * For example, the following guarantees that a descendant can't escape
129 * state updates of its ancestors.
130 *
131 * my_online(@css)
132 * {
133 * Lock @css's parent and @css;
134 * Inherit state from the parent;
135 * Unlock both.
136 * }
137 *
138 * my_update_state(@css)
139 * {
140 * css_for_each_descendant_pre(@pos, @css) {
141 * Lock @pos;
142 * if (@pos == @css)
143 * Update @css's state;
144 * else
145 * Verify @pos is alive and inherit state from its parent;
146 * Unlock @pos;
147 * }
148 * }
149 *
150 * As long as the inheriting step, including checking the parent state, is
151 * enclosed inside @pos locking, double-locking the parent isn't necessary
152 * while inheriting. The state update to the parent is guaranteed to be
153 * visible by walking order and, as long as inheriting operations to the
154 * same @pos are atomic to each other, multiple updates racing each other
155 * still result in the correct state. It's guaranateed that at least one
156 * inheritance happens for any css after the latest update to its parent.
157 *
158 * If checking parent's state requires locking the parent, each inheriting
159 * iteration should lock and unlock both @pos->parent and @pos.
160 *
161 * Alternatively, a subsystem may choose to use a single global lock to
162 * synchronize ->css_online() and ->css_offline() against tree-walking
163 * operations.
164 *
165 * It is allowed to temporarily drop RCU read lock during iteration. The
166 * caller is responsible for ensuring that @pos remains accessible until
167 * the start of the next iteration by, for example, bumping the css refcnt.
168 */
169#define css_for_each_descendant_pre(pos, css) \
170 for ((pos) = css_next_descendant_pre(NULL, (css)); (pos); \
171 (pos) = css_next_descendant_pre((pos), (css)))
Tejun Heo15a4c832014-05-04 15:09:14 -0400172
Tejun Heoc326aa22015-05-13 16:24:16 -0400173/**
174 * css_for_each_descendant_post - post-order walk of a css's descendants
175 * @pos: the css * to use as the loop cursor
176 * @css: css whose descendants to walk
177 *
178 * Similar to css_for_each_descendant_pre() but performs post-order
179 * traversal instead. @root is included in the iteration and the last
180 * node to be visited.
181 *
182 * If a subsystem synchronizes ->css_online() and the start of iteration, a
183 * css which finished ->css_online() is guaranteed to be visible in the
184 * future iterations and will stay visible until the last reference is put.
185 * A css which hasn't finished ->css_online() or already finished
186 * ->css_offline() may show up during traversal. It's each subsystem's
187 * responsibility to synchronize against on/offlining.
188 *
189 * Note that the walk visibility guarantee example described in pre-order
190 * walk doesn't apply the same to post-order walks.
191 */
192#define css_for_each_descendant_post(pos, css) \
193 for ((pos) = css_next_descendant_post(NULL, (css)); (pos); \
194 (pos) = css_next_descendant_post((pos), (css)))
Tejun Heo48ddbe12012-04-01 12:09:56 -0700195
Tejun Heoc326aa22015-05-13 16:24:16 -0400196/**
197 * cgroup_taskset_for_each - iterate cgroup_taskset
198 * @task: the loop cursor
199 * @tset: taskset to iterate
200 */
201#define cgroup_taskset_for_each(task, tset) \
202 for ((task) = cgroup_taskset_first((tset)); (task); \
203 (task) = cgroup_taskset_next((tset)))
Tejun Heo0cb51d72014-05-16 13:22:49 -0400204
Tejun Heoc326aa22015-05-13 16:24:16 -0400205/*
206 * Inline functions.
207 */
Paul Menageddbcc7e2007-10-18 23:39:30 -0700208
Tejun Heo5de01072013-06-12 21:04:52 -0700209/**
210 * css_get - obtain a reference on the specified css
211 * @css: target css
212 *
213 * The caller must already have a reference.
Paul Menageddbcc7e2007-10-18 23:39:30 -0700214 */
Paul Menageddbcc7e2007-10-18 23:39:30 -0700215static inline void css_get(struct cgroup_subsys_state *css)
216{
Tejun Heo3b514d22014-05-16 13:22:47 -0400217 if (!(css->flags & CSS_NO_REF))
218 percpu_ref_get(&css->refcnt);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700219}
Paul Menagee7c5ec92009-01-07 18:08:38 -0800220
Tejun Heo5de01072013-06-12 21:04:52 -0700221/**
Johannes Weinere8ea14c2014-12-10 15:42:42 -0800222 * css_get_many - obtain references on the specified css
223 * @css: target css
224 * @n: number of references to get
225 *
226 * The caller must already have a reference.
227 */
228static inline void css_get_many(struct cgroup_subsys_state *css, unsigned int n)
229{
230 if (!(css->flags & CSS_NO_REF))
231 percpu_ref_get_many(&css->refcnt, n);
232}
233
234/**
Tejun Heo6f4524d2014-05-16 13:22:52 -0400235 * css_tryget - try to obtain a reference on the specified css
236 * @css: target css
237 *
238 * Obtain a reference on @css unless it already has reached zero and is
239 * being released. This function doesn't care whether @css is on or
240 * offline. The caller naturally needs to ensure that @css is accessible
241 * but doesn't have to be holding a reference on it - IOW, RCU protected
242 * access is good enough for this function. Returns %true if a reference
243 * count was successfully obtained; %false otherwise.
244 */
245static inline bool css_tryget(struct cgroup_subsys_state *css)
246{
247 if (!(css->flags & CSS_NO_REF))
248 return percpu_ref_tryget(&css->refcnt);
249 return true;
250}
251
252/**
Tejun Heoec903c02014-05-13 12:11:01 -0400253 * css_tryget_online - try to obtain a reference on the specified css if online
Tejun Heo5de01072013-06-12 21:04:52 -0700254 * @css: target css
255 *
Tejun Heoec903c02014-05-13 12:11:01 -0400256 * Obtain a reference on @css if it's online. The caller naturally needs
257 * to ensure that @css is accessible but doesn't have to be holding a
Tejun Heo5de01072013-06-12 21:04:52 -0700258 * reference on it - IOW, RCU protected access is good enough for this
259 * function. Returns %true if a reference count was successfully obtained;
260 * %false otherwise.
261 */
Tejun Heoec903c02014-05-13 12:11:01 -0400262static inline bool css_tryget_online(struct cgroup_subsys_state *css)
Paul Menagee7c5ec92009-01-07 18:08:38 -0800263{
Tejun Heo3b514d22014-05-16 13:22:47 -0400264 if (!(css->flags & CSS_NO_REF))
265 return percpu_ref_tryget_live(&css->refcnt);
266 return true;
Paul Menagee7c5ec92009-01-07 18:08:38 -0800267}
268
Tejun Heo5de01072013-06-12 21:04:52 -0700269/**
270 * css_put - put a css reference
271 * @css: target css
272 *
Tejun Heoec903c02014-05-13 12:11:01 -0400273 * Put a reference obtained via css_get() and css_tryget_online().
Tejun Heo5de01072013-06-12 21:04:52 -0700274 */
Paul Menageddbcc7e2007-10-18 23:39:30 -0700275static inline void css_put(struct cgroup_subsys_state *css)
276{
Tejun Heo3b514d22014-05-16 13:22:47 -0400277 if (!(css->flags & CSS_NO_REF))
278 percpu_ref_put(&css->refcnt);
Paul Menageddbcc7e2007-10-18 23:39:30 -0700279}
280
Johannes Weinere8ea14c2014-12-10 15:42:42 -0800281/**
282 * css_put_many - put css references
283 * @css: target css
284 * @n: number of references to put
285 *
286 * Put references obtained via css_get() and css_tryget_online().
287 */
288static inline void css_put_many(struct cgroup_subsys_state *css, unsigned int n)
289{
290 if (!(css->flags & CSS_NO_REF))
291 percpu_ref_put_many(&css->refcnt, n);
292}
293
Tejun Heoc326aa22015-05-13 16:24:16 -0400294/**
295 * task_css_set_check - obtain a task's css_set with extra access conditions
296 * @task: the task to obtain css_set for
297 * @__c: extra condition expression to be passed to rcu_dereference_check()
Paul Menageddbcc7e2007-10-18 23:39:30 -0700298 *
Tejun Heoc326aa22015-05-13 16:24:16 -0400299 * A task's css_set is RCU protected, initialized and exited while holding
300 * task_lock(), and can only be modified while holding both cgroup_mutex
301 * and task_lock() while the task is alive. This macro verifies that the
302 * caller is inside proper critical section and returns @task's css_set.
303 *
304 * The caller can also specify additional allowed conditions via @__c, such
305 * as locks used during the cgroup_subsys::attach() methods.
Paul Menageddbcc7e2007-10-18 23:39:30 -0700306 */
Tejun Heoc326aa22015-05-13 16:24:16 -0400307#ifdef CONFIG_PROVE_RCU
308extern struct mutex cgroup_mutex;
309extern struct rw_semaphore css_set_rwsem;
310#define task_css_set_check(task, __c) \
311 rcu_dereference_check((task)->cgroups, \
312 lockdep_is_held(&cgroup_mutex) || \
313 lockdep_is_held(&css_set_rwsem) || \
314 ((task)->flags & PF_EXITING) || (__c))
315#else
316#define task_css_set_check(task, __c) \
317 rcu_dereference((task)->cgroups)
Tejun Heo2bd59d42014-02-11 11:52:49 -0500318#endif
Paul Menageddbcc7e2007-10-18 23:39:30 -0700319
Tejun Heoc326aa22015-05-13 16:24:16 -0400320/**
321 * task_css_check - obtain css for (task, subsys) w/ extra access conds
322 * @task: the target task
323 * @subsys_id: the target subsystem ID
324 * @__c: extra condition expression to be passed to rcu_dereference_check()
325 *
326 * Return the cgroup_subsys_state for the (@task, @subsys_id) pair. The
327 * synchronization rules are the same as task_css_set_check().
328 */
329#define task_css_check(task, subsys_id, __c) \
330 task_css_set_check((task), (__c))->subsys[(subsys_id)]
331
332/**
333 * task_css_set - obtain a task's css_set
334 * @task: the task to obtain css_set for
335 *
336 * See task_css_set_check().
337 */
338static inline struct css_set *task_css_set(struct task_struct *task)
339{
340 return task_css_set_check(task, false);
341}
342
343/**
344 * task_css - obtain css for (task, subsys)
345 * @task: the target task
346 * @subsys_id: the target subsystem ID
347 *
348 * See task_css_check().
349 */
350static inline struct cgroup_subsys_state *task_css(struct task_struct *task,
351 int subsys_id)
352{
353 return task_css_check(task, subsys_id, false);
354}
355
356/**
Linus Torvaldsbbe179f2015-06-26 19:50:04 -0700357 * task_get_css - find and get the css for (task, subsys)
358 * @task: the target task
359 * @subsys_id: the target subsystem ID
360 *
361 * Find the css for the (@task, @subsys_id) combination, increment a
362 * reference on and return it. This function is guaranteed to return a
363 * valid css.
364 */
365static inline struct cgroup_subsys_state *
366task_get_css(struct task_struct *task, int subsys_id)
367{
368 struct cgroup_subsys_state *css;
369
370 rcu_read_lock();
371 while (true) {
372 css = task_css(task, subsys_id);
373 if (likely(css_tryget_online(css)))
374 break;
375 cpu_relax();
376 }
377 rcu_read_unlock();
378 return css;
379}
380
381/**
Tejun Heoc326aa22015-05-13 16:24:16 -0400382 * task_css_is_root - test whether a task belongs to the root css
383 * @task: the target task
384 * @subsys_id: the target subsystem ID
385 *
386 * Test whether @task belongs to the root css on the specified subsystem.
387 * May be invoked in any context.
388 */
389static inline bool task_css_is_root(struct task_struct *task, int subsys_id)
390{
391 return task_css_check(task, subsys_id, true) ==
392 init_css_set.subsys[subsys_id];
393}
394
395static inline struct cgroup *task_cgroup(struct task_struct *task,
396 int subsys_id)
397{
398 return task_css(task, subsys_id)->cgroup;
399}
Tejun Heoa2dd4242014-03-19 10:23:55 -0400400
Tejun Heoaa6ec292014-07-09 10:08:08 -0400401/**
402 * cgroup_on_dfl - test whether a cgroup is on the default hierarchy
403 * @cgrp: the cgroup of interest
404 *
405 * The default hierarchy is the v2 interface of cgroup and this function
406 * can be used to test whether a cgroup is on the default hierarchy for
407 * cases where a subsystem should behave differnetly depending on the
408 * interface version.
409 *
410 * The set of behaviors which change on the default hierarchy are still
411 * being determined and the mount option is prefixed with __DEVEL__.
412 *
413 * List of changed behaviors:
414 *
415 * - Mount options "noprefix", "xattr", "clone_children", "release_agent"
416 * and "name" are disallowed.
417 *
418 * - When mounting an existing superblock, mount options should match.
419 *
420 * - Remount is disallowed.
421 *
422 * - rename(2) is disallowed.
423 *
424 * - "tasks" is removed. Everything should be at process granularity. Use
425 * "cgroup.procs" instead.
426 *
427 * - "cgroup.procs" is not sorted. pids will be unique unless they got
428 * recycled inbetween reads.
429 *
430 * - "release_agent" and "notify_on_release" are removed. Replacement
431 * notification mechanism will be implemented.
432 *
433 * - "cgroup.clone_children" is removed.
434 *
435 * - "cgroup.subtree_populated" is available. Its value is 0 if the cgroup
436 * and its descendants contain no task; otherwise, 1. The file also
437 * generates kernfs notification which can be monitored through poll and
438 * [di]notify when the value of the file changes.
439 *
440 * - cpuset: tasks will be kept in empty cpusets when hotplug happens and
441 * take masks of ancestors with non-empty cpus/mems, instead of being
442 * moved to an ancestor.
443 *
444 * - cpuset: a task can be moved into an empty cpuset, and again it takes
445 * masks of ancestors.
446 *
447 * - memcg: use_hierarchy is on by default and the cgroup file for the flag
448 * is not created.
449 *
450 * - blkcg: blk-throttle becomes properly hierarchical.
451 *
452 * - debug: disallowed on the default hierarchy.
453 */
Tejun Heoa2dd4242014-03-19 10:23:55 -0400454static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
455{
456 return cgrp->root == &cgrp_dfl_root;
457}
458
Tejun Heo07bc3562014-02-13 06:58:39 -0500459/* no synchronization, the result can only be used as a hint */
460static inline bool cgroup_has_tasks(struct cgroup *cgrp)
461{
462 return !list_empty(&cgrp->cset_links);
463}
464
Zefan Lif29374b2014-09-19 16:29:31 +0800465/* returns ino associated with a cgroup */
Tejun Heob1664922014-02-11 11:52:49 -0500466static inline ino_t cgroup_ino(struct cgroup *cgrp)
467{
Zefan Lif29374b2014-09-19 16:29:31 +0800468 return cgrp->kn->ino;
Tejun Heob1664922014-02-11 11:52:49 -0500469}
470
Tejun Heob4168642014-05-13 12:16:21 -0400471/* cft/css accessors for cftype->write() operation */
472static inline struct cftype *of_cft(struct kernfs_open_file *of)
Tejun Heo7da11272013-12-05 12:28:04 -0500473{
Tejun Heo2bd59d42014-02-11 11:52:49 -0500474 return of->kn->priv;
Tejun Heo7da11272013-12-05 12:28:04 -0500475}
476
Tejun Heob4168642014-05-13 12:16:21 -0400477struct cgroup_subsys_state *of_css(struct kernfs_open_file *of);
478
479/* cft/css accessors for cftype->seq_*() operations */
480static inline struct cftype *seq_cft(struct seq_file *seq)
481{
482 return of_cft(seq->private);
483}
484
485static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq)
486{
487 return of_css(seq->private);
488}
Tejun Heo59f52962014-02-11 11:52:49 -0500489
Tejun Heoe61734c2014-02-12 09:29:50 -0500490/*
491 * Name / path handling functions. All are thin wrappers around the kernfs
492 * counterparts and can be called under any context.
493 */
494
495static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
496{
Tejun Heofdce6bf2014-03-19 10:23:54 -0400497 return kernfs_name(cgrp->kn, buf, buflen);
Tejun Heoe61734c2014-02-12 09:29:50 -0500498}
499
500static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf,
501 size_t buflen)
502{
Tejun Heofdce6bf2014-03-19 10:23:54 -0400503 return kernfs_path(cgrp->kn, buf, buflen);
Tejun Heoe61734c2014-02-12 09:29:50 -0500504}
505
506static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
507{
Tejun Heofdce6bf2014-03-19 10:23:54 -0400508 pr_cont_kernfs_name(cgrp->kn);
Tejun Heoe61734c2014-02-12 09:29:50 -0500509}
510
511static inline void pr_cont_cgroup_path(struct cgroup *cgrp)
512{
Tejun Heofdce6bf2014-03-19 10:23:54 -0400513 pr_cont_kernfs_path(cgrp->kn);
Tejun Heoe61734c2014-02-12 09:29:50 -0500514}
515
Paul Menageddbcc7e2007-10-18 23:39:30 -0700516#else /* !CONFIG_CGROUPS */
517
Tejun Heof3ba5382015-01-06 12:02:46 -0500518struct cgroup_subsys_state;
519
Tejun Heoc326aa22015-05-13 16:24:16 -0400520static inline void css_put(struct cgroup_subsys_state *css) {}
521static inline int cgroup_attach_task_all(struct task_struct *from,
522 struct task_struct *t) { return 0; }
523static inline int cgroupstats_build(struct cgroupstats *stats,
524 struct dentry *dentry) { return -EINVAL; }
525
Paul Menageb4f48b62007-10-18 23:39:33 -0700526static inline void cgroup_fork(struct task_struct *p) {}
Paul Menage817929e2007-10-18 23:39:36 -0700527static inline void cgroup_post_fork(struct task_struct *p) {}
Li Zefan1ec41832014-03-28 15:22:19 +0800528static inline void cgroup_exit(struct task_struct *p) {}
Paul Menageddbcc7e2007-10-18 23:39:30 -0700529
Tejun Heoc326aa22015-05-13 16:24:16 -0400530static inline int cgroup_init_early(void) { return 0; }
531static inline int cgroup_init(void) { return 0; }
Sridhar Samudralad7926ee2010-05-30 22:24:39 +0200532
Paul Menageddbcc7e2007-10-18 23:39:30 -0700533#endif /* !CONFIG_CGROUPS */
534
Paul Menageddbcc7e2007-10-18 23:39:30 -0700535#endif /* _LINUX_CGROUP_H */