On 11/25/25 04:42, Aleksei Oladko wrote:
> The new helper returns pid in root pidns of VE
> 
> Signed-off-by: Aleksei Oladko <[email protected]>
> ---
>  include/linux/ve.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/include/linux/ve.h b/include/linux/ve.h
> index 37562dff25aa..b99faaba6e48 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;
> @@ -191,6 +192,22 @@ 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_ns;
> +     pid_t pid;
> +
> +     rcu_read_lock();
> +     ve_ns = rcu_dereference(get_exec_env()->ve_ns);

In case of show_signal_msg() this helper is completely fine. But do we really 
want to use current ve here? I think it would be a bit more consistent to take 
ve not from current task but from the "tsk" itself. 

In other words, when host task (from ve0) uses task_pid_ve_nr() on container 
task, we might get confused, because the task_pid_ve_nr() helper would return 
the pid in host init pid namespace.

> +     if (ve_ns)
> +             pid = task_pid_nr_ns(tsk, ve_ns->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_ns;

-- 
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.

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

Reply via email to