From: Aleksei Oladko <[email protected]> The new helper returns pid in root pidns of VE.
https://virtuozzo.atlassian.net/browse/VSTOR-119875 Signed-off-by: Aleksei Oladko <[email protected]> Reviewed-by: Pavel Tikhomirov <[email protected]> Feature: ve: ve generic structures --- v4: used task_ve guard helpers v5: - ve_ns has been renamed to ve_nsproxy in order not to mess with VE namespace - use new, bright and shiny __free(put_ve) attribute - added a comment why we don't check ve returned by get_task_ve() for NULL --- include/linux/ve.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/ve.h b/include/linux/ve.h index 0fbc4c45525fc..b01c593dad7b9 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -21,6 +21,7 @@ #include <asm/vdso.h> #include <linux/time_namespace.h> #include <linux/binfmts.h> +#include <linux/pid.h> struct nsproxy; struct user_namespace; @@ -202,6 +203,24 @@ static inline struct ve_struct *css_to_ve(struct cgroup_subsys_state *css) extern struct cgroup_subsys_state *ve_get_init_css(struct ve_struct *ve, int subsys_id); +static inline pid_t task_pid_ve_nr(struct task_struct *tsk) +{ + struct nsproxy *ve_nsproxy; + struct ve_struct *ve __free(put_ve) = get_task_ve(tsk); + pid_t pid; + + rcu_read_lock(); + /* get_task_ve() always returns non-NULL when CONFIG_VE is enabled */ + ve_nsproxy = rcu_dereference(ve->ve_nsproxy); + if (ve_nsproxy) + pid = task_pid_nr_ns(tsk, ve_nsproxy->pid_ns_for_children); + else + pid = task_pid_nr(tsk); + rcu_read_unlock(); + + return pid; +} + static inline struct time_namespace *ve_get_time_ns(struct ve_struct *ve) { struct nsproxy *ve_nsproxy; -- 2.43.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
