[Devel] [PATCH hci-8.1 v10 10/13] ve: add netif failcounter

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


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

Count hits of the per-VE network interface limit in ve.failcount.
The per-site "increase ve::netif_max_nr" hints are replaced by the
unified message from ve_failcount_inc.

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/dev.c     | 10 ++--------
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index 0395e37208849..5d94470692f72 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -84,6 +84,7 @@ struct ve_struct {
 	int			netns_max_nr;
 
 	atomic_t		netif_avail_nr;
+	atomic_t		netif_failcount;
 	int			netif_max_nr;
 
 	atomic_t		bpf_prog_avail_nr;
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 4c3acda6b135e..8505c1dae4a18 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -103,6 +103,7 @@ struct ve_struct ve0 = {
 	.netns_failcount	= ATOMIC_INIT(0),
 	.netns_max_nr		= INT_MAX,
 	.netif_avail_nr		= ATOMIC_INIT(INT_MAX),
+	.netif_failcount	= ATOMIC_INIT(0),
 	.netif_max_nr		= INT_MAX,
 	.bpf_prog_avail_nr	= ATOMIC_INIT(INT_MAX),
 	.bpf_prog_max_nr	= INT_MAX,
@@ -798,6 +799,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
 	ve->netns_max_nr = NETNS_MAX_NR_DEFAULT;
 
 	atomic_set(&ve->netif_avail_nr, NETIF_MAX_NR_DEFAULT);
+	atomic_set(&ve->netif_failcount, 0);
 	ve->netif_max_nr = NETIF_MAX_NR_DEFAULT;
 
 	atomic_set(&ve->bpf_prog_avail_nr, BPF_PROG_MAX_NR_DEFAULT);
@@ -1090,6 +1092,7 @@ static const struct ve_failcount_entry {
 #define VE_FC_ENTRY(name) { #name, offsetof(struct ve_struct, name##_failcount) }
 	VE_FC_ENTRY(netns),
 	VE_FC_ENTRY(mnt),
+	VE_FC_ENTRY(netif),
 	{}
 };
 
diff --git a/net/core/dev.c b/net/core/dev.c
index c7dddb200489f..7632ad1fd0151 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10997,10 +10997,7 @@ int register_netdevice(struct net_device *dev)
 
 	ret = -ENOMEM;
 	if (atomic_dec_if_positive(&net->owner_ve->netif_avail_nr) < 0) {
-		ve_pr_warn_ratelimited(VE_LOG_BOTH,
-			"CT%s: hits max number of network devices, "
-			"increase ve::netif_max_nr parameter\n",
-			ve_name(net->owner_ve));
+		ve_failcount_inc(net->owner_ve, netif);
 		return ret;
 	}
 
@@ -12211,10 +12208,7 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
 
 	err = -ENOMEM;
 	if (atomic_dec_if_positive(&net->owner_ve->netif_avail_nr) < 0) {
-		ve_pr_warn_ratelimited(VE_LOG_BOTH,
-			"CT%s: hits max number of network devices, "
-			"increase ve::netif_max_nr parameter\n",
-			ve_name(net->owner_ve));
+		ve_failcount_inc(net->owner_ve, netif);
 		goto out;
 	}
 	atomic_inc(&dev_net(dev)->owner_ve->netif_avail_nr);

-- 
2.43.0



More information about the Devel mailing list