aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h125
1 files changed, 54 insertions, 71 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index c4901c19668b..7bb274487c89 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -256,68 +256,7 @@ struct cgroup {
256 256
257/* cgroup_root->flags */ 257/* cgroup_root->flags */
258enum { 258enum {
259 /* 259 CGRP_ROOT_SANE_BEHAVIOR = (1 << 0), /* __DEVEL__sane_behavior specified */
260 * Unfortunately, cgroup core and various controllers are riddled
261 * with idiosyncrasies and pointless options. The following flag,
262 * when set, will force sane behavior - some options are forced on,
263 * others are disallowed, and some controllers will change their
264 * hierarchical or other behaviors.
265 *
266 * The set of behaviors affected by this flag are still being
267 * determined and developed and the mount option for this flag is
268 * prefixed with __DEVEL__. The prefix will be dropped once we
269 * reach the point where all behaviors are compatible with the
270 * planned unified hierarchy, which will automatically turn on this
271 * flag.
272 *
273 * The followings are the behaviors currently affected this flag.
274 *
275 * - Mount options "noprefix", "xattr", "clone_children",
276 * "release_agent" and "name" are disallowed.
277 *
278 * - When mounting an existing superblock, mount options should
279 * match.
280 *
281 * - Remount is disallowed.
282 *
283 * - rename(2) is disallowed.
284 *
285 * - "tasks" is removed. Everything should be at process
286 * granularity. Use "cgroup.procs" instead.
287 *
288 * - "cgroup.procs" is not sorted. pids will be unique unless they
289 * got recycled inbetween reads.
290 *
291 * - "release_agent" and "notify_on_release" are removed.
292 * Replacement notification mechanism will be implemented.
293 *
294 * - "cgroup.clone_children" is removed.
295 *
296 * - "cgroup.subtree_populated" is available. Its value is 0 if
297 * the cgroup and its descendants contain no task; otherwise, 1.
298 * The file also generates kernfs notification which can be
299 * monitored through poll and [di]notify when the value of the
300 * file changes.
301 *
302 * - If mount is requested with sane_behavior but without any
303 * subsystem, the default unified hierarchy is mounted.
304 *
305 * - cpuset: tasks will be kept in empty cpusets when hotplug happens
306 * and take masks of ancestors with non-empty cpus/mems, instead of
307 * being moved to an ancestor.
308 *
309 * - cpuset: a task can be moved into an empty cpuset, and again it
310 * takes masks of ancestors.
311 *
312 * - memcg: use_hierarchy is on by default and the cgroup file for
313 * the flag is not created.
314 *
315 * - blkcg: blk-throttle becomes properly hierarchical.
316 *
317 * - debug: disallowed on the default hierarchy.
318 */
319 CGRP_ROOT_SANE_BEHAVIOR = (1 << 0),
320
321 CGRP_ROOT_NOPREFIX = (1 << 1), /* mounted subsystems have no named prefix */ 260 CGRP_ROOT_NOPREFIX = (1 << 1), /* mounted subsystems have no named prefix */
322 CGRP_ROOT_XATTR = (1 << 2), /* supports extended attributes */ 261 CGRP_ROOT_XATTR = (1 << 2), /* supports extended attributes */
323}; 262};
@@ -531,20 +470,64 @@ struct cftype {
531extern struct cgroup_root cgrp_dfl_root; 470extern struct cgroup_root cgrp_dfl_root;
532extern struct css_set init_css_set; 471extern struct css_set init_css_set;
533 472
473/**
474 * cgroup_on_dfl - test whether a cgroup is on the default hierarchy
475 * @cgrp: the cgroup of interest
476 *
477 * The default hierarchy is the v2 interface of cgroup and this function
478 * can be used to test whether a cgroup is on the default hierarchy for
479 * cases where a subsystem should behave differnetly depending on the
480 * interface version.
481 *
482 * The set of behaviors which change on the default hierarchy are still
483 * being determined and the mount option is prefixed with __DEVEL__.
484 *
485 * List of changed behaviors:
486 *
487 * - Mount options "noprefix", "xattr", "clone_children", "release_agent"
488 * and "name" are disallowed.
489 *
490 * - When mounting an existing superblock, mount options should match.
491 *
492 * - Remount is disallowed.
493 *
494 * - rename(2) is disallowed.
495 *
496 * - "tasks" is removed. Everything should be at process granularity. Use
497 * "cgroup.procs" instead.
498 *
499 * - "cgroup.procs" is not sorted. pids will be unique unless they got
500 * recycled inbetween reads.
501 *
502 * - "release_agent" and "notify_on_release" are removed. Replacement
503 * notification mechanism will be implemented.
504 *
505 * - "cgroup.clone_children" is removed.
506 *
507 * - "cgroup.subtree_populated" is available. Its value is 0 if the cgroup
508 * and its descendants contain no task; otherwise, 1. The file also
509 * generates kernfs notification which can be monitored through poll and
510 * [di]notify when the value of the file changes.
511 *
512 * - cpuset: tasks will be kept in empty cpusets when hotplug happens and
513 * take masks of ancestors with non-empty cpus/mems, instead of being
514 * moved to an ancestor.
515 *
516 * - cpuset: a task can be moved into an empty cpuset, and again it takes
517 * masks of ancestors.
518 *
519 * - memcg: use_hierarchy is on by default and the cgroup file for the flag
520 * is not created.
521 *
522 * - blkcg: blk-throttle becomes properly hierarchical.
523 *
524 * - debug: disallowed on the default hierarchy.
525 */
534static inline bool cgroup_on_dfl(const struct cgroup *cgrp) 526static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
535{ 527{
536 return cgrp->root == &cgrp_dfl_root; 528 return cgrp->root == &cgrp_dfl_root;
537} 529}
538 530
539/*
540 * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details. This
541 * function can be called as long as @cgrp is accessible.
542 */
543static inline bool cgroup_sane_behavior(const struct cgroup *cgrp)
544{
545 return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR;
546}
547
548/* no synchronization, the result can only be used as a hint */ 531/* no synchronization, the result can only be used as a hint */
549static inline bool cgroup_has_tasks(struct cgroup *cgrp) 532static inline bool cgroup_has_tasks(struct cgroup *cgrp)
550{ 533{