[Devel] [PATCH RHEL7 COMMIT] ub: show up to date data counters in beancounter cgroup
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Apr 1 20:35:36 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1062.12.1.vz7.145.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.12.1.vz7.145.5
------>
commit 9e87df060aba63b8ec9f3283050572fb2c94b9b3
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date: Wed Apr 1 14:09:25 2020 +0300
ub: show up to date data counters in beancounter cgroup
Sync beancounter params from pid and mem cgroups when reading counters
though beancounter cgroup.
Also sync data from CT pid cgroup upon legacy sys_ubstat() syscall
(memcg data is already synced there, only pids data was missing).
https://jira.sw.ru/browse/PSBM-95266
Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Acked-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
kernel/bc/beancounter.c | 16 ++++++++++++++++
kernel/bc/statd.c | 12 ++++++++++++
2 files changed, 28 insertions(+)
diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index fb63023907631..87d7fb1079c92 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -729,6 +729,22 @@ static ssize_t ub_cgroup_resource_read(struct cgroup *cg, struct cftype *cft,
char str[32];
res = UB_CGROUP_RES(cft->private);
+
+ switch (res) {
+ case UB_NUMPROC:
+ ub_sync_pids(ub);
+ break;
+ case UB_KMEMSIZE:
+ case UB_DCACHESIZE:
+ case UB_PHYSPAGES:
+ case UB_SWAPPAGES:
+ case UB_OOMGUARPAGES:
+ ub_sync_memcg(ub);
+ break;
+ default:
+ break;
+ }
+
attr = UB_CGROUP_ATTR(cft->private);
ubparm = &ub->ub_parms[res];
diff --git a/kernel/bc/statd.c b/kernel/bc/statd.c
index a49252e2e5999..dc81959132708 100644
--- a/kernel/bc/statd.c
+++ b/kernel/bc/statd.c
@@ -223,6 +223,16 @@ int ubstat_alloc_store(struct user_beancounter *ub)
}
EXPORT_SYMBOL(ubstat_alloc_store);
+static bool ubstat_need_pids_sync(long cmd)
+{
+ if (UBSTAT_CMD(cmd) != UBSTAT_READ_ONE)
+ return true;
+
+ if (UBSTAT_PARMID(cmd) == UB_NUMPROC)
+ return true;
+ return false;
+}
+
static bool ubstat_need_memcg_sync(long cmd)
{
if (UBSTAT_CMD(cmd) != UBSTAT_READ_ONE)
@@ -272,6 +282,8 @@ static int ubstat_get_stat(struct user_beancounter *ub, long cmd,
if (ubstat_need_memcg_sync(cmd))
ub_sync_memcg(ub);
+ if (ubstat_need_pids_sync(cmd))
+ ub_sync_pids(ub);
spin_lock(&ubs_notify_lock);
switch (UBSTAT_CMD(cmd)) {
More information about the Devel
mailing list