From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 6C2948015D for ; Wed, 9 Sep 2026 21:37:25 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 689LaC4l024104; Thu, 10 Sep 2026 00:36:13 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 689LaC4l024104 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="DWrlJbbD" Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 689LZhMR024039 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 10 Sep 2026 00:35:43 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 689LZhMR024039 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-495474a5fbcso64054545e9.1 for ; Wed, 09 Sep 2026 14:35:43 -0700 (PDT) X-Gm-Message-State: AFuF++nnJGcc12fA6x5pYpJYsY9OIBVpffUeVQDJOWoRRTMPE5F4goHb MUUTul6KfVL9CEYrodfq4lMn59aX11V2WobGs1/08eRjA7QecF2T3wqAA+Eqe3q6PSHMP0dXmv8 RLAddMaHb2rDsZMhkclkmO3HCkMSa3QGezowwuCuAKygHTzCh86TA5w== X-Gm-Gg: AYBFou2OxQEhDS/K3IPWzCVTUfe6dOtDKuQ/sK+Oio1h67qNOhKoSZw7fm3cEh0uaV+ lHA95cna5w6LO/7ckVA53ElizsrT1dqq5R2Ojs78S06GxVgk3nwmo0c8iLgnbAltkks9VkTthCA GYiXzsVFEn13Gk9PUcYUv+2ahIEIMqrMNotD5p9iuGVVkKEFIt/m/V7z/Tc/ewwJvFp5IoZC0kH lifEgjqKH0tJ5vTMV2gXRN95DCqIW6HRF7ANrYB8UItkrr+4qEIsyP5ShYwDt9c+7MT90ydt1hB 9GrMSaME1CSMV+80quAp6zAQsIEqCVA3TcGED1xMrztOUkkqWDDJIAx+JLfAVzXNsrGKXV5h8D8 kbuODEuPIyDNUklUQr8HzNE6PfX+VbQ== X-Received: by 2002:a05:600c:3104:b0:49d:1de5:ce0a with SMTP id 5b1f17b1804b1-49d1de5ce93mr100526975e9.13.1788989743206; Wed, 09 Sep 2026 14:35:43 -0700 (PDT) X-Received: by 2002:a05:600c:3104:b0:49d:1de5:ce0a with SMTP id 5b1f17b1804b1-49d1de5ce93mr100526785e9.13.1788989742714; Wed, 09 Sep 2026 14:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1788989742; cv=none; d=google.com; s=arc-20260327; b=L3EwD/uATg390pUwSIVdPWeNyUm4DL6zACMTbzL2llqUUZ6JKTf++j/EH94HifnADk KdEg/RDiTWXM2PefP/Eg4tv8gBm1pfgrDBap/TvvQiemL7Q0p5Ue8q6BrqiyPM4p2UQN BeqELHoymRiGncdpOtUH6dCq4Ca1cPga8Q8mCRsNX640Ed+tD/66flXcCbFMq7zOnu4s HTQDjXQzz+Nzqy6DxQ7i4+knvRLMUAzNRSSsAqjIGuVf68v5Sky89JI5QCl94IwX7fxc 9kyakh0dGi2ebH4WtRdbH4jSZnsTnO3Wx4QHJpl34idRoRMtXUDAXmRLurqp9umoiEmt lTQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KRszzhu9nJBzA3VvRFpCp3EQFCxBl8hUI0U9MNhu6xM=; fh=QQvtjDaAlLft5IR2jnjma4lVp8TaaKU12WD0fWdFifQ=; b=f0DCWt2Ff748ooXO3YSanVMv94lJhKfonnv6WJpPUFMWq/ntpLVR1M+wQzzwTIupnF f5F+3Qw1Sezk5PCI7WERTsy/V8zgkY527PDXehGDMfzlF8sffDWMBDXSeA/tM77cMyuP L2/FXzGRcIxfoGciFWdFiN9d/2+ZEMDcVsGUi1dLcSnWeuXpUXZPY/tuyOVMJa9eyxI8 tEE1s3NilxjwHFvzVjsD9fQr1t3jKWKgxPB5E2kq/eVlXoWUmfMW71X3JN/I3S3X8nct TxpDIM5k/O17BmDRZfxah7cjnFOGziVFM1rLjSv5N4qQZy7UxpHkxWXC/4z+FMDsMNM8 ygOg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=DWrlJbbD; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-485885dd96fsi36548250f8f.391.2026.09.09.14.35.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 14:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=DWrlJbbD; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=KRszzhu9nJBzA3VvRFpCp3EQFCxBl8hUI0U9MNhu6xM=; b=DWrlJbbD4p6Z mXhD/HRj3Gw/h59Uh4GcT+avv2wu1SIXRWkajJv4zyhKgs0roby5PoGPzGYRsgTSLbOHeCIYArbxd rN8IMLeyVSW1lJhXqMIgLSww83DQe9kVEsGqOXjCxxuvfC6dijfY9haWCYHTlhYoN94SkoX3ZbnJZ StQExfDAHLXCCFsbzICOgOVLMU+z4Uy1CNh7aBU/UTEOg/72JVmtzeoZoW2Vbnd/B7RtvPbqA8+gs UQcJ1MB7o60tIoHPhTo0XED2zBKV5H4eEhhVaN2ua0Vff4P3uv6vJJoo3tLQCF35YgQ0uF9SconeD ESE7yNkxV4A0h/q14b0fZw==; Received: from [130.117.225.5] (helo=dev012.aci.vzint.dev) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x4Pug-00DVmc-0c; Wed, 09 Sep 2026 23:35:41 +0200 From: Vladimir Riabchun To: devel@openvz.org Date: Wed, 9 Sep 2026 21:35:26 +0000 Message-ID: <1192cb6b90315be4aea86501a203310202147ee2.1788989664.git.vladimir.riabchun@virtuozzo.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 X-OZ-Fwd: true Subject: [Devel] [PATCH VZ10 v8 4/7] ve: Move from global VE mounts limit to per-VE limit X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org This change unifies mount limit handling with other VE limits. This will simplify refactoring later and allow more precise limits control from one place. https://virtuozzo.atlassian.net/browse/VSTOR-135520 Feature: per-ve failcounters Signed-off-by: Vladimir Riabchun --- include/linux/ve.h | 9 +++-- kernel/ve/ve.c | 34 ++++++++++++++++++- kernel/ve/veowner.c | 19 ----------- tools/testing/selftests/ve/ve_ns_owner_test.c | 6 +++- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/include/linux/ve.h b/include/linux/ve.h index 65c058c0f34d..fabc608e31f5 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -96,7 +96,13 @@ struct ve_struct { atomic_t nd_neigh_nr; unsigned long meminfo_val; + /* + * Operations with a big amount of mount points can require a lot of time. + * These operations take the global lock namespace_sem, so they can affect + * other containers. + */ atomic_t mnt_avail_nr; /* number of available VE mounts */ + int mnt_max_nr; #ifdef CONFIG_COREDUMP char core_pattern[CORENAME_MAX_SIZE]; @@ -143,8 +149,7 @@ extern int nr_ve; #define NETNS_MAX_NR_DEFAULT 256 /* number of net-namespaces per-VE */ #define NETIF_MAX_NR_DEFAULT 256 /* number of net-interfaces per-VE */ #define BPF_PROG_MAX_NR_DEFAULT 256 /* number of loaded BPF progs per-VE */ - -extern unsigned int sysctl_ve_mount_nr; +#define MNT_MAX_NR_DEFAULT 4096 /* number of mounts per-VE */ #ifdef CONFIG_VE static inline void ve_set_state(struct ve_struct *ve, int new_state) diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c index 58a0c4b8e36e..a33e55991e52 100644 --- a/kernel/ve/ve.c +++ b/kernel/ve/ve.c @@ -83,6 +83,7 @@ struct ve_struct ve0 = { .arp_neigh_nr = ATOMIC_INIT(0), .nd_neigh_nr = ATOMIC_INIT(0), .mnt_avail_nr = ATOMIC_INIT(INT_MAX), + .mnt_max_nr = INT_MAX, .meminfo_val = VE_MEMINFO_SYSTEM, #ifdef CONFIG_X86 .umh_running_helpers = ATOMIC_INIT(0), @@ -787,7 +788,8 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_ atomic_set(&ve->arp_neigh_nr, 0); atomic_set(&ve->nd_neigh_nr, 0); - atomic_set(&ve->mnt_avail_nr, sysctl_ve_mount_nr); + ve->mnt_max_nr = MNT_MAX_NR_DEFAULT; + atomic_set(&ve->mnt_avail_nr, MNT_MAX_NR_DEFAULT); #ifdef CONFIG_COREDUMP strcpy(ve->core_pattern, "core"); @@ -1068,6 +1070,30 @@ static s64 ve_mnt_avail_nr_read(struct cgroup_subsys_state *css, struct cftype * return atomic_read(&css_to_ve(css)->mnt_avail_nr); } +static u64 ve_mnt_max_nr_read(struct cgroup_subsys_state *css, struct cftype *cft) +{ + return css_to_ve(css)->mnt_max_nr; +} + +static int ve_mnt_max_nr_write(struct cgroup_subsys_state *css, struct cftype *cft, u64 val) +{ + struct ve_struct *ve = css_to_ve(css); + int delta; + + if (!ve_is_super(get_exec_env())) + return -EPERM; + + if (val > INT_MAX) + return -EOVERFLOW; + + down_write(&ve->op_sem); + delta = val - ve->mnt_max_nr; + ve->mnt_max_nr = val; + atomic_add(delta, &ve->mnt_avail_nr); + up_write(&ve->op_sem); + return 0; +} + static u64 ve_netif_max_nr_read(struct cgroup_subsys_state *css, struct cftype *cft) { return css_to_ve(css)->netif_max_nr; @@ -1630,6 +1656,12 @@ static struct cftype ve_cftypes[] = { .name = "mnt_avail_nr", .read_s64 = ve_mnt_avail_nr_read, }, + { + .name = "mnt_max_nr", + .flags = CFTYPE_NOT_ON_ROOT, + .read_u64 = ve_mnt_max_nr_read, + .write_u64 = ve_mnt_max_nr_write, + }, { .name = "netif_max_nr", .flags = CFTYPE_NOT_ON_ROOT, diff --git a/kernel/ve/veowner.c b/kernel/ve/veowner.c index 1e631baf0de9..c77735f8c035 100644 --- a/kernel/ve/veowner.c +++ b/kernel/ve/veowner.c @@ -48,26 +48,7 @@ static void prepare_proc(void) * ------------------------------------------------------------------------ */ -/* - * Operations with a big amount of mount points can require a lot of time. - * These operations take the global lock namespace_sem, so they can affect - * other containers. Let us allow no more than sysctl_ve_mount_nr mount - * points for a VE. - */ -unsigned int sysctl_ve_mount_nr = 4096; -static int ve_mount_nr_min = 0; -static int ve_mount_nr_max = INT_MAX; - static struct ctl_table vz_fs_table[] = { - { - .procname = "ve-mount-nr", - .data = &sysctl_ve_mount_nr, - .maxlen = sizeof(sysctl_ve_mount_nr), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = &ve_mount_nr_min, - .extra2 = &ve_mount_nr_max, - }, { .procname = "fsync-enable", .data = &ve0.fsync_enable, diff --git a/tools/testing/selftests/ve/ve_ns_owner_test.c b/tools/testing/selftests/ve/ve_ns_owner_test.c index c3fa7d7b7f9c..dcff4d54172d 100644 --- a/tools/testing/selftests/ve/ve_ns_owner_test.c +++ b/tools/testing/selftests/ve/ve_ns_owner_test.c @@ -50,7 +50,7 @@ * any spurious accounting against the parent ve would overflow it. */ #define VE_NETNS_MAX 3 -#define VE_MOUNTS_MAX 4096 +#define VE_MOUNTS_MAX 32 /* * Synchronisation across the clone() boundary: child does its setup, @@ -173,6 +173,10 @@ FIXTURE_SETUP(ve_ns_owner) snprintf(val, sizeof(val), "%d", VE_NETNS_MAX); ASSERT_EQ(write_file_at(self->cgv2_fd, path, val), 0); + snprintf(path, sizeof(path), "%d/ve.mnt_max_nr", self->ctid); + snprintf(val, sizeof(val), "%d", VE_MOUNTS_MAX); + ASSERT_EQ(write_file_at(self->cgv2_fd, path, val), 0); + /* * The new ve cgroup has not been entered by anything yet, so its * mnt_avail_nr counter should be VE_MOUNTS_MAX. Each test below -- 2.47.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel