[Devel] [PATCH RH9 08/11] ve/uevent: Use own uevent_seqnum for every VE

Alexander Mikhalitsyn alexander.mikhalitsyn at virtuozzo.com
Thu Sep 23 18:02:32 MSK 2021


From: Konstantin Khorenko <khorenko at virtuozzo.com>

https://jira.sw.ru/browse/PSBM-17903

Signed-off-by: Kirill Tkhai <ktkhai at parallels.com>

https://jira.sw.ru/browse/PSBM-133986

(cherry picked from commit 739915b241c792831b89f87bb6260da8a6a515e7)
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 include/linux/ve.h   | 6 ++++++
 kernel/ksysfs.c      | 3 ++-
 lib/kobject_uevent.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index c8dd71cfa3d9..f8fd5b67ffb8 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -51,6 +51,8 @@ struct ve_struct {
 
 	atomic_t		netns_avail_nr;
 	int			netns_max_nr;
+
+	u64			_uevent_seqnum;
 };
 
 extern int nr_ve;
@@ -81,6 +83,8 @@ extern bool current_user_ns_initial(void);
 
 extern struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp);
 
+#define ve_uevent_seqnum       (get_exec_env()->_uevent_seqnum)
+
 #else	/* CONFIG_VE */
 #define get_ve(ve)	(NULL)
 #define put_ve(ve)	do { } while (0)
@@ -99,6 +103,8 @@ static inline struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp)
 {
 	return NULL;
 }
+#define ve_uevent_seqnum uevent_seqnum
+
 #endif	/* CONFIG_VE */
 
 #endif /* _LINUX_VE_H */
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 35859da8bd4f..e56c431b94af 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -17,6 +17,7 @@
 #include <linux/sched.h>
 #include <linux/capability.h>
 #include <linux/compiler.h>
+#include <linux/ve.h>
 
 #include <linux/rcupdate.h>	/* rcu_expedited and rcu_normal */
 
@@ -31,7 +32,7 @@ static struct kobj_attribute _name##_attr = \
 static ssize_t uevent_seqnum_show(struct kobject *kobj,
 				  struct kobj_attribute *attr, char *buf)
 {
-	return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum);
+	return sprintf(buf, "%llu\n", (unsigned long long)ve_uevent_seqnum);
 }
 KERNEL_ATTR_RO(uevent_seqnum);
 
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index c87d5b6a8a55..db150f72ba9a 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -585,7 +585,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
 
 	mutex_lock(&uevent_sock_mutex);
 	/* we will send an event, so request a new sequence number */
-	retval = add_uevent_var(env, "SEQNUM=%llu", ++uevent_seqnum);
+	retval = add_uevent_var(env, "SEQNUM=%llu", ++ve_uevent_seqnum);
 	if (retval) {
 		mutex_unlock(&uevent_sock_mutex);
 		goto exit;
-- 
2.31.1



More information about the Devel mailing list