[Devel] [PATCH RHEL8 COMMIT] ve: fix reading container state from cgroup
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 9 19:39:48 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.53
------>
commit 22b6ab88d5fcf9c0dd57e550fb1bf0c40544a085
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date: Fri Jul 9 19:39:48 2021 +0300
ve: fix reading container state from cgroup
1) ve->op_sem is needed to remove race with ve_start_container when
ve->is_running == 0 but ve->ve_ns != NULL already, and for a short
moment we would print "STOPPING" if read state on container start
2) add !ve->ve_ns check for showing STOPPED just to be more consistent
with vz7 and don't show STOPPED if we still see non-null ve->ve_ns.
So now we have:
RUNNING | STOPPED
is_running==true | is_running==false
| ve_ns==NULL
| !cgroup_is_populated()
Before these patch we were able to see STARTING instead of STOPPING and
vice versa.
https://jira.sw.ru/browse/PSBM-82766
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
rebase to vz8:
Reworked:
- bring back ve_ns check from vz7 for consistency
- leave cgroup_is_populated as it looks like a valid replacement
for nr_threads_ve
- remove rcu_access_pointer as we are under ve->op_sem anyway
https://jira.sw.ru/browse/PSBM-131412
https://jira.sw.ru/browse/PSBM-127798
(cherry-picked from vz7 commit 1c182ff3216c ("ve: fix reading container
state from cgroup"))
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
kernel/ve/ve.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 9667f9051c02..dc920cdf5921 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1147,15 +1147,17 @@ static int ve_state_show(struct seq_file *sf, void *v)
struct cgroup_subsys_state *css = seq_css(sf);
struct ve_struct *ve = css_to_ve(css);
+ down_read(&ve->op_sem);
if (ve->is_running)
seq_puts(sf, "RUNNING");
- else if (!cgroup_is_populated(css->cgroup))
+ else if (!cgroup_is_populated(css->cgroup) && !ve->ve_ns)
seq_puts(sf, "STOPPED");
- else if (rcu_access_pointer(ve->ve_ns))
+ else if (ve->ve_ns)
seq_puts(sf, "STOPPING");
else
seq_puts(sf, "STARTING");
seq_putc(sf, '\n');
+ up_read(&ve->op_sem);
return 0;
}
More information about the Devel
mailing list