diff options
-rw-r--r-- | kernel/sched.c | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index d1e6663d3ab0..cc9cd5b710a6 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -7124,25 +7124,25 @@ unsigned long sched_group_shares(struct task_group *tg) | |||
7124 | #ifdef CONFIG_FAIR_CGROUP_SCHED | 7124 | #ifdef CONFIG_FAIR_CGROUP_SCHED |
7125 | 7125 | ||
7126 | /* return corresponding task_group object of a cgroup */ | 7126 | /* return corresponding task_group object of a cgroup */ |
7127 | static inline struct task_group *cgroup_tg(struct cgroup *cont) | 7127 | static inline struct task_group *cgroup_tg(struct cgroup *cgrp) |
7128 | { | 7128 | { |
7129 | return container_of(cgroup_subsys_state(cont, cpu_cgroup_subsys_id), | 7129 | return container_of(cgroup_subsys_state(cgrp, cpu_cgroup_subsys_id), |
7130 | struct task_group, css); | 7130 | struct task_group, css); |
7131 | } | 7131 | } |
7132 | 7132 | ||
7133 | static struct cgroup_subsys_state * | 7133 | static struct cgroup_subsys_state * |
7134 | cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) | 7134 | cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp) |
7135 | { | 7135 | { |
7136 | struct task_group *tg; | 7136 | struct task_group *tg; |
7137 | 7137 | ||
7138 | if (!cont->parent) { | 7138 | if (!cgrp->parent) { |
7139 | /* This is early initialization for the top cgroup */ | 7139 | /* This is early initialization for the top cgroup */ |
7140 | init_task_group.css.cgroup = cont; | 7140 | init_task_group.css.cgroup = cgrp; |
7141 | return &init_task_group.css; | 7141 | return &init_task_group.css; |
7142 | } | 7142 | } |
7143 | 7143 | ||
7144 | /* we support only 1-level deep hierarchical scheduler atm */ | 7144 | /* we support only 1-level deep hierarchical scheduler atm */ |
7145 | if (cont->parent->parent) | 7145 | if (cgrp->parent->parent) |
7146 | return ERR_PTR(-EINVAL); | 7146 | return ERR_PTR(-EINVAL); |
7147 | 7147 | ||
7148 | tg = sched_create_group(); | 7148 | tg = sched_create_group(); |
@@ -7150,21 +7150,21 @@ cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) | |||
7150 | return ERR_PTR(-ENOMEM); | 7150 | return ERR_PTR(-ENOMEM); |
7151 | 7151 | ||
7152 | /* Bind the cgroup to task_group object we just created */ | 7152 | /* Bind the cgroup to task_group object we just created */ |
7153 | tg->css.cgroup = cont; | 7153 | tg->css.cgroup = cgrp; |
7154 | 7154 | ||
7155 | return &tg->css; | 7155 | return &tg->css; |
7156 | } | 7156 | } |
7157 | 7157 | ||
7158 | static void cpu_cgroup_destroy(struct cgroup_subsys *ss, | 7158 | static void cpu_cgroup_destroy(struct cgroup_subsys *ss, |
7159 | struct cgroup *cont) | 7159 | struct cgroup *cgrp) |
7160 | { | 7160 | { |
7161 | struct task_group *tg = cgroup_tg(cont); | 7161 | struct task_group *tg = cgroup_tg(cgrp); |
7162 | 7162 | ||
7163 | sched_destroy_group(tg); | 7163 | sched_destroy_group(tg); |
7164 | } | 7164 | } |
7165 | 7165 | ||
7166 | static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, | 7166 | static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, |
7167 | struct cgroup *cont, struct task_struct *tsk) | 7167 | struct cgroup *cgrp, struct task_struct *tsk) |
7168 | { | 7168 | { |
7169 | /* We don't support RT-tasks being in separate groups */ | 7169 | /* We don't support RT-tasks being in separate groups */ |
7170 | if (tsk->sched_class != &fair_sched_class) | 7170 | if (tsk->sched_class != &fair_sched_class) |
@@ -7174,38 +7174,21 @@ static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, | |||
7174 | } | 7174 | } |
7175 | 7175 | ||
7176 | static void | 7176 | static void |
7177 | cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cont, | 7177 | cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
7178 | struct cgroup *old_cont, struct task_struct *tsk) | 7178 | struct cgroup *old_cont, struct task_struct *tsk) |
7179 | { | 7179 | { |
7180 | sched_move_task(tsk); | 7180 | sched_move_task(tsk); |
7181 | } | 7181 | } |
7182 | 7182 | ||
7183 | static ssize_t cpu_shares_write(struct cgroup *cont, struct cftype *cftype, | 7183 | static int cpu_shares_write_uint(struct cgroup *cgrp, struct cftype *cftype, |
7184 | struct file *file, const char __user *userbuf, | 7184 | u64 shareval) |
7185 | size_t nbytes, loff_t *ppos) | ||
7186 | { | 7185 | { |
7187 | unsigned long shareval; | 7186 | return sched_group_set_shares(cgroup_tg(cgrp), shareval); |
7188 | struct task_group *tg = cgroup_tg(cont); | ||
7189 | char buffer[2*sizeof(unsigned long) + 1]; | ||
7190 | int rc; | ||
7191 | |||
7192 | if (nbytes > 2*sizeof(unsigned long)) /* safety check */ | ||
7193 | return -E2BIG; | ||
7194 | |||
7195 | if (copy_from_user(buffer, userbuf, nbytes)) | ||
7196 | return -EFAULT; | ||
7197 | |||
7198 | buffer[nbytes] = 0; /* nul-terminate */ | ||
7199 | shareval = simple_strtoul(buffer, NULL, 10); | ||
7200 | |||
7201 | rc = sched_group_set_shares(tg, shareval); | ||
7202 | |||
7203 | return (rc < 0 ? rc : nbytes); | ||
7204 | } | 7187 | } |
7205 | 7188 | ||
7206 | static u64 cpu_shares_read_uint(struct cgroup *cont, struct cftype *cft) | 7189 | static u64 cpu_shares_read_uint(struct cgroup *cgrp, struct cftype *cft) |
7207 | { | 7190 | { |
7208 | struct task_group *tg = cgroup_tg(cont); | 7191 | struct task_group *tg = cgroup_tg(cgrp); |
7209 | 7192 | ||
7210 | return (u64) tg->shares; | 7193 | return (u64) tg->shares; |
7211 | } | 7194 | } |
@@ -7213,7 +7196,7 @@ static u64 cpu_shares_read_uint(struct cgroup *cont, struct cftype *cft) | |||
7213 | static struct cftype cpu_shares = { | 7196 | static struct cftype cpu_shares = { |
7214 | .name = "shares", | 7197 | .name = "shares", |
7215 | .read_uint = cpu_shares_read_uint, | 7198 | .read_uint = cpu_shares_read_uint, |
7216 | .write = cpu_shares_write, | 7199 | .write_uint = cpu_shares_write_uint, |
7217 | }; | 7200 | }; |
7218 | 7201 | ||
7219 | static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont) | 7202 | static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont) |