LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] CFS CGroup: Code cleanup
@ 2007-10-24 2:32 Paul Menage
2007-10-24 4:45 ` Srivatsa Vaddagiri
0 siblings, 1 reply; 7+ messages in thread
From: Paul Menage @ 2007-10-24 2:32 UTC (permalink / raw)
To: Andrew Morton, Ingo Molnar, Srivatsa Vaddagiri; +Cc: containers, linux-kernel
Clean up some CFS CGroup code
- replace "cont" with "cgrp" in a few places in the CFS cgroup code,
- use write_uint rather than write for cpu.shares write function
Signed-off-by: Paul Menage <menage@google.com>
---
This is a resend of yesterday's mail with the same subject; the final hunk was missing from yesterday's patch. The second patch in the series was unaffected by this.
kernel/sched.c | 53 ++++++++++++++++++-----------------------------------
1 file changed, 18 insertions(+), 35 deletions(-)
Index: container-2.6.23-mm1/kernel/sched.c
===================================================================
--- container-2.6.23-mm1.orig/kernel/sched.c
+++ container-2.6.23-mm1/kernel/sched.c
@@ -6936,25 +6936,25 @@ unsigned long sched_group_shares(struct
#ifdef CONFIG_FAIR_CGROUP_SCHED
/* return corresponding task_group object of a cgroup */
-static inline struct task_group *cgroup_tg(struct cgroup *cont)
+static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
{
- return container_of(cgroup_subsys_state(cont, cpu_cgroup_subsys_id),
- struct task_group, css);
+ return container_of(cgroup_subsys_state(cgrp, cpu_cgroup_subsys_id),
+ struct task_group, css);
}
static struct cgroup_subsys_state *
-cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
+cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp)
{
struct task_group *tg;
- if (!cont->parent) {
+ if (!cgrp->parent) {
/* This is early initialization for the top cgroup */
- init_task_group.css.cgroup = cont;
+ init_task_group.css.cgroup = cgrp;
return &init_task_group.css;
}
/* we support only 1-level deep hierarchical scheduler atm */
- if (cont->parent->parent)
+ if (cgrp->parent->parent)
return ERR_PTR(-EINVAL);
tg = sched_create_group();
@@ -6962,21 +6962,21 @@ cpu_cgroup_create(struct cgroup_subsys *
return ERR_PTR(-ENOMEM);
/* Bind the cgroup to task_group object we just created */
- tg->css.cgroup = cont;
+ tg->css.cgroup = cgrp;
return &tg->css;
}
static void cpu_cgroup_destroy(struct cgroup_subsys *ss,
- struct cgroup *cont)
+ struct cgroup *cgrp)
{
- struct task_group *tg = cgroup_tg(cont);
+ struct task_group *tg = cgroup_tg(cgrp);
sched_destroy_group(tg);
}
static int cpu_cgroup_can_attach(struct cgroup_subsys *ss,
- struct cgroup *cont, struct task_struct *tsk)
+ struct cgroup *cgrp, struct task_struct *tsk)
{
/* We don't support RT-tasks being in separate groups */
if (tsk->sched_class != &fair_sched_class)
@@ -6986,38 +6986,21 @@ static int cpu_cgroup_can_attach(struct
}
static void
-cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cont,
+cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
struct cgroup *old_cont, struct task_struct *tsk)
{
sched_move_task(tsk);
}
-static ssize_t cpu_shares_write(struct cgroup *cont, struct cftype *cftype,
- struct file *file, const char __user *userbuf,
- size_t nbytes, loff_t *ppos)
+static int cpu_shares_write_uint(struct cgroup *cgrp, struct cftype *cftype,
+ u64 shareval)
{
- unsigned long shareval;
- struct task_group *tg = cgroup_tg(cont);
- char buffer[2*sizeof(unsigned long) + 1];
- int rc;
-
- if (nbytes > 2*sizeof(unsigned long)) /* safety check */
- return -E2BIG;
-
- if (copy_from_user(buffer, userbuf, nbytes))
- return -EFAULT;
-
- buffer[nbytes] = 0; /* nul-terminate */
- shareval = simple_strtoul(buffer, NULL, 10);
-
- rc = sched_group_set_shares(tg, shareval);
-
- return (rc < 0 ? rc : nbytes);
+ return sched_group_set_shares(cgroup_tg(cgrp), shareval);
}
-static u64 cpu_shares_read_uint(struct cgroup *cont, struct cftype *cft)
+static u64 cpu_shares_read_uint(struct cgroup *cgrp, struct cftype *cft)
{
- struct task_group *tg = cgroup_tg(cont);
+ struct task_group *tg = cgroup_tg(cgrp);
return (u64) tg->shares;
}
@@ -7025,7 +7008,7 @@ static u64 cpu_shares_read_uint(struct c
static struct cftype cpu_shares = {
.name = "shares",
.read_uint = cpu_shares_read_uint,
- .write = cpu_shares_write,
+ .write_uint = cpu_shares_write_uint,
};
static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] CFS CGroup: Code cleanup
2007-10-24 2:32 [PATCH 1/2] CFS CGroup: Code cleanup Paul Menage
@ 2007-10-24 4:45 ` Srivatsa Vaddagiri
2007-10-24 6:50 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Srivatsa Vaddagiri @ 2007-10-24 4:45 UTC (permalink / raw)
To: Paul Menage
Cc: Andrew Morton, Ingo Molnar, Srivatsa Vaddagiri, containers, linux-kernel
On Tue, Oct 23, 2007 at 07:32:27PM -0700, Paul Menage wrote:
> Clean up some CFS CGroup code
>
> - replace "cont" with "cgrp" in a few places in the CFS cgroup code,
> - use write_uint rather than write for cpu.shares write function
>
> Signed-off-by: Paul Menage <menage@google.com>
Acked-by : Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
--
Regards,
vatsa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] CFS CGroup: Code cleanup
2007-10-24 4:45 ` Srivatsa Vaddagiri
@ 2007-10-24 6:50 ` Ingo Molnar
0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2007-10-24 6:50 UTC (permalink / raw)
To: Srivatsa Vaddagiri
Cc: Paul Menage, Andrew Morton, Srivatsa Vaddagiri, containers, linux-kernel
* Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> wrote:
> On Tue, Oct 23, 2007 at 07:32:27PM -0700, Paul Menage wrote:
> > Clean up some CFS CGroup code
> >
> > - replace "cont" with "cgrp" in a few places in the CFS cgroup code,
> > - use write_uint rather than write for cpu.shares write function
> >
> > Signed-off-by: Paul Menage <menage@google.com>
>
> Acked-by : Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
thanks, applied.
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] CFS CGroup: Code cleanup
2007-10-23 6:16 ` Paul Menage
@ 2007-10-23 7:42 ` Paul Menage
0 siblings, 0 replies; 7+ messages in thread
From: Paul Menage @ 2007-10-23 7:42 UTC (permalink / raw)
To: vatsa
Cc: Andrew Morton, Ingo Molnar, Srivatsa Vaddagiri, containers, linux-kernel
On 10/22/07, Paul Menage <menage@google.com> wrote:
> On 10/22/07, Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> wrote:
> >
> > Minor nit: From pov of making this patch series git bisect safe, shouldn't we
> > be registering a write_uint() handler in this patch as well?
> >
>
> Yes, we should. Sigh. I originally had the cleanup and the new
> reporting interface in the same patch, and decided to split them apart
> into a cleanup patch and a new feature patch, but clearly goofed. I'll
> resend tomorrow with the write_uint registration in the right place.
OK, this wasn't a patch goof - the original patch in my tree does have
the addition of write_uint in the cftype definition. I guess the last
hunk got lost as I transferred it to the email.
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] CFS CGroup: Code cleanup
2007-10-23 2:46 ` Srivatsa Vaddagiri
@ 2007-10-23 6:16 ` Paul Menage
2007-10-23 7:42 ` Paul Menage
0 siblings, 1 reply; 7+ messages in thread
From: Paul Menage @ 2007-10-23 6:16 UTC (permalink / raw)
To: vatsa
Cc: Andrew Morton, Ingo Molnar, Srivatsa Vaddagiri, containers, linux-kernel
On 10/22/07, Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> wrote:
>
> Minor nit: From pov of making this patch series git bisect safe, shouldn't we
> be registering a write_uint() handler in this patch as well?
>
Yes, we should. Sigh. I originally had the cleanup and the new
reporting interface in the same patch, and decided to split them apart
into a cleanup patch and a new feature patch, but clearly goofed. I'll
resend tomorrow with the write_uint registration in the right place.
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] CFS CGroup: Code cleanup
2007-10-23 0:49 Paul Menage
@ 2007-10-23 2:46 ` Srivatsa Vaddagiri
2007-10-23 6:16 ` Paul Menage
0 siblings, 1 reply; 7+ messages in thread
From: Srivatsa Vaddagiri @ 2007-10-23 2:46 UTC (permalink / raw)
To: Paul Menage
Cc: Andrew Morton, Ingo Molnar, Srivatsa Vaddagiri, containers, linux-kernel
On Mon, Oct 22, 2007 at 05:49:20PM -0700, Paul Menage wrote:
> Clean up some CFS CGroup code
>
> - replace "cont" with "cgrp" in a few places in the CFS cgroup code,
This change looks good to me. Thanks for doing it.
> - use write_uint rather than write for cpu.shares write function
Minor nit: From pov of making this patch series git bisect safe, shouldn't we
be registering a write_uint() handler in this patch as well?
--
Regards,
vatsa
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] CFS CGroup: Code cleanup
@ 2007-10-23 0:49 Paul Menage
2007-10-23 2:46 ` Srivatsa Vaddagiri
0 siblings, 1 reply; 7+ messages in thread
From: Paul Menage @ 2007-10-23 0:49 UTC (permalink / raw)
To: Andrew Morton, Ingo Molnar, Srivatsa Vaddagiri; +Cc: containers, linux-kernel
Clean up some CFS CGroup code
- replace "cont" with "cgrp" in a few places in the CFS cgroup code,
- use write_uint rather than write for cpu.shares write function
Signed-off-by: Paul Menage <menage@google.com>
---
kernel/sched.c | 51 +++++++++++++++++----------------------------------
1 file changed, 17 insertions(+), 34 deletions(-)
Index: container-2.6.23-mm1/kernel/sched.c
===================================================================
--- container-2.6.23-mm1.orig/kernel/sched.c
+++ container-2.6.23-mm1/kernel/sched.c
@@ -6936,25 +6936,25 @@ unsigned long sched_group_shares(struct
#ifdef CONFIG_FAIR_CGROUP_SCHED
/* return corresponding task_group object of a cgroup */
-static inline struct task_group *cgroup_tg(struct cgroup *cont)
+static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
{
- return container_of(cgroup_subsys_state(cont, cpu_cgroup_subsys_id),
- struct task_group, css);
+ return container_of(cgroup_subsys_state(cgrp, cpu_cgroup_subsys_id),
+ struct task_group, css);
}
static struct cgroup_subsys_state *
-cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
+cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp)
{
struct task_group *tg;
- if (!cont->parent) {
+ if (!cgrp->parent) {
/* This is early initialization for the top cgroup */
- init_task_group.css.cgroup = cont;
+ init_task_group.css.cgroup = cgrp;
return &init_task_group.css;
}
/* we support only 1-level deep hierarchical scheduler atm */
- if (cont->parent->parent)
+ if (cgrp->parent->parent)
return ERR_PTR(-EINVAL);
tg = sched_create_group();
@@ -6962,21 +6962,21 @@ cpu_cgroup_create(struct cgroup_subsys *
return ERR_PTR(-ENOMEM);
/* Bind the cgroup to task_group object we just created */
- tg->css.cgroup = cont;
+ tg->css.cgroup = cgrp;
return &tg->css;
}
static void cpu_cgroup_destroy(struct cgroup_subsys *ss,
- struct cgroup *cont)
+ struct cgroup *cgrp)
{
- struct task_group *tg = cgroup_tg(cont);
+ struct task_group *tg = cgroup_tg(cgrp);
sched_destroy_group(tg);
}
static int cpu_cgroup_can_attach(struct cgroup_subsys *ss,
- struct cgroup *cont, struct task_struct *tsk)
+ struct cgroup *cgrp, struct task_struct *tsk)
{
/* We don't support RT-tasks being in separate groups */
if (tsk->sched_class != &fair_sched_class)
@@ -6986,38 +6986,21 @@ static int cpu_cgroup_can_attach(struct
}
static void
-cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cont,
+cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
struct cgroup *old_cont, struct task_struct *tsk)
{
sched_move_task(tsk);
}
-static ssize_t cpu_shares_write(struct cgroup *cont, struct cftype *cftype,
- struct file *file, const char __user *userbuf,
- size_t nbytes, loff_t *ppos)
+static int cpu_shares_write_uint(struct cgroup *cgrp, struct cftype *cftype,
+ u64 shareval)
{
- unsigned long shareval;
- struct task_group *tg = cgroup_tg(cont);
- char buffer[2*sizeof(unsigned long) + 1];
- int rc;
-
- if (nbytes > 2*sizeof(unsigned long)) /* safety check */
- return -E2BIG;
-
- if (copy_from_user(buffer, userbuf, nbytes))
- return -EFAULT;
-
- buffer[nbytes] = 0; /* nul-terminate */
- shareval = simple_strtoul(buffer, NULL, 10);
-
- rc = sched_group_set_shares(tg, shareval);
-
- return (rc < 0 ? rc : nbytes);
+ return sched_group_set_shares(cgroup_tg(cgrp), shareval);
}
-static u64 cpu_shares_read_uint(struct cgroup *cont, struct cftype *cft)
+static u64 cpu_shares_read_uint(struct cgroup *cgrp, struct cftype *cft)
{
- struct task_group *tg = cgroup_tg(cont);
+ struct task_group *tg = cgroup_tg(cgrp);
return (u64) tg->shares;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-10-24 6:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-24 2:32 [PATCH 1/2] CFS CGroup: Code cleanup Paul Menage
2007-10-24 4:45 ` Srivatsa Vaddagiri
2007-10-24 6:50 ` Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2007-10-23 0:49 Paul Menage
2007-10-23 2:46 ` Srivatsa Vaddagiri
2007-10-23 6:16 ` Paul Menage
2007-10-23 7:42 ` Paul Menage
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).