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

Valeriy Vdovin valeriy.vdovin at virtuozzo.com
Tue Apr 21 14:53:31 MSK 2020


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 6db175e..a06d9b6 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 268f1b4..70ec6ff 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 : "",
-- 
1.8.3.1



More information about the Devel mailing list