All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>,
	Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
	cover.1789491989.git.vladimir.riabchun@virtuozzo.com,
	Konstantin Khorenko <khorenko@virtuozzo.com>,
	devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v10 11/13] ve: add bpf_prog failcounter
Date: Fri, 25 Sep 2026 18:53:32 +0200	[thread overview]
Message-ID: <20260925-b4-kh-ve_fail-v10-11-77a6b6ea4205@virtuozzo.com> (raw)
In-Reply-To: <20260925-b4-kh-ve_fail-v10-0-77a6b6ea4205@virtuozzo.com>

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

Count hits of the per-VE BPF program limit in ve.failcount.

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

Feature: per-ve failcounters
Signed-off-by: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 include/linux/ve.h   | 1 +
 kernel/bpf/syscall.c | 1 +
 kernel/ve/ve.c       | 3 +++
 3 files changed, 5 insertions(+)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index 5d94470692f72..b4c9e628cb333 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -88,6 +88,7 @@ struct ve_struct {
 	int			netif_max_nr;
 
 	atomic_t		bpf_prog_avail_nr;
+	atomic_t		bpf_prog_failcount;
 	int			bpf_prog_max_nr;
 
 	atomic64_t		_uevent_seqnum;
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index c94d4240e3d3d..8498bc9df7ea6 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2891,6 +2891,7 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
 	if (!bpf_cap && type == BPF_PROG_TYPE_CGROUP_DEVICE) {
 		load_ve = get_exec_env();
 		if (atomic_dec_if_positive(&load_ve->bpf_prog_avail_nr) < 0) {
+			ve_failcount_inc(load_ve, bpf_prog);
 			load_ve = NULL;
 			err = -ENOSPC;
 			goto put_token;
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 8505c1dae4a18..be45975b74045 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -106,6 +106,7 @@ struct ve_struct ve0 = {
 	.netif_failcount	= ATOMIC_INIT(0),
 	.netif_max_nr		= INT_MAX,
 	.bpf_prog_avail_nr	= ATOMIC_INIT(INT_MAX),
+	.bpf_prog_failcount	= ATOMIC_INIT(0),
 	.bpf_prog_max_nr	= INT_MAX,
 	.fsync_enable		= FSYNC_FILTERED,
 	._randomize_va_space	=
@@ -803,6 +804,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
 	ve->netif_max_nr = NETIF_MAX_NR_DEFAULT;
 
 	atomic_set(&ve->bpf_prog_avail_nr, BPF_PROG_MAX_NR_DEFAULT);
+	atomic_set(&ve->bpf_prog_failcount, 0);
 	ve->bpf_prog_max_nr = BPF_PROG_MAX_NR_DEFAULT;
 
 	err = ve_log_init(ve);
@@ -1093,6 +1095,7 @@ static const struct ve_failcount_entry {
 	VE_FC_ENTRY(netns),
 	VE_FC_ENTRY(mnt),
 	VE_FC_ENTRY(netif),
+	VE_FC_ENTRY(bpf_prog),
 	{}
 };
 

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-09-25 16:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 16:53 [Devel] [PATCH hci-8.1 v10 00/13] Add per-VE failcount support Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 01/13] ve/ve.{h, c}: farewell to spaces as indents Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 02/13] ve/fs: count available mounts instead of used ones Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 03/13] selftests/ve: update ve_ns_owner_test Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 04/13] ve: make mount limit configurable per VE Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 05/13] ve/ve.c: generate VE resource accessors using macros Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 06/13] ve/aio: initialize aio fields in ve0 Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 07/13] ve: introduce per-VE failcounter infrastructure Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 08/13] ve: add netns failcounter Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 09/13] ve: add mnt failcounter Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 10/13] ve: add netif failcounter Konstantin Khorenko
2026-09-25 16:53 ` Konstantin Khorenko [this message]
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 12/13] ve: add aio failcounter Konstantin Khorenko
2026-09-25 16:53 ` [Devel] [PATCH hci-8.1 v10 13/13] selftests/ve: add mount accounting selftest Konstantin Khorenko
2026-09-25 17:10 ` [Devel] [PATCH hci-8.1 v10 00/13] Add per-VE failcount support Vladimir Riabchun
2026-09-25 17:33 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260925-b4-kh-ve_fail-v10-11-77a6b6ea4205@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=cover.1789491989.git.vladimir.riabchun@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.