aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cgroup.h275
-rw-r--r--include/linux/cgroup_subsys.h30
-rw-r--r--include/linux/hugetlb_cgroup.h2
-rw-r--r--include/linux/memcontrol.h2
4 files changed, 149 insertions, 160 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 9450f025fe0c..c2515851c1aa 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -14,18 +14,17 @@
14#include <linux/rcupdate.h> 14#include <linux/rcupdate.h>
15#include <linux/rculist.h> 15#include <linux/rculist.h>
16#include <linux/cgroupstats.h> 16#include <linux/cgroupstats.h>
17#include <linux/prio_heap.h>
18#include <linux/rwsem.h> 17#include <linux/rwsem.h>
19#include <linux/idr.h> 18#include <linux/idr.h>
20#include <linux/workqueue.h> 19#include <linux/workqueue.h>
21#include <linux/xattr.h>
22#include <linux/fs.h> 20#include <linux/fs.h>
23#include <linux/percpu-refcount.h> 21#include <linux/percpu-refcount.h>
24#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/kernfs.h>
25 24
26#ifdef CONFIG_CGROUPS 25#ifdef CONFIG_CGROUPS
27 26
28struct cgroupfs_root; 27struct cgroup_root;
29struct cgroup_subsys; 28struct cgroup_subsys;
30struct inode; 29struct inode;
31struct cgroup; 30struct cgroup;
@@ -34,31 +33,16 @@ extern int cgroup_init_early(void);
34extern int cgroup_init(void); 33extern int cgroup_init(void);
35extern void cgroup_fork(struct task_struct *p); 34extern void cgroup_fork(struct task_struct *p);
36extern void cgroup_post_fork(struct task_struct *p); 35extern void cgroup_post_fork(struct task_struct *p);
37extern void cgroup_exit(struct task_struct *p, int run_callbacks); 36extern void cgroup_exit(struct task_struct *p);
38extern int cgroupstats_build(struct cgroupstats *stats, 37extern int cgroupstats_build(struct cgroupstats *stats,
39 struct dentry *dentry); 38 struct dentry *dentry);
40extern int cgroup_load_subsys(struct cgroup_subsys *ss);
41extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
42 39
43extern int proc_cgroup_show(struct seq_file *, void *); 40extern int proc_cgroup_show(struct seq_file *, void *);
44 41
45/* 42/* define the enumeration of all cgroup subsystems */
46 * Define the enumeration of all cgroup subsystems. 43#define SUBSYS(_x) _x ## _cgrp_id,
47 *
48 * We define ids for builtin subsystems and then modular ones.
49 */
50#define SUBSYS(_x) _x ## _subsys_id,
51enum cgroup_subsys_id { 44enum cgroup_subsys_id {
52#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
53#include <linux/cgroup_subsys.h>
54#undef IS_SUBSYS_ENABLED
55 CGROUP_BUILTIN_SUBSYS_COUNT,
56
57 __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1,
58
59#define IS_SUBSYS_ENABLED(option) IS_MODULE(option)
60#include <linux/cgroup_subsys.h> 45#include <linux/cgroup_subsys.h>
61#undef IS_SUBSYS_ENABLED
62 CGROUP_SUBSYS_COUNT, 46 CGROUP_SUBSYS_COUNT,
63}; 47};
64#undef SUBSYS 48#undef SUBSYS
@@ -153,11 +137,6 @@ enum {
153 CGRP_SANE_BEHAVIOR, 137 CGRP_SANE_BEHAVIOR,
154}; 138};
155 139
156struct cgroup_name {
157 struct rcu_head rcu_head;
158 char name[];
159};
160
161struct cgroup { 140struct cgroup {
162 unsigned long flags; /* "unsigned long" so bitops work */ 141 unsigned long flags; /* "unsigned long" so bitops work */
163 142
@@ -174,16 +153,17 @@ struct cgroup {
174 /* the number of attached css's */ 153 /* the number of attached css's */
175 int nr_css; 154 int nr_css;
176 155
156 atomic_t refcnt;
157
177 /* 158 /*
178 * We link our 'sibling' struct into our parent's 'children'. 159 * We link our 'sibling' struct into our parent's 'children'.
179 * Our children link their 'sibling' into our 'children'. 160 * Our children link their 'sibling' into our 'children'.
180 */ 161 */
181 struct list_head sibling; /* my parent's children */ 162 struct list_head sibling; /* my parent's children */
182 struct list_head children; /* my children */ 163 struct list_head children; /* my children */
183 struct list_head files; /* my files */
184 164
185 struct cgroup *parent; /* my parent */ 165 struct cgroup *parent; /* my parent */
186 struct dentry *dentry; /* cgroup fs entry, RCU protected */ 166 struct kernfs_node *kn; /* cgroup kernfs entry */
187 167
188 /* 168 /*
189 * Monotonically increasing unique serial number which defines a 169 * Monotonically increasing unique serial number which defines a
@@ -193,23 +173,13 @@ struct cgroup {
193 */ 173 */
194 u64 serial_nr; 174 u64 serial_nr;
195 175
196 /* 176 /* The bitmask of subsystems attached to this cgroup */
197 * This is a copy of dentry->d_name, and it's needed because 177 unsigned long subsys_mask;
198 * we can't use dentry->d_name in cgroup_path().
199 *
200 * You must acquire rcu_read_lock() to access cgrp->name, and
201 * the only place that can change it is rename(), which is
202 * protected by parent dir's i_mutex.
203 *
204 * Normally you should use cgroup_name() wrapper rather than
205 * access it directly.
206 */
207 struct cgroup_name __rcu *name;
208 178
209 /* Private pointers for each registered subsystem */ 179 /* Private pointers for each registered subsystem */
210 struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT]; 180 struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
211 181
212 struct cgroupfs_root *root; 182 struct cgroup_root *root;
213 183
214 /* 184 /*
215 * List of cgrp_cset_links pointing at css_sets with tasks in this 185 * List of cgrp_cset_links pointing at css_sets with tasks in this
@@ -237,14 +207,11 @@ struct cgroup {
237 /* For css percpu_ref killing and RCU-protected deletion */ 207 /* For css percpu_ref killing and RCU-protected deletion */
238 struct rcu_head rcu_head; 208 struct rcu_head rcu_head;
239 struct work_struct destroy_work; 209 struct work_struct destroy_work;
240
241 /* directory xattrs */
242 struct simple_xattrs xattrs;
243}; 210};
244 211
245#define MAX_CGROUP_ROOT_NAMELEN 64 212#define MAX_CGROUP_ROOT_NAMELEN 64
246 213
247/* cgroupfs_root->flags */ 214/* cgroup_root->flags */
248enum { 215enum {
249 /* 216 /*
250 * Unfortunately, cgroup core and various controllers are riddled 217 * Unfortunately, cgroup core and various controllers are riddled
@@ -262,8 +229,8 @@ enum {
262 * 229 *
263 * The followings are the behaviors currently affected this flag. 230 * The followings are the behaviors currently affected this flag.
264 * 231 *
265 * - Mount options "noprefix" and "clone_children" are disallowed. 232 * - Mount options "noprefix", "xattr", "clone_children",
266 * Also, cgroupfs file cgroup.clone_children is not created. 233 * "release_agent" and "name" are disallowed.
267 * 234 *
268 * - When mounting an existing superblock, mount options should 235 * - When mounting an existing superblock, mount options should
269 * match. 236 * match.
@@ -281,6 +248,11 @@ enum {
281 * - "release_agent" and "notify_on_release" are removed. 248 * - "release_agent" and "notify_on_release" are removed.
282 * Replacement notification mechanism will be implemented. 249 * Replacement notification mechanism will be implemented.
283 * 250 *
251 * - "cgroup.clone_children" is removed.
252 *
253 * - If mount is requested with sane_behavior but without any
254 * subsystem, the default unified hierarchy is mounted.
255 *
284 * - cpuset: tasks will be kept in empty cpusets when hotplug happens 256 * - cpuset: tasks will be kept in empty cpusets when hotplug happens
285 * and take masks of ancestors with non-empty cpus/mems, instead of 257 * and take masks of ancestors with non-empty cpus/mems, instead of
286 * being moved to an ancestor. 258 * being moved to an ancestor.
@@ -300,29 +272,24 @@ enum {
300 272
301 /* mount options live below bit 16 */ 273 /* mount options live below bit 16 */
302 CGRP_ROOT_OPTION_MASK = (1 << 16) - 1, 274 CGRP_ROOT_OPTION_MASK = (1 << 16) - 1,
303
304 CGRP_ROOT_SUBSYS_BOUND = (1 << 16), /* subsystems finished binding */
305}; 275};
306 276
307/* 277/*
308 * A cgroupfs_root represents the root of a cgroup hierarchy, and may be 278 * A cgroup_root represents the root of a cgroup hierarchy, and may be
309 * associated with a superblock to form an active hierarchy. This is 279 * associated with a kernfs_root to form an active hierarchy. This is
310 * internal to cgroup core. Don't access directly from controllers. 280 * internal to cgroup core. Don't access directly from controllers.
311 */ 281 */
312struct cgroupfs_root { 282struct cgroup_root {
313 struct super_block *sb; 283 struct kernfs_root *kf_root;
314
315 /* The bitmask of subsystems attached to this hierarchy */
316 unsigned long subsys_mask;
317 284
318 /* Unique id for this hierarchy. */ 285 /* Unique id for this hierarchy. */
319 int hierarchy_id; 286 int hierarchy_id;
320 287
321 /* The root cgroup for this hierarchy */ 288 /* The root cgroup. Root is destroyed on its release. */
322 struct cgroup top_cgroup; 289 struct cgroup cgrp;
323 290
324 /* Tracks how many cgroups are currently defined in hierarchy.*/ 291 /* Number of cgroups in the hierarchy, used only for /proc/cgroups */
325 int number_of_cgroups; 292 atomic_t nr_cgrps;
326 293
327 /* A list running through the active hierarchies */ 294 /* A list running through the active hierarchies */
328 struct list_head root_list; 295 struct list_head root_list;
@@ -360,10 +327,14 @@ struct css_set {
360 struct hlist_node hlist; 327 struct hlist_node hlist;
361 328
362 /* 329 /*
363 * List running through all tasks using this cgroup 330 * Lists running through all tasks using this cgroup group.
364 * group. Protected by css_set_lock 331 * mg_tasks lists tasks which belong to this cset but are in the
332 * process of being migrated out or in. Protected by
333 * css_set_rwsem, but, during migration, once tasks are moved to
334 * mg_tasks, it can be read safely while holding cgroup_mutex.
365 */ 335 */
366 struct list_head tasks; 336 struct list_head tasks;
337 struct list_head mg_tasks;
367 338
368 /* 339 /*
369 * List of cgrp_cset_links pointing at cgroups referenced from this 340 * List of cgrp_cset_links pointing at cgroups referenced from this
@@ -372,13 +343,29 @@ struct css_set {
372 struct list_head cgrp_links; 343 struct list_head cgrp_links;
373 344
374 /* 345 /*
375 * Set of subsystem states, one for each subsystem. This array 346 * Set of subsystem states, one for each subsystem. This array is
376 * is immutable after creation apart from the init_css_set 347 * immutable after creation apart from the init_css_set during
377 * during subsystem registration (at boot time) and modular subsystem 348 * subsystem registration (at boot time).
378 * loading/unloading.
379 */ 349 */
380 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; 350 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
381 351
352 /*
353 * List of csets participating in the on-going migration either as
354 * source or destination. Protected by cgroup_mutex.
355 */
356 struct list_head mg_preload_node;
357 struct list_head mg_node;
358
359 /*
360 * If this cset is acting as the source of migration the following
361 * two fields are set. mg_src_cgrp is the source cgroup of the
362 * on-going migration and mg_dst_cset is the destination cset the
363 * target tasks on this cset should be migrated to. Protected by
364 * cgroup_mutex.
365 */
366 struct cgroup *mg_src_cgrp;
367 struct css_set *mg_dst_cset;
368
382 /* For RCU-protected deletion */ 369 /* For RCU-protected deletion */
383 struct rcu_head rcu_head; 370 struct rcu_head rcu_head;
384}; 371};
@@ -397,6 +384,7 @@ enum {
397 CFTYPE_NOT_ON_ROOT = (1 << 1), /* don't create on root cgrp */ 384 CFTYPE_NOT_ON_ROOT = (1 << 1), /* don't create on root cgrp */
398 CFTYPE_INSANE = (1 << 2), /* don't create if sane_behavior */ 385 CFTYPE_INSANE = (1 << 2), /* don't create if sane_behavior */
399 CFTYPE_NO_PREFIX = (1 << 3), /* (DON'T USE FOR NEW FILES) no subsys prefix */ 386 CFTYPE_NO_PREFIX = (1 << 3), /* (DON'T USE FOR NEW FILES) no subsys prefix */
387 CFTYPE_ONLY_ON_DFL = (1 << 4), /* only on default hierarchy */
400}; 388};
401 389
402#define MAX_CFTYPE_NAME 64 390#define MAX_CFTYPE_NAME 64
@@ -416,8 +404,9 @@ struct cftype {
416 umode_t mode; 404 umode_t mode;
417 405
418 /* 406 /*
419 * If non-zero, defines the maximum length of string that can 407 * The maximum length of string, excluding trailing nul, that can
420 * be passed to write_string; defaults to 64 408 * be passed to write_string. If < PAGE_SIZE-1, PAGE_SIZE-1 is
409 * assumed.
421 */ 410 */
422 size_t max_write_len; 411 size_t max_write_len;
423 412
@@ -425,10 +414,12 @@ struct cftype {
425 unsigned int flags; 414 unsigned int flags;
426 415
427 /* 416 /*
428 * The subsys this file belongs to. Initialized automatically 417 * Fields used for internal bookkeeping. Initialized automatically
429 * during registration. NULL for cgroup core files. 418 * during registration.
430 */ 419 */
431 struct cgroup_subsys *ss; 420 struct cgroup_subsys *ss; /* NULL for cgroup core files */
421 struct list_head node; /* anchored at ss->cfts */
422 struct kernfs_ops *kf_ops;
432 423
433 /* 424 /*
434 * read_u64() is a shortcut for the common case of returning a 425 * read_u64() is a shortcut for the common case of returning a
@@ -467,7 +458,7 @@ struct cftype {
467 * Returns 0 or -ve error code. 458 * Returns 0 or -ve error code.
468 */ 459 */
469 int (*write_string)(struct cgroup_subsys_state *css, struct cftype *cft, 460 int (*write_string)(struct cgroup_subsys_state *css, struct cftype *cft,
470 const char *buffer); 461 char *buffer);
471 /* 462 /*
472 * trigger() callback can be used to get some kick from the 463 * trigger() callback can be used to get some kick from the
473 * userspace, when the actual string written is not important 464 * userspace, when the actual string written is not important
@@ -475,37 +466,18 @@ struct cftype {
475 * kick type for multiplexing. 466 * kick type for multiplexing.
476 */ 467 */
477 int (*trigger)(struct cgroup_subsys_state *css, unsigned int event); 468 int (*trigger)(struct cgroup_subsys_state *css, unsigned int event);
478};
479 469
480/* 470#ifdef CONFIG_DEBUG_LOCK_ALLOC
481 * cftype_sets describe cftypes belonging to a subsystem and are chained at 471 struct lock_class_key lockdep_key;
482 * cgroup_subsys->cftsets. Each cftset points to an array of cftypes 472#endif
483 * terminated by zero length name.
484 */
485struct cftype_set {
486 struct list_head node; /* chained at subsys->cftsets */
487 struct cftype *cfts;
488}; 473};
489 474
490/* 475extern struct cgroup_root cgrp_dfl_root;
491 * cgroupfs file entry, pointed to from leaf dentry->d_fsdata. Don't
492 * access directly.
493 */
494struct cfent {
495 struct list_head node;
496 struct dentry *dentry;
497 struct cftype *type;
498 struct cgroup_subsys_state *css;
499
500 /* file xattrs */
501 struct simple_xattrs xattrs;
502};
503 476
504/* seq_file->private points to the following, only ->priv is public */ 477static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
505struct cgroup_open_file { 478{
506 struct cfent *cfe; 479 return cgrp->root == &cgrp_dfl_root;
507 void *priv; 480}
508};
509 481
510/* 482/*
511 * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details. This 483 * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details. This
@@ -516,34 +488,63 @@ static inline bool cgroup_sane_behavior(const struct cgroup *cgrp)
516 return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR; 488 return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR;
517} 489}
518 490
519/* Caller should hold rcu_read_lock() */ 491/* no synchronization, the result can only be used as a hint */
520static inline const char *cgroup_name(const struct cgroup *cgrp) 492static inline bool cgroup_has_tasks(struct cgroup *cgrp)
521{ 493{
522 return rcu_dereference(cgrp->name)->name; 494 return !list_empty(&cgrp->cset_links);
523} 495}
524 496
525static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq) 497/* returns ino associated with a cgroup, 0 indicates unmounted root */
498static inline ino_t cgroup_ino(struct cgroup *cgrp)
526{ 499{
527 struct cgroup_open_file *of = seq->private; 500 if (cgrp->kn)
528 return of->cfe->css; 501 return cgrp->kn->ino;
502 else
503 return 0;
529} 504}
530 505
531static inline struct cftype *seq_cft(struct seq_file *seq) 506static inline struct cftype *seq_cft(struct seq_file *seq)
532{ 507{
533 struct cgroup_open_file *of = seq->private; 508 struct kernfs_open_file *of = seq->private;
534 return of->cfe->type; 509
510 return of->kn->priv;
511}
512
513struct cgroup_subsys_state *seq_css(struct seq_file *seq);
514
515/*
516 * Name / path handling functions. All are thin wrappers around the kernfs
517 * counterparts and can be called under any context.
518 */
519
520static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
521{
522 return kernfs_name(cgrp->kn, buf, buflen);
535} 523}
536 524
525static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf,
526 size_t buflen)
527{
528 return kernfs_path(cgrp->kn, buf, buflen);
529}
530
531static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
532{
533 pr_cont_kernfs_name(cgrp->kn);
534}
535
536static inline void pr_cont_cgroup_path(struct cgroup *cgrp)
537{
538 pr_cont_kernfs_path(cgrp->kn);
539}
540
541char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
542
537int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 543int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
538int cgroup_rm_cftypes(struct cftype *cfts); 544int cgroup_rm_cftypes(struct cftype *cfts);
539 545
540bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); 546bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
541 547
542int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
543int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
544
545int cgroup_task_count(const struct cgroup *cgrp);
546
547/* 548/*
548 * Control Group taskset, used to pass around set of tasks to cgroup_subsys 549 * Control Group taskset, used to pass around set of tasks to cgroup_subsys
549 * methods. 550 * methods.
@@ -551,22 +552,15 @@ int cgroup_task_count(const struct cgroup *cgrp);
551struct cgroup_taskset; 552struct cgroup_taskset;
552struct task_struct *cgroup_taskset_first(struct cgroup_taskset *tset); 553struct task_struct *cgroup_taskset_first(struct cgroup_taskset *tset);
553struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset); 554struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset);
554struct cgroup_subsys_state *cgroup_taskset_cur_css(struct cgroup_taskset *tset,
555 int subsys_id);
556int cgroup_taskset_size(struct cgroup_taskset *tset);
557 555
558/** 556/**
559 * cgroup_taskset_for_each - iterate cgroup_taskset 557 * cgroup_taskset_for_each - iterate cgroup_taskset
560 * @task: the loop cursor 558 * @task: the loop cursor
561 * @skip_css: skip if task's css matches this, %NULL to iterate through all
562 * @tset: taskset to iterate 559 * @tset: taskset to iterate
563 */ 560 */
564#define cgroup_taskset_for_each(task, skip_css, tset) \ 561#define cgroup_taskset_for_each(task, tset) \
565 for ((task) = cgroup_taskset_first((tset)); (task); \ 562 for ((task) = cgroup_taskset_first((tset)); (task); \
566 (task) = cgroup_taskset_next((tset))) \ 563 (task) = cgroup_taskset_next((tset)))
567 if (!(skip_css) || \
568 cgroup_taskset_cur_css((tset), \
569 (skip_css)->ss->subsys_id) != (skip_css))
570 564
571/* 565/*
572 * Control Group subsystem type. 566 * Control Group subsystem type.
@@ -591,7 +585,6 @@ struct cgroup_subsys {
591 struct task_struct *task); 585 struct task_struct *task);
592 void (*bind)(struct cgroup_subsys_state *root_css); 586 void (*bind)(struct cgroup_subsys_state *root_css);
593 587
594 int subsys_id;
595 int disabled; 588 int disabled;
596 int early_init; 589 int early_init;
597 590
@@ -610,27 +603,26 @@ struct cgroup_subsys {
610 bool broken_hierarchy; 603 bool broken_hierarchy;
611 bool warned_broken_hierarchy; 604 bool warned_broken_hierarchy;
612 605
606 /* the following two fields are initialized automtically during boot */
607 int id;
613#define MAX_CGROUP_TYPE_NAMELEN 32 608#define MAX_CGROUP_TYPE_NAMELEN 32
614 const char *name; 609 const char *name;
615 610
616 /* link to parent, protected by cgroup_lock() */ 611 /* link to parent, protected by cgroup_lock() */
617 struct cgroupfs_root *root; 612 struct cgroup_root *root;
618 613
619 /* list of cftype_sets */ 614 /*
620 struct list_head cftsets; 615 * List of cftypes. Each entry is the first entry of an array
616 * terminated by zero length name.
617 */
618 struct list_head cfts;
621 619
622 /* base cftypes, automatically [de]registered with subsys itself */ 620 /* base cftypes, automatically registered with subsys itself */
623 struct cftype *base_cftypes; 621 struct cftype *base_cftypes;
624 struct cftype_set base_cftset;
625
626 /* should be defined only by modular subsystems */
627 struct module *module;
628}; 622};
629 623
630#define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys; 624#define SUBSYS(_x) extern struct cgroup_subsys _x ## _cgrp_subsys;
631#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
632#include <linux/cgroup_subsys.h> 625#include <linux/cgroup_subsys.h>
633#undef IS_SUBSYS_ENABLED
634#undef SUBSYS 626#undef SUBSYS
635 627
636/** 628/**
@@ -661,10 +653,12 @@ struct cgroup_subsys_state *css_parent(struct cgroup_subsys_state *css)
661 */ 653 */
662#ifdef CONFIG_PROVE_RCU 654#ifdef CONFIG_PROVE_RCU
663extern struct mutex cgroup_mutex; 655extern struct mutex cgroup_mutex;
656extern struct rw_semaphore css_set_rwsem;
664#define task_css_set_check(task, __c) \ 657#define task_css_set_check(task, __c) \
665 rcu_dereference_check((task)->cgroups, \ 658 rcu_dereference_check((task)->cgroups, \
666 lockdep_is_held(&(task)->alloc_lock) || \ 659 lockdep_is_held(&cgroup_mutex) || \
667 lockdep_is_held(&cgroup_mutex) || (__c)) 660 lockdep_is_held(&css_set_rwsem) || \
661 ((task)->flags & PF_EXITING) || (__c))
668#else 662#else
669#define task_css_set_check(task, __c) \ 663#define task_css_set_check(task, __c) \
670 rcu_dereference((task)->cgroups) 664 rcu_dereference((task)->cgroups)
@@ -837,16 +831,11 @@ void css_task_iter_start(struct cgroup_subsys_state *css,
837struct task_struct *css_task_iter_next(struct css_task_iter *it); 831struct task_struct *css_task_iter_next(struct css_task_iter *it);
838void css_task_iter_end(struct css_task_iter *it); 832void css_task_iter_end(struct css_task_iter *it);
839 833
840int css_scan_tasks(struct cgroup_subsys_state *css,
841 bool (*test)(struct task_struct *, void *),
842 void (*process)(struct task_struct *, void *),
843 void *data, struct ptr_heap *heap);
844
845int cgroup_attach_task_all(struct task_struct *from, struct task_struct *); 834int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
846int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from); 835int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
847 836
848struct cgroup_subsys_state *css_from_dir(struct dentry *dentry, 837struct cgroup_subsys_state *css_tryget_from_dir(struct dentry *dentry,
849 struct cgroup_subsys *ss); 838 struct cgroup_subsys *ss);
850 839
851#else /* !CONFIG_CGROUPS */ 840#else /* !CONFIG_CGROUPS */
852 841
@@ -854,7 +843,7 @@ static inline int cgroup_init_early(void) { return 0; }
854static inline int cgroup_init(void) { return 0; } 843static inline int cgroup_init(void) { return 0; }
855static inline void cgroup_fork(struct task_struct *p) {} 844static inline void cgroup_fork(struct task_struct *p) {}
856static inline void cgroup_post_fork(struct task_struct *p) {} 845static inline void cgroup_post_fork(struct task_struct *p) {}
857static inline void cgroup_exit(struct task_struct *p, int callbacks) {} 846static inline void cgroup_exit(struct task_struct *p) {}
858 847
859static inline int cgroupstats_build(struct cgroupstats *stats, 848static inline int cgroupstats_build(struct cgroupstats *stats,
860 struct dentry *dentry) 849 struct dentry *dentry)
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 7b99d717411d..768fe44e19f0 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -3,51 +3,51 @@
3 * 3 *
4 * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS. 4 * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
5 */ 5 */
6#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS) 6#if IS_ENABLED(CONFIG_CPUSETS)
7SUBSYS(cpuset) 7SUBSYS(cpuset)
8#endif 8#endif
9 9
10#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG) 10#if IS_ENABLED(CONFIG_CGROUP_DEBUG)
11SUBSYS(debug) 11SUBSYS(debug)
12#endif 12#endif
13 13
14#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED) 14#if IS_ENABLED(CONFIG_CGROUP_SCHED)
15SUBSYS(cpu_cgroup) 15SUBSYS(cpu)
16#endif 16#endif
17 17
18#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT) 18#if IS_ENABLED(CONFIG_CGROUP_CPUACCT)
19SUBSYS(cpuacct) 19SUBSYS(cpuacct)
20#endif 20#endif
21 21
22#if IS_SUBSYS_ENABLED(CONFIG_MEMCG) 22#if IS_ENABLED(CONFIG_MEMCG)
23SUBSYS(mem_cgroup) 23SUBSYS(memory)
24#endif 24#endif
25 25
26#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE) 26#if IS_ENABLED(CONFIG_CGROUP_DEVICE)
27SUBSYS(devices) 27SUBSYS(devices)
28#endif 28#endif
29 29
30#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER) 30#if IS_ENABLED(CONFIG_CGROUP_FREEZER)
31SUBSYS(freezer) 31SUBSYS(freezer)
32#endif 32#endif
33 33
34#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_NET_CLASSID) 34#if IS_ENABLED(CONFIG_CGROUP_NET_CLASSID)
35SUBSYS(net_cls) 35SUBSYS(net_cls)
36#endif 36#endif
37 37
38#if IS_SUBSYS_ENABLED(CONFIG_BLK_CGROUP) 38#if IS_ENABLED(CONFIG_BLK_CGROUP)
39SUBSYS(blkio) 39SUBSYS(blkio)
40#endif 40#endif
41 41
42#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_PERF) 42#if IS_ENABLED(CONFIG_CGROUP_PERF)
43SUBSYS(perf) 43SUBSYS(perf_event)
44#endif 44#endif
45 45
46#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_NET_PRIO) 46#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
47SUBSYS(net_prio) 47SUBSYS(net_prio)
48#endif 48#endif
49 49
50#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_HUGETLB) 50#if IS_ENABLED(CONFIG_CGROUP_HUGETLB)
51SUBSYS(hugetlb) 51SUBSYS(hugetlb)
52#endif 52#endif
53/* 53/*
diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h
index 787bba3bf552..0129f89cf98d 100644
--- a/include/linux/hugetlb_cgroup.h
+++ b/include/linux/hugetlb_cgroup.h
@@ -49,7 +49,7 @@ int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
49 49
50static inline bool hugetlb_cgroup_disabled(void) 50static inline bool hugetlb_cgroup_disabled(void)
51{ 51{
52 if (hugetlb_subsys.disabled) 52 if (hugetlb_cgrp_subsys.disabled)
53 return true; 53 return true;
54 return false; 54 return false;
55} 55}
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index abd0113b6620..eccfb4a4b379 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -162,7 +162,7 @@ extern int do_swap_account;
162 162
163static inline bool mem_cgroup_disabled(void) 163static inline bool mem_cgroup_disabled(void)
164{ 164{
165 if (mem_cgroup_subsys.disabled) 165 if (memory_cgrp_subsys.disabled)
166 return true; 166 return true;
167 return false; 167 return false;
168} 168}