[Devel] [PATCH RHEL7 COMMIT] bc: roll back beancounters-based numer of processes accounting

Konstantin Khorenko khorenko at virtuozzo.com
Mon Aug 13 19:13:26 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.9.1.vz7.70.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.9.1.vz7.70.3
------>
commit 93f3499e067721f1012cee24e00b40ab76818118
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Mon Aug 13 19:13:26 2018 +0300

    bc: roll back beancounters-based numer of processes accounting
    
    ubc param "numproc" is handled ub in our home brew beancounters code,
    while stock kernel (even RHEL7 one) now has pids cgroup which
    does approximately the same.
    
    So drop original "numproc" ubc limit code, next patch adds similar
    funtionality basing on pids cgroup.
    
    Note: the difference between approaches:
    - ubc code accounts and limits processes (thus you can create a lot of
      threads in a Container with "numproc" limit)
    - pids cgroup accounts and limits "pids", thus including threads
    
    At the same time we already configure pids cgroup for a Container and
    set up "pids.max" equal to ubc "numproc" value, so the semantic has been
    already changed for some period.
    
    Fixes: d821108a8a1a ("ubc: initial patch")
    https://jira.sw.ru/browse/PSBM-86044
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    ======================================================
    Patchset description:
    bc: rework "numproc" ubc limit to be based on pids cgroup
    
    It's time to rework our home brew ubc "numproc" limit to be based on stock pids
    cgroup.
    
    Note: the semantic will change a bit: now we limit number of possible threads
    in a Container while old ubc "numproc" limited number of tasks.
    
    Note1: vzctl update is required.
    
    https://jira.sw.ru/browse/PSBM-86044
    
    Konstantin Khorenko (2):
      bc: roll back beancounters-based numer of processes accounting
      bc: implement ubc "numproc" limit based on pids cgroup
---
 include/bc/misc.h       |  2 --
 kernel/bc/beancounter.c |  2 --
 kernel/bc/misc.c        | 10 ----------
 kernel/exit.c           |  1 -
 kernel/fork.c           |  7 +------
 5 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/include/bc/misc.h b/include/bc/misc.h
index 7bf77ef34320..b329e5fedf22 100644
--- a/include/bc/misc.h
+++ b/include/bc/misc.h
@@ -23,8 +23,6 @@ UB_DECLARE_VOID_FUNC(ub_flock_uncharge(struct file_lock *fl))
 UB_DECLARE_FUNC(int, ub_siginfo_charge(struct sigqueue *q,
 			struct user_beancounter *ub, gfp_t gfp_mask))
 UB_DECLARE_VOID_FUNC(ub_siginfo_uncharge(struct sigqueue *q))
-UB_DECLARE_FUNC(int, ub_task_charge(struct user_beancounter *ub))
-UB_DECLARE_VOID_FUNC(ub_task_uncharge(struct user_beancounter *ub))
 UB_DECLARE_VOID_FUNC(ub_task_get(struct user_beancounter *ub,
 			struct task_struct *task))
 UB_DECLARE_VOID_FUNC(ub_task_put(struct task_struct *task))
diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index d5de31008a5e..31e5904df708 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -76,7 +76,6 @@ const char *ub_rnames[] = {
 /* default maximum perpcu resources precharge */
 int ub_resource_precharge[UB_RESOURCES] = {
 	[UB_PRIVVMPAGES]= 256,
-	[UB_NUMPROC]	= 4,
 	[UB_NUMSIGINFO]	= 4,
 	[UB_NUMFILE]	= 8,
 };
@@ -1089,7 +1088,6 @@ void __init ub_init_early(void)
 	memset(&current->task_bc, 0, sizeof(struct task_beancounter));
 	(void)set_exec_ub(ub);
 	current->task_bc.task_ub = get_beancounter(ub);
-	__charge_beancounter_locked(ub, UB_NUMPROC, 1, UB_FORCE);
 	init_mm.mm_ub = get_beancounter(ub);
 
 	list_add(&ub->ub_list, &ub_list_head);
diff --git a/kernel/bc/misc.c b/kernel/bc/misc.c
index 15093a719407..16e70cd220e2 100644
--- a/kernel/bc/misc.c
+++ b/kernel/bc/misc.c
@@ -22,16 +22,6 @@
  * Task staff
  */
 
-int ub_task_charge(struct user_beancounter *ub)
-{
-	return charge_beancounter_fast(ub, UB_NUMPROC, 1, UB_HARD);
-}
-
-void ub_task_uncharge(struct user_beancounter *ub)
-{
-	uncharge_beancounter_fast(ub, UB_NUMPROC, 1);
-}
-
 void ub_task_get(struct user_beancounter *ub, struct task_struct *task)
 {
 	struct task_beancounter *new_bc = &task->task_bc;
diff --git a/kernel/exit.c b/kernel/exit.c
index 1f243edca11a..bf68b87a4d60 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -214,7 +214,6 @@ void release_task(struct task_struct * p)
 	qwrite_unlock_irq(&tasklist_lock);
 	cgroup_pids_release(p);
 	release_thread(p);
-	ub_task_uncharge(get_task_ub(p));
 	call_rcu(&p->rcu, delayed_put_task_struct);
 
 	p = leader;
diff --git a/kernel/fork.c b/kernel/fork.c
index 2898e64ce9d3..aada3d26ffcc 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1394,12 +1394,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 		goto fork_out;
 
 	retval = -ENOMEM;
-	if (ub_task_charge(get_exec_ub()))
-		goto fork_out;
-
 	p = dup_task_struct(current, node);
 	if (!p)
-		goto bad_fork_uncharge;
+		goto fork_out;
 
 	ub_task_get(get_exec_ub(), p);
 
@@ -1771,8 +1768,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 bad_fork_free:
 	ub_task_put(p);
 	free_task(p);
-bad_fork_uncharge:
-	ub_task_uncharge(get_exec_ub());
 fork_out:
 	return ERR_PTR(retval);
 }


More information about the Devel mailing list