From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v3 0/2] sched: Fix incorrect nproc report inside CT
Date: Thu, 12 Nov 2026 19:37:40 +0100 [thread overview]
Message-ID: <179450866043.4060562.7827272878398907108.b4-review@b4> (raw)
In-Reply-To: <20261029-ct-invalid-nrpoc-v3-0-89d4b0b7d520@virtuozzo.com>
I won't apply this version, please send v4 with the changes below.
On Thu, 29 Oct 2026 11:16:05 +0100, Vladimir Riabchun <vladimir.riabchun@virtuozzo.com> wrote:
> nproc code uses sched_getaffinity syscall under the hood[1].
> It appears that this syscall returned complete nonsence when
> called from VE - we ignored both num_online_vcpus and
> cgroup cpuset limitations.
The code of patch 1 is right. What to change for v4:
1. Patch 1: add a Fixes tag for 87211cbff4b4 ("sched: Return only
virtual cpus in sched_getaffinity()") and the Feature line of that
commit, "sched: virtualize CT cpu affinity management".
2. Patch 1: fix the message. bitmap_fill() fills whole unsigned
longs, not integers. Say what a CT sees now: the first
min(vCPUs, CPUs of its cpuset) bits, with the vCPU limit of the
target task. nproc can then be lower than /proc/cpuinfo and
/sys/devices/system/cpu/online, say that this is intended.
3. Patch 1: the code comment says setaffinity is "not available"
inside a CT. sched_setaffinity() returns 0 there and does nothing,
write that.
4. Patch 2: loop to CPU_SETSIZE in get_nth_cpu().
5. Patch 2: include <sys/mman.h>, as you promised in the v2 reply,
and add a Feature: line.
6. Cover letter:
- The old code did use num_online_vcpus(), the bug was the
rounding. Ignoring the cpuset was the design of 87211cbff4b4.
- "64 no matter what" holds up to 64 vCPUs, above that it was 128.
- Typos: "nonsence", "insted".
- Link [1] points at a line of gnulib master, which will drift.
Name the function instead.
Separate patches, not needed for this series; I created a task for
it:
1. task_nr_cpus() reads nr_cpus of the task's own cpu cgroup, while
vzctl --cpus sets it on the CT root cgroup only. In a nested cpu
cgroup inside a CT (docker in a CT, a systemd unit with CPUQuota=)
nproc, /proc/cpuinfo and the sysfs cpu lists show the host CPU
count. tg_nr_cpus() in cpuacct.c already goes through
ve_root_tg(), task_nr_cpus() should do the same.
https://virtuozzo.atlassian.net/browse/VSTOR-154938
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
prev parent reply other threads:[~2026-11-12 18:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 10:16 Vladimir Riabchun
2026-10-29 10:16 ` [Devel] [PATCH hci-8.1 v3 1/2] sched: Fix sched_getaffinity syscall Vladimir Riabchun
2026-10-29 10:21 ` no-reply
2026-10-29 10:48 ` Vladimir Riabchun
2026-11-12 18:37 ` Konstantin Khorenko
2026-10-29 10:16 ` [Devel] [PATCH hci-8.1 v3 2/2] selftests: ve: Test sched_getaffinity in VE Vladimir Riabchun
2026-10-29 10:22 ` no-reply
2026-10-29 10:50 ` Vladimir Riabchun
2026-11-12 18:37 ` Konstantin Khorenko
2026-11-12 18:37 ` Konstantin Khorenko [this message]
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=179450866043.4060562.7827272878398907108.b4-review@b4 \
--to=khorenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=vladimir.riabchun@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