|
@@ -256,68 +256,7 @@ struct cgroup {
|
|
|
|
|
|
/* cgroup_root->flags */
|
|
/* cgroup_root->flags */
|
|
enum {
|
|
enum {
|
|
- /*
|
|
|
|
- * Unfortunately, cgroup core and various controllers are riddled
|
|
|
|
- * with idiosyncrasies and pointless options. The following flag,
|
|
|
|
- * when set, will force sane behavior - some options are forced on,
|
|
|
|
- * others are disallowed, and some controllers will change their
|
|
|
|
- * hierarchical or other behaviors.
|
|
|
|
- *
|
|
|
|
- * The set of behaviors affected by this flag are still being
|
|
|
|
- * determined and developed and the mount option for this flag is
|
|
|
|
- * prefixed with __DEVEL__. The prefix will be dropped once we
|
|
|
|
- * reach the point where all behaviors are compatible with the
|
|
|
|
- * planned unified hierarchy, which will automatically turn on this
|
|
|
|
- * flag.
|
|
|
|
- *
|
|
|
|
- * The followings are the behaviors currently affected this flag.
|
|
|
|
- *
|
|
|
|
- * - Mount options "noprefix", "xattr", "clone_children",
|
|
|
|
- * "release_agent" and "name" are disallowed.
|
|
|
|
- *
|
|
|
|
- * - When mounting an existing superblock, mount options should
|
|
|
|
- * match.
|
|
|
|
- *
|
|
|
|
- * - Remount is disallowed.
|
|
|
|
- *
|
|
|
|
- * - rename(2) is disallowed.
|
|
|
|
- *
|
|
|
|
- * - "tasks" is removed. Everything should be at process
|
|
|
|
- * granularity. Use "cgroup.procs" instead.
|
|
|
|
- *
|
|
|
|
- * - "cgroup.procs" is not sorted. pids will be unique unless they
|
|
|
|
- * got recycled inbetween reads.
|
|
|
|
- *
|
|
|
|
- * - "release_agent" and "notify_on_release" are removed.
|
|
|
|
- * Replacement notification mechanism will be implemented.
|
|
|
|
- *
|
|
|
|
- * - "cgroup.clone_children" is removed.
|
|
|
|
- *
|
|
|
|
- * - "cgroup.subtree_populated" is available. Its value is 0 if
|
|
|
|
- * the cgroup and its descendants contain no task; otherwise, 1.
|
|
|
|
- * The file also generates kernfs notification which can be
|
|
|
|
- * monitored through poll and [di]notify when the value of the
|
|
|
|
- * file changes.
|
|
|
|
- *
|
|
|
|
- * - If mount is requested with sane_behavior but without any
|
|
|
|
- * subsystem, the default unified hierarchy is mounted.
|
|
|
|
- *
|
|
|
|
- * - cpuset: tasks will be kept in empty cpusets when hotplug happens
|
|
|
|
- * and take masks of ancestors with non-empty cpus/mems, instead of
|
|
|
|
- * being moved to an ancestor.
|
|
|
|
- *
|
|
|
|
- * - cpuset: a task can be moved into an empty cpuset, and again it
|
|
|
|
- * takes masks of ancestors.
|
|
|
|
- *
|
|
|
|
- * - memcg: use_hierarchy is on by default and the cgroup file for
|
|
|
|
- * the flag is not created.
|
|
|
|
- *
|
|
|
|
- * - blkcg: blk-throttle becomes properly hierarchical.
|
|
|
|
- *
|
|
|
|
- * - debug: disallowed on the default hierarchy.
|
|
|
|
- */
|
|
|
|
- CGRP_ROOT_SANE_BEHAVIOR = (1 << 0),
|
|
|
|
-
|
|
|
|
|
|
+ CGRP_ROOT_SANE_BEHAVIOR = (1 << 0), /* __DEVEL__sane_behavior specified */
|
|
CGRP_ROOT_NOPREFIX = (1 << 1), /* mounted subsystems have no named prefix */
|
|
CGRP_ROOT_NOPREFIX = (1 << 1), /* mounted subsystems have no named prefix */
|
|
CGRP_ROOT_XATTR = (1 << 2), /* supports extended attributes */
|
|
CGRP_ROOT_XATTR = (1 << 2), /* supports extended attributes */
|
|
};
|
|
};
|
|
@@ -531,20 +470,64 @@ struct cftype {
|
|
extern struct cgroup_root cgrp_dfl_root;
|
|
extern struct cgroup_root cgrp_dfl_root;
|
|
extern struct css_set init_css_set;
|
|
extern struct css_set init_css_set;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * cgroup_on_dfl - test whether a cgroup is on the default hierarchy
|
|
|
|
+ * @cgrp: the cgroup of interest
|
|
|
|
+ *
|
|
|
|
+ * The default hierarchy is the v2 interface of cgroup and this function
|
|
|
|
+ * can be used to test whether a cgroup is on the default hierarchy for
|
|
|
|
+ * cases where a subsystem should behave differnetly depending on the
|
|
|
|
+ * interface version.
|
|
|
|
+ *
|
|
|
|
+ * The set of behaviors which change on the default hierarchy are still
|
|
|
|
+ * being determined and the mount option is prefixed with __DEVEL__.
|
|
|
|
+ *
|
|
|
|
+ * List of changed behaviors:
|
|
|
|
+ *
|
|
|
|
+ * - Mount options "noprefix", "xattr", "clone_children", "release_agent"
|
|
|
|
+ * and "name" are disallowed.
|
|
|
|
+ *
|
|
|
|
+ * - When mounting an existing superblock, mount options should match.
|
|
|
|
+ *
|
|
|
|
+ * - Remount is disallowed.
|
|
|
|
+ *
|
|
|
|
+ * - rename(2) is disallowed.
|
|
|
|
+ *
|
|
|
|
+ * - "tasks" is removed. Everything should be at process granularity. Use
|
|
|
|
+ * "cgroup.procs" instead.
|
|
|
|
+ *
|
|
|
|
+ * - "cgroup.procs" is not sorted. pids will be unique unless they got
|
|
|
|
+ * recycled inbetween reads.
|
|
|
|
+ *
|
|
|
|
+ * - "release_agent" and "notify_on_release" are removed. Replacement
|
|
|
|
+ * notification mechanism will be implemented.
|
|
|
|
+ *
|
|
|
|
+ * - "cgroup.clone_children" is removed.
|
|
|
|
+ *
|
|
|
|
+ * - "cgroup.subtree_populated" is available. Its value is 0 if the cgroup
|
|
|
|
+ * and its descendants contain no task; otherwise, 1. The file also
|
|
|
|
+ * generates kernfs notification which can be monitored through poll and
|
|
|
|
+ * [di]notify when the value of the file changes.
|
|
|
|
+ *
|
|
|
|
+ * - cpuset: tasks will be kept in empty cpusets when hotplug happens and
|
|
|
|
+ * take masks of ancestors with non-empty cpus/mems, instead of being
|
|
|
|
+ * moved to an ancestor.
|
|
|
|
+ *
|
|
|
|
+ * - cpuset: a task can be moved into an empty cpuset, and again it takes
|
|
|
|
+ * masks of ancestors.
|
|
|
|
+ *
|
|
|
|
+ * - memcg: use_hierarchy is on by default and the cgroup file for the flag
|
|
|
|
+ * is not created.
|
|
|
|
+ *
|
|
|
|
+ * - blkcg: blk-throttle becomes properly hierarchical.
|
|
|
|
+ *
|
|
|
|
+ * - debug: disallowed on the default hierarchy.
|
|
|
|
+ */
|
|
static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
|
|
static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
|
|
{
|
|
{
|
|
return cgrp->root == &cgrp_dfl_root;
|
|
return cgrp->root == &cgrp_dfl_root;
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
- * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details. This
|
|
|
|
- * function can be called as long as @cgrp is accessible.
|
|
|
|
- */
|
|
|
|
-static inline bool cgroup_sane_behavior(const struct cgroup *cgrp)
|
|
|
|
-{
|
|
|
|
- return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/* no synchronization, the result can only be used as a hint */
|
|
/* no synchronization, the result can only be used as a hint */
|
|
static inline bool cgroup_has_tasks(struct cgroup *cgrp)
|
|
static inline bool cgroup_has_tasks(struct cgroup *cgrp)
|
|
{
|
|
{
|