Skip to contentSkip to conversation

cgroup: replace error handling in cgroup_init() with WARN_ON()s

PATCH In review Tejun Heo 2 participants 6 messages Aug 5, 2015 – Oct 15, 2015

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author maintainer
#0 lore raw

PATCH 1/3 cgroup: replace error handling in cgroup_init() with WARN_ON()s

The init sequence shouldn't fail short of bugs and even when it does it's better to continue with the rest of initialization and we were silently ignoring /proc/cgroups creation failure.

Drop the explicit error handling and wrap sysfs_create_mount_point(), register_filesystem() and proc_create() with WARN_ON()s.

Cc Li Zefan <[email protected]>
Cc Johannes Weiner <[email protected]>
---
 kernel/cgroup.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
kernel/cgroup.c +4 -11
@@ -5014,7 +5014,7 @@ int __init cgroup_init(void)
 {
 	struct cgroup_subsys *ss;
 	unsigned long key;
-	int ssid, err;
+	int ssid;
 
 	BUG_ON(percpu_init_rwsem(&cgroup_threadgroup_rwsem));
 	BUG_ON(cgroup_init_cftypes(NULL, cgroup_dfl_base_files));
@@ -5072,17 +5072,10 @@ int __init cgroup_init(void)
 			ss->bind(init_css_set.subsys[ssid]);
 	}
 
-	err = sysfs_create_mount_point(fs_kobj, "cgroup");
-	if (err)
-		return err;
-
-	err = register_filesystem(&cgroup_fs_type);
-	if (err < 0) {
-		sysfs_remove_mount_point(fs_kobj, "cgroup");
-		return err;
-	}
+	WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup"));
+	WARN_ON(register_filesystem(&cgroup_fs_type));
+	WARN_ON(!proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations));
 
-	proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
 	return 0;
 }
 
author maintainer
#1 lore raw

Re: [PATCH cgroup/for-4.3 2/3] cgroup: drop cgroup__DEVEL__legacy_files_on_dfl

Now that interfaces for the major three controllers - cpu, memory, io
- are shaping up, there's no reason to have an option to force legacy files to show up on the unified hierarchy for testing. Drop it.

Cc Li Zefan <[email protected]>
Cc Johannes Weiner <[email protected]>
---
 Documentation/cgroups/unified-hierarchy.txt |    6 -----
 kernel/cgroup.c                             |   30 +---------------------------
 2 files changed, 2 insertions(+), 34 deletions(-)
Documentation/cgroups/unified-hierarchy.txt +0 -6
@@ -107,12 +107,6 @@ root of unified hierarchy can be bound t
 allows mixing unified hierarchy with the traditional multiple
 hierarchies in a fully backward compatible way.
 
-For development purposes, the following boot parameter makes all
-controllers to appear on the unified hierarchy whether supported or
-not.
-
- cgroup__DEVEL__legacy_files_on_dfl
-
 A controller can be moved across hierarchies only after the controller
 is no longer referenced in its current hierarchy.  Because per-cgroup
 controller states are destroyed asynchronously and controllers may
kernel/cgroup.c +2 -28
@@ -152,12 +152,6 @@ struct cgroup_root cgrp_dfl_root;
  */
 static bool cgrp_dfl_root_visible;
 
-/*
- * Set by the boot param of the same name and makes subsystems with NULL
- * ->dfl_files to use ->legacy_files on the default hierarchy.
- */
-static bool cgroup_legacy_files_on_dfl;
-
 /* some controllers are not supported in the default hierarchy */
 static unsigned long cgrp_dfl_root_inhibit_ss_mask;
 
@@ -3340,17 +3334,8 @@ int cgroup_add_legacy_cftypes(struct cgr
 {
 	struct cftype *cft;
 
-	/*
-	 * If legacy_flies_on_dfl, we want to show the legacy files on the
-	 * dfl hierarchy but iff the target subsystem hasn't been updated
-	 * for the dfl hierarchy yet.
-	 */
-	if (!cgroup_legacy_files_on_dfl ||
-	    ss->dfl_cftypes != ss->legacy_cftypes) {
-		for (cft = cfts; cft && cft->name[0] != '\0'; cft++)
-			cft->flags |= __CFTYPE_NOT_ON_DFL;
-	}
-
+	for (cft = cfts; cft && cft->name[0] != '\0'; cft++)
+		cft->flags |= __CFTYPE_NOT_ON_DFL;
 	return cgroup_add_cftypes(ss, cfts);
 }
 
@@ -5055,9 +5040,6 @@ int __init cgroup_init(void)
 
 		cgrp_dfl_root.subsys_mask |= 1 << ss->id;
 
-		if (cgroup_legacy_files_on_dfl && !ss->dfl_cftypes)
-			ss->dfl_cftypes = ss->legacy_cftypes;
-
 		if (!ss->dfl_cftypes)
 			cgrp_dfl_root_inhibit_ss_mask |= 1 << ss->id;
 
@@ -5474,14 +5456,6 @@ static int __init cgroup_disable(char *s
 }
 __setup("cgroup_disable=", cgroup_disable);
 
-static int __init cgroup_set_legacy_files_on_dfl(char *str)
-{
-	printk("cgroup: using legacy files on the default hierarchy\n");
-	cgroup_legacy_files_on_dfl = true;
-	return 0;
-}
-__setup("cgroup__DEVEL__legacy_files_on_dfl", cgroup_set_legacy_files_on_dfl);
-
 /**
  * css_tryget_online_from_dir - get corresponding css from a cgroup dentry
  * @dentry: directory dentry of interest
author maintainer
#2 lore raw

PATCH 3/3 cgroup: replace __DEVEL__sane_behavior with cgroup2 fs type

With major controllers - cpu, memory and io - shaping up for the unified hierarchy, cgroup2 is about ready to be, gradually, released into the wild. Replace __DEVEL__sane_behavior flag which was used to select the unified hierarchy with a separate filesystem type "cgroup2" so that unified hierarchy can be mounted as follows.

mount -t cgroup2 none $MOUNT_POINT

Cc Li Zefan <[email protected]>
Cc Johannes Weiner <[email protected]>
---
 Documentation/cgroups/unified-hierarchy.txt |    6 +--
 include/linux/cgroup-defs.h                 |    1 
 kernel/cgroup.c                             |   43 +++++++++++++---------------
 3 files changed, 22 insertions(+), 28 deletions(-)
Documentation/cgroups/unified-hierarchy.txt +2 -4
@@ -94,11 +94,9 @@ the process.
 
 2-1. Mounting
 
-Currently, unified hierarchy can be mounted with the following mount
-command.  Note that this is still under development and scheduled to
-change soon.
+Unified hierarchy can be mounted with the following mount command.
 
- mount -t cgroup -o __DEVEL__sane_behavior cgroup $MOUNT_POINT
+ mount -t cgroup2 none $MOUNT_POINT
 
 All controllers which support the unified hierarchy and are not bound
 to other hierarchies are automatically bound to unified hierarchy and
include/linux/cgroup-defs.h +0 -1
@@ -66,7 +66,6 @@ enum {
 
 /* cgroup_root->flags */
 enum {
-	CGRP_ROOT_SANE_BEHAVIOR	= (1 << 0), /* __DEVEL__sane_behavior specified */
 	CGRP_ROOT_NOPREFIX	= (1 << 1), /* mounted subsystems have no named prefix */
 	CGRP_ROOT_XATTR		= (1 << 2), /* supports extended attributes */
 };
kernel/cgroup.c +20 -23

91 lines not on this page · raw message

#5 lore raw
In reply to Tejun Heo
Quoted 10 lines · Tejun Heo

The init sequence shouldn't fail short of bugs and even when it does it's better to continue with the rest of initialization and we were silently ignoring /proc/cgroups creation failure.

Drop the explicit error handling and wrap sysfs_create_mount_point(), register_filesystem() and proc_create() with WARN_ON()s.

Cc Li Zefan <[email protected]>
Cc Johannes Weiner <[email protected]>

acked

#3 lore raw

Re: [PATCH cgroup/for-4.3 3/3] cgroup: replace __DEVEL__sane_behavior with cgroup2 fs type

In reply to Tejun Heo
Quoted 11 lines · Tejun Heo

With major controllers - cpu, memory and io - shaping up for the unified hierarchy, cgroup2 is about ready to be, gradually, released into the wild. Replace __DEVEL__sane_behavior flag which was used to select the unified hierarchy with a separate filesystem type "cgroup2" so that unified hierarchy can be mounted as follows.

mount -t cgroup2 none $MOUNT_POINT

Cc Li Zefan <[email protected]>
Cc Johannes Weiner <[email protected]>

acked

author maintainer
#4 lore raw

Re: [PATCH cgroup/for-4.3 2/3] cgroup: drop cgroup__DEVEL__legacy_files_on_dfl

In reply to Tejun Heo
Quoted 7 lines · Tejun Heo

Now that interfaces for the major three controllers - cpu, memory, io
- are shaping up, there's no reason to have an option to force legacy files to show up on the unified hierarchy for testing. Drop it.

Cc Li Zefan <[email protected]>
Cc Johannes Weiner <[email protected]>

Applying 1-2 to cgroup/for-4.4. Will apply the third one once the cpu controller discussion reaches some resolution.

Thanks.

Signature · 1 line
tejun