Those will replace task->task_ve references.

We protect access to other task's task_ve with task_lock. To actually be
able to dereference ve fields we also have to take reference on it,
because other task's task_ve can change under us.

If we don't plan to dereference ve and only use it to compare with other
ve, we can just read it without any locking.

https://virtuozzo.atlassian.net/browse/VSTOR-118289
Signed-off-by: Pavel Tikhomirov <[email protected]>

Feature: ve: ve generic structures
---
 include/linux/ve.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index 63b80068e2fb5..f664740041001 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -179,6 +179,17 @@ void cgroot_ve_cleanup_ra_data(struct cgroup_root *cgroot);
 extern struct ve_struct *get_ve(struct ve_struct *ve);
 extern void put_ve(struct ve_struct *ve);
 
+static inline struct ve_struct *task_ve(struct task_struct *task)
+{
+       return READ_ONCE(task->task_ve);
+}
+
+static inline struct ve_struct *get_task_ve(struct task_struct *task)
+{
+       guard(task_lock)(task);
+       return get_ve(task_ve(task));
+}
+
 void ve_stop_ns(struct pid_namespace *ns);
 void ve_exit_ns(struct pid_namespace *ns);
 bool ve_check_trusted_exec(struct file *file, struct filename *name);
@@ -248,6 +259,16 @@ extern bool is_ve_init_net(const struct net *net);
 #define get_ve(ve)     ((void)(ve), NULL)
 #define put_ve(ve)     do { (void)(ve); } while (0)
 
+static inline struct ve_struct *task_ve(struct task_struct *task)
+{
+       return NULL;
+}
+
+static inline struct ve_struct *get_task_ve(struct task_struct *task)
+{
+       return NULL;
+}
+
 static inline void ve_stop_ns(struct pid_namespace *ns) { }
 static inline void ve_exit_ns(struct pid_namespace *ns) { }
 
-- 
2.51.1

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to