OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
	Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 2/2] selftests/ve: check the AIO ring size in a pseudosuper VE
Date: Fri, 13 Nov 2026 15:15:43 +0000	[thread overview]
Message-ID: <010701a1d57a960c-3fd97beb-150d-485c-afaf-f50c123010f1-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261113-pr-ptikhomirov-vstor-154129-aio-pseudosuper-ring-v1-2-7d35d143fdc3@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] selftests/ve: cgroup2 mount fd leaked on early FIXTURE_SETUP
  failure
- [Low] selftests/ve: VE cgroup left behind when FIXTURE_SETUP fails
  after make_ve()
- [Low] selftests/ve: test models possible CPUs with
  sysconf(_SC_NPROCESSORS_CONF)
--

commit 5c946723cd7135b742e593bb7b560ea1869bd370
Author: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>

selftests/ve: check the AIO ring size in a pseudosuper VE

This adds a selftest, ve_aio_ring_test, that checks the io_setup() ring size on the host, in a VE, and in a pseudosuper VE. It checks that the host and a VE keep the CPU heuristic, that a pseudosuper VE skips it, and that io_setup((nr - 2) / 2) in a pseudosuper VE gives a ring of nr events for rings of 1 to 4 pages.

> diff --git a/tools/testing/selftests/ve/ve_aio_ring_test.c b/tools/testing/selftests/ve/ve_aio_ring_test.c
> new file mode 100644
> index 000000000000..c37094157422
> --- /dev/null
> +++ b/tools/testing/selftests/ve/ve_aio_ring_test.c

[ ... ]

> +FIXTURE_SETUP(ve_aio_ring)
> +{
> +	long cpus;
> +
> +	self->ctid = -1;
> +	self->arg = MAP_FAILED;
> +
> +	self->page_size = sysconf(_SC_PAGESIZE);
> +	cpus = sysconf(_SC_NPROCESSORS_CONF);
> +	ASSERT_GT(cpus, 0);
> +	self->cpus = cpus;

[Severity: Low]
Does sysconf(_SC_NPROCESSORS_CONF) really give the number of possible CPUs that ring_nr() needs? The comments and the skip message call it "possible CPUs", and ioctx_alloc() uses num_possible_cpus().

As far as I can tell, glibc derives this value from the cpuN entries under /sys/devices/system/cpu. Those are registered only for present CPUs (see cpu_dev_register_generic()). On a VM or host with possible-but-not-present CPUs, such as hot-pluggable vCPUs or possible_cpus= on the command line, the count can be lower than num_possible_cpus(). The expected ring sizes then no longer match the kernel's, so the test fails spuriously, or the skip check wrongly skips the pseudosuper checks.

Would parsing /sys/devices/system/cpu/possible be more reliable?

> +	if (ring_nr(self, 1) == ring_nr_pseudosuper(self, 1))
> +		SKIP(return, "%u possible CPUs are too few for the CPU heuristic to matter",
> +		     self->cpus);
> +
> +	self->arg = mmap(NULL, sizeof(*self->arg), PROT_READ | PROT_WRITE,
> +			 MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> +	ASSERT_NE(self->arg, MAP_FAILED);
> +
> +	self->cgv2_fd = mount_cg2_fd();
> +	ASSERT_GE(self->cgv2_fd, 0);
> +
> +	ASSERT_EQ(write_file_at(self->cgv2_fd, "cgroup.subtree_control",
> +				VE_CONTROLLERS), 0);
> +
> +	self->ctid = make_ve(self->cgv2_fd, CTID_MIN);
> +	ASSERT_GE(self->ctid, 0);

[Severity: Low]
Does this leak the cgroup2 fd when one of these ASSERTs fails? If write_file_at() or make_ve() fails after mount_cg2_fd() succeeded, ctid is still -1. FIXTURE_TEARDOWN() then skips close(self->cgv2_fd), because the close sits under "if (self->ctid >= 0)". The harness also does not run teardown at all when setup does not complete, so the fd stays open either way. The impact is small, since the test process exits soon afterwards.

> +
> +	ASSERT_EQ(prepare_namespaces(&self->ns_ctx, CLONE_NEWVE,
> +				     self->cgv2_fd, self->ctid), 0);
> +}

[Severity: Low]
Is the VE left behind if prepare_namespaces() fails? make_ve() has already created the VE cgroup by then. The harness runs FIXTURE_TEARDOWN() only if setup completed, so destroy_ve() never runs. The CTID then stays in the cgroup2 hierarchy, and later runs find it already taken.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261113-pr-ptikhomirov-vstor-154129-aio-pseudosuper-ring-v1-0-7d35d143fdc3@virtuozzo.com?part=2

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

  reply	other threads:[~2026-11-13 15:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 15:08 [Devel] [PATCH hci-8.1 0/2] fs/aio: fix CT migration with AIO to a node with more CPUs Pavel Tikhomirov
2026-11-13 15:08 ` [Devel] [PATCH hci-8.1 1/2] fs/aio: restore the AIO ring of the dumped size in a pseudosuper VE Pavel Tikhomirov
2026-11-13 15:14   ` no-reply
2026-11-13 19:41   ` Konstantin Khorenko
2026-11-13 15:08 ` [Devel] [PATCH hci-8.1 2/2] selftests/ve: check the AIO ring " Pavel Tikhomirov
2026-11-13 15:15   ` no-reply [this message]
2026-11-13 19:41   ` Konstantin Khorenko
2026-11-13 19:41 ` [Devel] [PATCH hci-8.1 0/2] fs/aio: fix CT migration with AIO to a node with more CPUs Konstantin Khorenko
2026-11-16 10:33   ` Pavel Tikhomirov
2026-11-16 10:35     ` Pavel Tikhomirov
2026-11-16 10:35   ` Pavel Tikhomirov

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=010701a1d57a960c-3fd97beb-150d-485c-afaf-f50c123010f1-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=ptikhomirov@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox