The commit is pushed to "branch-rh10-6.12.0-55.13.1.2.x.vz10-ovz" and will
appear at [email protected]:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.2.23.vz10
------>
commit 4d3ef81d2e6c6f11497c8af859885a2d57eea1b6
Author: Aleksei Oladko <[email protected]>
Date: Wed Dec 3 16:35:16 2025 +0100
ve: Introduce task_pid_ve_nr() helper
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
---
include/linux/ve.h | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 0fbc4c45525fc..cd0e855d38f18 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;
@@ -179,6 +180,8 @@ 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);
+DEFINE_FREE(put_ve, struct ve_struct *, if (_T) put_ve(_T))
+
static inline struct ve_struct *task_ve(struct task_struct *task)
{
return READ_ONCE(task->task_ve);
@@ -202,6 +205,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;
@@ -259,6 +280,8 @@ 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)
+DEFINE_FREE(put_ve, struct ve_struct *, if (_T) put_ve(_T))
+
static inline struct ve_struct *task_ve(struct task_struct *task)
{
return NULL;
@@ -323,6 +346,4 @@ static inline int ve_get_cpu_avenrun(struct ve_struct *ve,
unsigned long *avenru
static inline int ve_get_cpu_stat(struct ve_struct *ve, struct kernel_cpustat
*kstat) { return -ENOSYS; }
#endif
-DEFINE_FREE(put_ve, struct ve_struct *, if (_T) put_ve(_T))
-
#endif /* _LINUX_VE_H */
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel