[Devel] [PATCH RHEL7 COMMIT] ve: Make get_ve_by_id() lockless

Konstantin Khorenko khorenko at odin.com
Thu Apr 30 08:24:53 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.4.9
------>
commit 1b776f45202a6e39b9516a080212a206be840ad4
Author: Kirill Tkhai <ktkhai at odin.com>
Date:   Thu Apr 30 19:24:53 2015 +0400

    ve: Make get_ve_by_id() lockless
    
    css_tryget() fails if css_offline has already been called,
    so the "true" result guarantees that final put_ve() hasn't
    been made yet.
    
    Signed-off-by: Kirill Tkhai <ktkhai at odin.com>
    Acked-by: Vladimir Davydov <vdavydov at parallels.com>
---
 kernel/ve/ve.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 9a6424e..3ef10bc 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -226,10 +226,11 @@ EXPORT_SYMBOL(__find_ve_by_id);
 struct ve_struct *get_ve_by_id(envid_t veid)
 {
 	struct ve_struct *ve;
-	mutex_lock(&ve_list_lock);
+	rcu_read_lock();
 	ve = __find_ve_by_id(veid);
-	get_ve(ve);
-	mutex_unlock(&ve_list_lock);
+	if (ve && !css_tryget(&ve->css))
+		ve = NULL;
+	rcu_read_unlock();
 	return ve;
 }
 EXPORT_SYMBOL(get_ve_by_id);



More information about the Devel mailing list