[Devel] [PATCH RHEL7 COMMIT] Revert "ub: introduce helper for real "held" value (without precharge)"

Konstantin Khorenko khorenko at virtuozzo.com
Thu Apr 23 12:18:44 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.vz7.150.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.vz7.150.3
------>
commit 014a94175615448fc2a23894267f7f1aeb69977c
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date:   Thu Apr 23 12:18:43 2020 +0300

    Revert "ub: introduce helper for real "held" value (without precharge)"
    
    This reverts commit 3fb610430bd73284c61cb69aa8f7264f25b0e924.
    
    This commit had 4 problems:
    1. The helper function get_beancounter_held_real did not encapsulate
       a lot of logic and only substituted a single line of code in original
       location.
    
    2. The same function was only called from a single place.
    
    3. It introduced logic gap between a call to ub_precharge_snapshot
       and the actual use of it's result when subtracting the sum of all
       per-cpu precharges from held.
    
    4. It also introduced a WARN check of values that are racy by design without
       actually holding a lock. There are two possible ways to resolve this, add
       locking to defeat race, or remove the warning. There are 2 arguments that
       stand against adding locking here:
        a) this is a stat displaying codepath,
        b) warning checks values that are especially designed to be lockless for
           speed.
    
    https://jira.sw.ru/browse/PSBM-103215
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
 include/bc/beancounter.h | 18 ------------------
 kernel/bc/proc.c         |  3 ++-
 2 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/include/bc/beancounter.h b/include/bc/beancounter.h
index 6db175e8c6ac1..a06d9b6ecfd3e 100644
--- a/include/bc/beancounter.h
+++ b/include/bc/beancounter.h
@@ -483,24 +483,6 @@ static inline void uncharge_beancounter_fast(struct user_beancounter *ub,
 	local_irq_restore(flags);
 }
 
-/*
- * For a particular beancounter param return real 'held' value with
- * respect to precharge.
- */
-static inline unsigned long get_beancounter_held_real(struct ubparm *ubparm,
-               int precharge)
-{
-       unsigned long val = ubparm->held;
-
-       /*
-        * We want to catch cases where precharge might be greater
-        * than held.
-        */
-       WARN_ON_ONCE(val < precharge);
-
-       return (val > precharge) ? (val - precharge) : 0;
-}
-
 unsigned long __get_beancounter_usage_percpu(struct user_beancounter *ub,
 		int resource);
 
diff --git a/kernel/bc/proc.c b/kernel/bc/proc.c
index 268f1b41a733e..70ec6ff5f2163 100644
--- a/kernel/bc/proc.c
+++ b/kernel/bc/proc.c
@@ -52,7 +52,8 @@ static void ub_show_res(struct seq_file *f, struct user_beancounter *ub,
 	unsigned long held;
 
 	p = &ub->ub_parms[r];
-	held = get_beancounter_held_real(p, precharge);
+	held = p->held;
+	held = (held > precharge) ? (held - precharge) : 0;
 
 	seq_printf(f, res_fmt,
 			show_uid && r == 0 ? ub->ub_name : "",


More information about the Devel mailing list