[PATCH] Add hierarchical accounting to cpu accounting controller - Kernel

This is a discussion on [PATCH] Add hierarchical accounting to cpu accounting controller - Kernel ; > +The CPU accounting controller is used to group tasks using cgroups and > +account the CPU usage of these group of tasks. this group or these groups? .... > --- a/kernel/sched.c > +++ b/kernel/sched.c > @@ -9236,6 +9236,7 @@ ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 28 of 28

Thread: [PATCH] Add hierarchical accounting to cpu accounting controller

  1. Re: [PATCH] Add hierarchical accounting to cpu accounting controller

    > +The CPU accounting controller is used to group tasks using cgroups and
    > +account the CPU usage of these group of tasks.


    this group or these groups?

    ....

    > --- a/kernel/sched.c
    > +++ b/kernel/sched.c
    > @@ -9236,6 +9236,7 @@ struct cpuacct {
    > struct cgroup_subsys_state css;
    > /* cpuusage holds pointer to a u64-type object on every cpu */
    > u64 *cpuusage;
    > + struct cpuacct *parent;
    > };
    >


    Maybe the comment needs to be updated?

    /* track cpu usage of a group of tasks */
    struct cpuacct {
    ...
    };

    ->

    /* track cpu usage of a group of tasks and its child groups */
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] Add hierarchical accounting to cpu accounting controller

    Bharata B Rao wrote:
    > On Fri, Oct 31, 2008 at 09:40:41AM +0900, KAMEZAWA Hiroyuki wrote:
    >> On Thu, 30 Oct 2008 22:46:22 +0530
    >> Dhaval Giani wrote:
    >>> I disagree. The child is a part of the parent's hierarchy, and therefore
    >>> its usage should reflect in the parent's usage.
    >>>

    >> In my point of view, there is no big difference. It's just whether we need a tool
    >> in userland or not. If there is no performance impact, I have no objections.
    >>
    >> One request from me is add Documentation/controllers/cpuacct.txt or some to explain
    >> "what we see".

    >
    > I am not sure which version (mine or Li Zefan's) Paul prefers. I am
    > resending my patch anyway with documentation and performance numbers
    > included. I don't see any significant improvement or degradation in
    > hackbench, lmbench and volanomark numbers with this patch.
    >
    > Regards,
    > Bharata.
    >
    > Add hierarchical accounting to cpu accounting controller and cpuacct
    > documentation.
    >
    > Currently, while charging the task's cputime to its accounting group,
    > the accounting group hierarchy isn't updated. This patch charges the cputime
    > of a task to its accounting group and all its parent accounting groups.
    >
    > Reported-by: Srivatsa Vaddagiri
    > Signed-off-by: Bharata B Rao
    > CC: Peter Zijlstra
    > CC: Ingo Molnar
    > CC: Srivatsa Vaddagiri
    > Reviewed-by: Paul Menage


    Looks good and straight forward.

    Acked-by: Balbir Singh

    --
    Balbir
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. Re: [PATCH] Add hierarchical accounting to cpu accounting controller

    On Wed, Nov 05, 2008 at 08:59:11AM +0530, Srivatsa Vaddagiri wrote:
    > On Wed, Nov 05, 2008 at 08:54:40AM +0530, Bharata B Rao wrote:
    > > I will resend the patch with other corrections you mentioned only if
    > > Paul/Ingo want this patch to go in.

    >
    > I strongly recommend his patch to go in, as otherwise group accounting
    > will be broken where control hierarchy is not same as accounting
    > hierarchy. In that sense, I would treat this patch as more of a bug fix
    > than anything else.
    >


    Wondering what the status of this patch is?

    thanks,
    --
    regards,
    Dhaval
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. Re: [PATCH] Add hierarchical accounting to cpu accounting controller

    On Tue, 2008-11-04 at 18:19 +0530, Bharata B Rao wrote:

    > Add hierarchical accounting to cpu accounting controller and cpuacct
    > documentation.
    >
    > Currently, while charging the task's cputime to its accounting group,
    > the accounting group hierarchy isn't updated. This patch charges the cputime
    > of a task to its accounting group and all its parent accounting groups.
    >
    > Reported-by: Srivatsa Vaddagiri
    > Signed-off-by: Bharata B Rao
    > CC: Peter Zijlstra
    > CC: Ingo Molnar
    > CC: Srivatsa Vaddagiri
    > Reviewed-by: Paul Menage


    Seems sane and simple enough.

    Acked-by: Peter Zijlstra

    Ingo?

    > ---
    > Documentation/controllers/cpuacct.txt | 32 ++++++++++++++++++++++++++++++++
    > kernel/sched.c | 10 ++++++++--
    > 2 files changed, 40 insertions(+), 2 deletions(-)
    >
    > --- /dev/null
    > +++ b/Documentation/controllers/cpuacct.txt
    > @@ -0,0 +1,32 @@
    > +CPU Accounting Controller
    > +-------------------------
    > +
    > +The CPU accounting controller is used to group tasks using cgroups and
    > +account the CPU usage of these group of tasks.
    > +
    > +The CPU accounting controller supports multi-hierarchy groups. An accounting
    > +group accumulates the CPU usage of all of it's child groups and
    > +the tasks directly present in it's group.
    > +
    > +Accounting groups can be created by first mounting the cgroup filesystem.
    > +
    > +# mkdir /cgroups
    > +# mount -t cgroup -ocpuacct none /cgroups
    > +
    > +With the above step, the initial or the parent accounting group
    > +becomes visible at /cgroups. At bootup, this group comprises of all the
    > +tasks in the system. /cgroups/tasks lists the tasks in this cgroup.
    > +/cgroups/cpuacct.usage gives the CPU time (in nanoseconds) obtained by
    > +this group which is essentially the CPU time obtained by all the tasks
    > +in the system.
    > +
    > +New accounting groups can be created under the parent group /cgroups.
    > +
    > +# cd /cgroups
    > +# mkdir g1
    > +# echo $$ > g1
    > +
    > +The above steps create a new group g1 and move the current shell
    > +process (bash) into it. CPU time consumed by this bash and it's children
    > +can be obtained from g1/cpuacct.usage and the same gets accumulated in
    > +/cgroups/cpuacct.usage also.
    > --- a/kernel/sched.c
    > +++ b/kernel/sched.c
    > @@ -9236,6 +9236,7 @@ struct cpuacct {
    > struct cgroup_subsys_state css;
    > /* cpuusage holds pointer to a u64-type object on every cpu */
    > u64 *cpuusage;
    > + struct cpuacct *parent;
    > };
    >
    > struct cgroup_subsys cpuacct_subsys;
    > @@ -9269,6 +9270,9 @@ static struct cgroup_subsys_state *cpuac
    > return ERR_PTR(-ENOMEM);
    > }
    >
    > + if (cgrp->parent)
    > + ca->parent = cgroup_ca(cgrp->parent);
    > +
    > return &ca->css;
    > }
    >
    > @@ -9348,14 +9352,16 @@ static int cpuacct_populate(struct cgrou
    > static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
    > {
    > struct cpuacct *ca;
    > + int cpu;
    >
    > if (!cpuacct_subsys.active)
    > return;
    >
    > + cpu = task_cpu(tsk);
    > ca = task_ca(tsk);
    > - if (ca) {
    > - u64 *cpuusage = percpu_ptr(ca->cpuusage, task_cpu(tsk));
    >
    > + for (; ca; ca = ca->parent) {
    > + u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);
    > *cpuusage += cputime;
    > }
    > }



    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. Re: [PATCH] Add hierarchical accounting to cpu accounting controller


    * Bharata B Rao wrote:

    > I will resend the patch with other corrections you mentioned only if
    > Paul/Ingo want this patch to go in.


    yes, please resend the fixed version.

    Ingo
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. Re: [PATCH] Add hierarchical accounting to cpu accounting controller

    Peter Zijlstra wrote:
    > On Tue, 2008-11-04 at 18:19 +0530, Bharata B Rao wrote:
    >
    >> Add hierarchical accounting to cpu accounting controller and cpuacct
    >> documentation.
    >>
    >> Currently, while charging the task's cputime to its accounting group,
    >> the accounting group hierarchy isn't updated. This patch charges the cputime
    >> of a task to its accounting group and all its parent accounting groups.
    >>
    >> Reported-by: Srivatsa Vaddagiri
    >> Signed-off-by: Bharata B Rao
    >> CC: Peter Zijlstra
    >> CC: Ingo Molnar
    >> CC: Srivatsa Vaddagiri
    >> Reviewed-by: Paul Menage

    >
    > Seems sane and simple enough.
    >
    > Acked-by: Peter Zijlstra


    Just in case it was missed

    Acked-by: Balbir Singh

    --
    Balbir
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. Re: [PATCH] Add hierarchical accounting to cpu accounting controller

    On Mon, Nov 10, 2008 at 02:09:37PM +0100, Ingo Molnar wrote:
    >
    > * Bharata B Rao wrote:
    >
    > > I will resend the patch with other corrections you mentioned only if
    > > Paul/Ingo want this patch to go in.

    >
    > yes, please resend the fixed version.


    Here it is:

    Add hierarchical accounting to cpu accounting controller and include
    cpuacct documentation.

    Currently, while charging the task's cputime to its accounting group,
    the accounting group hierarchy isn't updated. This patch charges the cputime
    of a task to its accounting group and all its parent accounting groups.

    Reported-by: Srivatsa Vaddagiri
    Signed-off-by: Bharata B Rao
    CC: Ingo Molnar
    CC: Srivatsa Vaddagiri
    Reviewed-by: Paul Menage
    Acked-by: Balbir Singh
    Acked-by: Peter Zijlstra
    ---
    Documentation/controllers/cpuacct.txt | 32 ++++++++++++++++++++++++++++++++
    kernel/sched.c | 12 +++++++++---
    2 files changed, 41 insertions(+), 3 deletions(-)

    --- /dev/null
    +++ b/Documentation/controllers/cpuacct.txt
    @@ -0,0 +1,32 @@
    +CPU Accounting Controller
    +-------------------------
    +
    +The CPU accounting controller is used to group tasks using cgroups and
    +account the CPU usage of these groups of tasks.
    +
    +The CPU accounting controller supports multi-hierarchy groups. An accounting
    +group accumulates the CPU usage of all of its child groups and the tasks
    +directly present in its group.
    +
    +Accounting groups can be created by first mounting the cgroup filesystem.
    +
    +# mkdir /cgroups
    +# mount -t cgroup -ocpuacct none /cgroups
    +
    +With the above step, the initial or the parent accounting group
    +becomes visible at /cgroups. At bootup, this group includes all the
    +tasks in the system. /cgroups/tasks lists the tasks in this cgroup.
    +/cgroups/cpuacct.usage gives the CPU time (in nanoseconds) obtained by
    +this group which is essentially the CPU time obtained by all the tasks
    +in the system.
    +
    +New accounting groups can be created under the parent group /cgroups.
    +
    +# cd /cgroups
    +# mkdir g1
    +# echo $$ > g1
    +
    +The above steps create a new group g1 and move the current shell
    +process (bash) into it. CPU time consumed by this bash and its children
    +can be obtained from g1/cpuacct.usage and the same is accumulated in
    +/cgroups/cpuacct.usage also.
    --- a/kernel/sched.c
    +++ b/kernel/sched.c
    @@ -9231,11 +9231,12 @@ struct cgroup_subsys cpu_cgroup_subsys =
    * (balbir@in.ibm.com).
    */

    -/* track cpu usage of a group of tasks */
    +/* track cpu usage of a group of tasks and its child groups */
    struct cpuacct {
    struct cgroup_subsys_state css;
    /* cpuusage holds pointer to a u64-type object on every cpu */
    u64 *cpuusage;
    + struct cpuacct *parent;
    };

    struct cgroup_subsys cpuacct_subsys;
    @@ -9269,6 +9270,9 @@ static struct cgroup_subsys_state *cpuac
    return ERR_PTR(-ENOMEM);
    }

    + if (cgrp->parent)
    + ca->parent = cgroup_ca(cgrp->parent);
    +
    return &ca->css;
    }

    @@ -9348,14 +9352,16 @@ static int cpuacct_populate(struct cgrou
    static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
    {
    struct cpuacct *ca;
    + int cpu;

    if (!cpuacct_subsys.active)
    return;

    + cpu = task_cpu(tsk);
    ca = task_ca(tsk);
    - if (ca) {
    - u64 *cpuusage = percpu_ptr(ca->cpuusage, task_cpu(tsk));

    + for (; ca; ca = ca->parent) {
    + u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu);
    *cpuusage += cputime;
    }
    }

    Regards,
    Bharata.
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. Re: [PATCH] Add hierarchical accounting to cpu accounting controller


    * Bharata B Rao wrote:

    > On Mon, Nov 10, 2008 at 02:09:37PM +0100, Ingo Molnar wrote:
    > >
    > > * Bharata B Rao wrote:
    > >
    > > > I will resend the patch with other corrections you mentioned only if
    > > > Paul/Ingo want this patch to go in.

    > >
    > > yes, please resend the fixed version.

    >
    > Here it is:
    >
    > Add hierarchical accounting to cpu accounting controller and include
    > cpuacct documentation.
    >
    > Currently, while charging the task's cputime to its accounting group,
    > the accounting group hierarchy isn't updated. This patch charges the cputime
    > of a task to its accounting group and all its parent accounting groups.
    >
    > Reported-by: Srivatsa Vaddagiri
    > Signed-off-by: Bharata B Rao
    > CC: Ingo Molnar
    > CC: Srivatsa Vaddagiri
    > Reviewed-by: Paul Menage
    > Acked-by: Balbir Singh
    > Acked-by: Peter Zijlstra
    > ---
    > Documentation/controllers/cpuacct.txt | 32 ++++++++++++++++++++++++++++++++
    > kernel/sched.c | 12 +++++++++---
    > 2 files changed, 41 insertions(+), 3 deletions(-)


    applied to tip/sched/core, thanks Bharata!

    Ingo
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2