Beautifull tasks accounting/limiting beancounter control.

Signed-off-by: Pavel Emelianov <[EMAIL PROTECTED]>
Signed-off-by: Kirill Korotaev <[EMAIL PROTECTED]>

---

 include/linux/sched.h |    1 +
 kernel/bc/misc.c      |   31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

--- ./include/linux/sched.h.bctasks     2006-11-03 17:47:38.000000000 +0300
+++ ./include/linux/sched.h     2006-11-03 17:51:57.000000000 +0300
@@ -1068,6 +1068,7 @@ int copy_beancounter(struct task_struct 
 #endif
 #ifdef CONFIG_BEANCOUNTERS
        struct beancounter *exec_bc;
+       struct beancounter *task_bc;
 #endif
 };
 
--- ./kernel/bc/misc.c.bctasks  2006-11-03 17:47:38.000000000 +0300
+++ ./kernel/bc/misc.c  2006-11-03 17:51:57.000000000 +0300
@@ -17,6 +17,10 @@ int copy_beancounter(struct task_struct 
        struct beancounter *bc;
 
        bc = parent->exec_bc;
+       if (bc_charge(bc, BC_NUMTASKS, 1, BC_LIMIT))
+               return -ENOMEM;
+
+       tsk->task_bc = bc_get(bc);
        tsk->exec_bc = bc_get(bc);
        return 0;
 }
@@ -25,6 +29,10 @@ void free_beancounter(struct task_struct
 {
        struct beancounter *bc;
 
+       bc = tsk->task_bc;
+       bc_uncharge(bc, BC_NUMTASKS, 1);
+       bc_put(bc);
+
        bc = tsk->exec_bc;
        bc_put(bc);
 }
@@ -86,3 +94,26 @@ int bc_task_move(struct task_struct *tsk
        return err;
 }
 EXPORT_SYMBOL(bc_task_move);
+
+#define BC_NUMTASKS_BARRIER    128
+#define BC_NUMTASKS_LIMIT      128
+
+static int bc_task_init(struct beancounter *bc, int i)
+{
+       bc_init_resource(&bc->bc_parms[BC_NUMTASKS],
+                       BC_NUMTASKS_BARRIER, BC_NUMTASKS_LIMIT);
+       return 0;
+}
+
+static struct bc_resource bc_task_resource = {
+       .bcr_name = "numtasks",
+       .bcr_init = bc_task_init,
+};
+
+static int __init bc_misc_init_resource(void)
+{
+       bc_register_resource(BC_NUMTASKS, &bc_task_resource);
+       return 0;
+}
+
+__initcall(bc_misc_init_resource);

-------------------------------------------------------------------------
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