Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/ve: ve_ring_nr() hides run_in_ve() failures behind a
  ring size of 0
- [Low] selftests/ve: sysconf(_SC_NPROCESSORS_CONF) used instead of
  possible CPU mask
--

commit f6695923b52cdf1c2c82b7a1c344e0b1de81f04b
Author: Pavel Tikhomirov <[email protected]>

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

This adds a selftest that checks that the host and a VE keep the CPU heuristic 
of the io_setup() ring and that a pseudosuper VE skips it. It also checks 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..1922a05aceef
> --- /dev/null
> +++ b/tools/testing/selftests/ve/ve_aio_ring_test.c

[ ... ]

> +/* The ring capacity io_setup(@nr_events) makes in the VE, or 0. */
> +static unsigned int ve_ring_nr(FIXTURE_DATA(ve_aio_ring) * self,
> +                            unsigned int nr_events)
> +{
> +     self->arg->nr_events = nr_events;
> +     self->arg->ring_nr = 0;
> +     if (run_in_ve(self->cgv2_fd, self->ctid, &self->ns_ctx, CLONE_NEWVE,
> +                   aio_ring_nr, self->arg))
> +             return 0;
> +     return self->arg->ring_nr;
> +}

[Severity: Low]
Does this hide run_in_ve() failures behind a ring size of 0? If the fork, the 
cgroup enter or the setns fails, or aio_ring_nr() itself fails, the callers 
only see 0. ve_keeps_cpu_heuristic and the pseudosuper tests then report 
"expected N, got 0" as a failure of the behaviour under test instead of an 
environment error. Could the failure be reported separately, for example by 
returning an error code and having the callers ASSERT on it?

[ ... ]

> +FIXTURE_SETUP(ve_aio_ring)
> +{
> +     long cpus;
> +     int ret;
> +
> +     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;
> +     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);

[Severity: Low]
Does sysconf(_SC_NPROCESSORS_CONF) give the number of possible CPUs that 
ring_nr() needs? The kernel sizes the ring in ioctx_alloc() with 
num_possible_cpus(). As far as I can tell, libc derives the configured count 
from the cpuN sysfs entries. The generic cpu_dev_register_generic() registers 
those only for present CPUs.

On a VM with hotplug slots, or with possible_cpus= or nr_cpus= set, possible 
CPUs can outnumber the cpuN entries. Then the expected ring sizes are wrong, 
and host_keeps_cpu_heuristic and ve_keeps_cpu_heuristic fail spuriously. The 
skip check can also wrongly skip the pseudosuper tests.

The file header and the skip message both say "possible CPUs". Would it be 
better to read /sys/devices/system/cpu/possible instead?

-- 
Sashiko AI review ยท 
https://sashiko.vzint.dev/#/patchset/20261116-pr-ptikhomirov-vstor-154129-aio-pseudosuper-ring-v2-0-532d149b4...@virtuozzo.com?part=2

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to