[Devel] [PATCH rh7] ve/vznetstat: Fix potential exit race
Cyrill Gorcunov
gorcunov at virtuozzo.com
Fri Jul 24 09:19:11 PDT 2015
On Fri, Jul 24, 2015 at 07:13:06PM +0300, Vladimir Davydov wrote:
...
> > prefer counter. What's the profit of using @ve_netns instead?
>
> Because this way it will always work, while your approach won't. In case
> of VZCTL_TC_CLEAR_STAT you can get away by taking the req_mutex, but it
> simply won't work with venet_acct_set_base.
True. Fix on top attached. Thank you!
-------------- next part --------------
From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Subject: [PATCH rh7] ve/vznetstat: Fix potential exit race
When container is exiting another task may be doing operations
with statistics incrementing/decrementing stat counter, which
may lead to situation where counter is not zero, thus we don't
zap @ve->stat member.
Fix it by testing if the net is the last one belonging
to a container.
https://jira.sw.ru/browse/PSBM-35178
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
CC: Andrey Vagin <avagin at virtuozzo.com>
CC: Vladimir Davydov <vdavydov at virtuozzo.com>
CC: Konstantin Khorenko <khorenko at virtuozzo.com>
CC: Pavel Emelyanov <xemul at virtuozzo.com>
CC: Igor Sukhih <igor at parallels.com>
---
kernel/ve/vznetstat/vznetstat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-pcs7.git/kernel/ve/vznetstat/vznetstat.c
===================================================================
--- linux-pcs7.git.orig/kernel/ve/vznetstat/vznetstat.c
+++ linux-pcs7.git/kernel/ve/vznetstat/vznetstat.c
@@ -1098,7 +1098,7 @@ static void __net_exit net_exit_acct(str
if (ve->stat) {
venet_acct_put_stat(ve->stat);
- if (atomic_read(&ve->stat->users) == 0)
+ if (ve->ve_netns == net)
ve->stat = NULL;
}
}
More information about the Devel
mailing list