Skip to contentSkip to conversation

cgroup: fix boot option parsing

PATCH In review Li Zefan 2 participants 2 messages Mar 17, 2008

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 cgroup: fix boot option parsing

When boot with 'cgroup_disable=cpuacct', it turns out subsystem 'cpu' is disabled.

When Balbir posted the patch to add cgroup boot option support, Paul M noticed this problem, but the patch was accepted without fixing it.

---
 kernel/cgroup.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
kernel/cgroup.c +6 -9
index e8e8ec4..54c28ea 100644
@@ -3062,25 +3062,22 @@ static void cgroup_release_agent(struct work_struct *work)
 static int __init cgroup_disable(char *str)
 {
 	int i;
+	char *token;
+
+	while ((token = strsep(&str, ",")) != NULL) {
+		if (!*token)
+			continue;
 
-	while (*str) {
 		for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
 			struct cgroup_subsys *ss = subsys[i];
 
-			if (!strncmp(str, ss->name, strlen(ss->name))) {
+			if (!strcmp(token, ss->name)) {
 				ss->disabled = 1;
 				printk(KERN_INFO "Disabling %s control group"
 					" subsystem\n", ss->name);
 				break;
 			}
 		}
-		/*
-		 * Find the next option if any
-		 */
-		while (*str && (*str != ','))
-			str++;
-		if (*str == ',')
-			str++;
 	}
 	return 1;
 }
Signature · 1 line
1.5.4.rc3
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Li Zefan

When boot with 'cgroup_disable=cpuacct', it turns out subsystem
'cpu' is disabled.

When Balbir posted the patch to add cgroup boot option support, Paul M noticed this problem, but the patch was accepted without fixing it.

Quoted 43 lines

---

  kernel/cgroup.c |   15 ++++++---------
  1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index e8e8ec4..54c28ea 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3062,25 +3062,22 @@ static void cgroup_release_agent(struct work_struct *work)
static int __init cgroup_disable(char *str)

  {
        int i;

+ char *token;
+
+ while ((token = strsep(&str, ",")) != NULL) {
+ if (!*token)
+ continue;

 -       while (*str) {
                for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
                        struct cgroup_subsys *ss = subsys[i];

- if (!strncmp(str, ss->name, strlen(ss->name))) {

 +                       if (!strcmp(token, ss->name)) {
                                ss->disabled = 1;
                                printk(KERN_INFO "Disabling %s control group"
                                        " subsystem\n", ss->name);
                                break;
                        }
                }
 -               /*
 -                * Find the next option if any
 -                */
 -               while (*str && (*str != ','))
 -                       str++;
 -               if (*str == ',')
 -                       str++;
        }
        return 1;

}
--
1.5.4.rc3