[Devel] [PATCH hci-8.1 v10 08/13] ve: add netns failcounter

Konstantin Khorenko khorenko at virtuozzo.com
Fri Sep 25 19:53:29 MSK 2026


From: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>

Count hits of the per-VE net namespace limit in ve.failcount.

https://virtuozzo.atlassian.net/browse/VSTOR-135520

Feature: per-ve failcounters
Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 include/linux/ve.h       | 1 +
 kernel/ve/ve.c           | 3 +++
 net/core/net_namespace.c | 4 +++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index 546060eddc765..969390bb511e7 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -80,6 +80,7 @@ struct ve_struct {
 	struct kmapset_key	proc_perms_key;
 
 	atomic_t		netns_avail_nr;
+	atomic_t		netns_failcount;
 	int			netns_max_nr;
 
 	atomic_t		netif_avail_nr;
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index f915f86e7471e..56936ef4cc92b 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -100,6 +100,7 @@ struct ve_struct ve0 = {
 	.features		= -1,
 	.sched_lat_ve.cur	= &ve0_lat_stats,
 	.netns_avail_nr		= ATOMIC_INIT(INT_MAX),
+	.netns_failcount	= ATOMIC_INIT(0),
 	.netns_max_nr		= INT_MAX,
 	.netif_avail_nr		= ATOMIC_INIT(INT_MAX),
 	.netif_max_nr		= INT_MAX,
@@ -792,6 +793,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
 	ve->fsync_enable = FSYNC_FILTERED;
 
 	atomic_set(&ve->netns_avail_nr, NETNS_MAX_NR_DEFAULT);
+	atomic_set(&ve->netns_failcount, 0);
 	ve->netns_max_nr = NETNS_MAX_NR_DEFAULT;
 
 	atomic_set(&ve->netif_avail_nr, NETIF_MAX_NR_DEFAULT);
@@ -1084,6 +1086,7 @@ static const struct ve_failcount_entry {
 	size_t offset;
 } ve_failcounts[] = {
 #define VE_FC_ENTRY(name) { #name, offsetof(struct ve_struct, name##_failcount) }
+	VE_FC_ENTRY(netns),
 	{}
 };
 
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index b3d54cad984a9..328e1c96b6f4d 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -486,8 +486,10 @@ void net_drop_ns(void *p)
 #ifdef CONFIG_VE
 static int dec_netns_avail(struct ve_struct *ve)
 {
-	if (atomic_dec_if_positive(&ve->netns_avail_nr) < 0)
+	if (atomic_dec_if_positive(&ve->netns_avail_nr) < 0) {
+		ve_failcount_inc(ve, netns);
 		return -ENOSPC;
+	}
 	return 0;
 }
 

-- 
2.43.0



More information about the Devel mailing list