Create one beancounter per thread group. This is the base patch and serves
as the starting point for aggregating thread groups.

Signed-off-by: Balbir Singh <[EMAIL PROTECTED]>
---

 kernel/bc/misc.c |   11 +++++++----
 kernel/fork.c    |    4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff -puN kernel/bc/misc.c~per-tgid-beancounters kernel/bc/misc.c
--- linux-2.6.18-rc5/kernel/bc/misc.c~per-tgid-beancounters     2006-09-12 
22:27:02.000000000 +0530
+++ linux-2.6.18-rc5-balbir/kernel/bc/misc.c    2006-09-17 20:30:55.000000000 
+0530
@@ -12,15 +12,18 @@
 
 void bc_task_charge(struct task_struct *parent, struct task_struct *new)
 {
-       struct task_beancounter *old_bc;
        struct task_beancounter *new_bc;
        struct beancounter *bc;
 
-       old_bc = &parent->task_bc;
        new_bc = &new->task_bc;
+       bc = beancounter_findcreate(new->tgid, BC_ALLOC);
+       if (!bc) {
+               printk(KERN_WARNING "failed to create bc %d for tgid %d\n",
+                       bc->bc_id, new->tgid);
+               return;
+       }
 
-       bc = old_bc->fork_bc;
-       new_bc->exec_bc = get_beancounter(bc);
+       new_bc->exec_bc = bc;
        new_bc->fork_bc = get_beancounter(bc);
 }
 
diff -puN kernel/fork.c~per-tgid-beancounters kernel/fork.c
--- linux-2.6.18-rc5/kernel/fork.c~per-tgid-beancounters        2006-09-12 
22:27:02.000000000 +0530
+++ linux-2.6.18-rc5-balbir/kernel/fork.c       2006-09-12 22:32:26.000000000 
+0530
@@ -994,8 +994,6 @@ static struct task_struct *copy_process(
        if (!p)
                goto fork_out;
 
-       bc_task_charge(current, p);
-
 #ifdef CONFIG_TRACE_IRQFLAGS
        DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
        DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
@@ -1106,6 +1104,8 @@ static struct task_struct *copy_process(
        if (clone_flags & CLONE_THREAD)
                p->tgid = current->tgid;
 
+       bc_task_charge(current, p);
+
        if ((retval = security_task_alloc(p)))
                goto bad_fork_cleanup_policy;
        if ((retval = audit_alloc(p)))
_

-- 

        Balbir Singh,
        Linux Technology Center,
        IBM Software Labs

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech

Reply via email to