From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: no-reply@sashiko.virtuozzo.com, andrey.zhadchenko@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, svt-core@virtuozzo.com
Subject: Re: [PATCH hci-8.1 v6 6/7] vhost-blk: create kernel threads with the mainstream worker ioctls
Date: Wed, 18 Nov 2026 11:31:13 +0100 [thread overview]
Message-ID: <0ec6cd65-d1b8-489e-88bb-d523b4ebffc1@virtuozzo.com> (raw)
In-Reply-To: <010701a1ea9f47c8-3aaae176-4d7e-4af5-a213-91567ef96db8-000000@eu-central-1.amazonses.com>
>> @@ -52,16 +96,25 @@ static int vhost_blk_start(VirtIODevice *vdev)
>> return 0;
>> }
>>
>> + ret = hdev->vhost_ops->vhost_set_fork_from_owner(hdev,
>> + VHOST_FORK_OWNER_TASK);
>> + if (ret < 0 && ret != -ENOTTY) {
>> + error_report("vhost-blk: unable to set vhost_task mode: %s",
>> + strerror(-ret));
>> + return ret;
>> + }
> [Severity: Medium]
> As reported by no-reply@sashiko.virtuozzo.com on v3 [1], can this abort device start on an older kernel that lacks VHOST_SET_FORK_FROM_OWNER? The call is now unconditional, so it also hits num-threads=1, which worked before the patch.
>
> The in-tree comment in vhost_kernel_set_features() says an unknown vhost ioctl most likely does not return ENOTTY, because the kernel treats the argument as a virtio queue id. vhost_kernel_set_fork_from_owner() returns the raw -errno from the same vhost_kernel_call() path. Before VHOST_SET_OWNER, an unknown ioctl would more likely fail with -EPERM or -ENOBUFS. Neither is -ENOTTY, so the check against it never matches. Would it be safer to ignore any error from this call when nworkers is 1, and fail only when nworkers > 1?
Fixed.
>> - nworkers = s->conf.num_threads;
>> - if (nworkers != 1 && ioctl(s->vhostfd, VHOST_SET_NWORKERS, &nworkers)) {
>> - error_report("vhost-blk: unable to set number of kernel threads");
>> - ret = -EINVAL;
>> - goto err_reset_owner;
>> + nworkers = MIN(s->conf.num_threads, hdev->nvqs);
>> + if (nworkers > 1) {
> [Severity: Low]
> As reported by no-reply@sashiko.virtuozzo.com on v1 [2], does this silently run fewer threads than requested? num-threads=0 becomes one default worker, and a value above the number of queues is clamped to nvqs. Neither case produces a diagnostic. The old code passed any value other than 1 to the kernel. The commit message also says to fail rather than silently run on fewer threads than requested. Should realize reject these values, or should this code report them?
Added this note:
num-threads of 0 still means one thread and a value above num-queues is
clamped to it,
as VHOST_SET_NWORKERS did.
>
> [1] https://lore.kernel.org/r/010701a182850602-e5cbb570-ea26-4d45-8aed-14cb710088ba-000000@eu-central-1.amazonses.com
> [2] https://lore.kernel.org/r/010701a17d2bfd69-07c611d4-bf3a-47f3-9970-bc829fc0ef42-000000@eu-central-1.amazonses.com
>
next prev parent reply other threads:[~2026-11-18 10:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 17:37 [PATCH hci-8.1 v6 0/7] vhost-blk: switch from VHOST_SET_NWORKERS to " Alexander Ivanov
2026-11-17 17:37 ` [PATCH hci-8.1 v6 1/7] vhost-backend: add vhost_set_fork_from_owner op Alexander Ivanov
2026-11-17 17:39 ` no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 2/7] vhost-blk: reject num-queues above VHOST_BLK_MAX_QUEUES Alexander Ivanov
2026-11-17 17:40 ` no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 3/7] vhost-blk: use a local vhost_dev pointer in start and stop Alexander Ivanov
2026-11-17 17:41 ` no-reply
2026-11-18 10:20 ` Alexander Ivanov
2026-11-19 16:32 ` Andrey Drobyshev
2026-11-17 17:37 ` [PATCH hci-8.1 v6 4/7] vhost-blk: fix vhost_blk_start() returning 0 on failure Alexander Ivanov
2026-11-17 17:42 ` no-reply
2026-11-19 16:32 ` Andrey Drobyshev
2026-11-17 17:37 ` [PATCH hci-8.1 v6 5/7] vhost-blk: reset the owner when vhost_blk_start() fails Alexander Ivanov
2026-11-17 17:43 ` no-reply
2026-11-19 16:32 ` Andrey Drobyshev
2026-11-17 17:37 ` [PATCH hci-8.1 v6 6/7] vhost-blk: create kernel threads with the mainstream worker ioctls Alexander Ivanov
2026-11-17 17:47 ` no-reply
2026-11-18 10:31 ` Alexander Ivanov [this message]
2026-11-19 16:32 ` Andrey Drobyshev
2026-11-17 17:37 ` [PATCH hci-8.1 v6 7/7] linux-headers: drop VHOST_SET_NWORKERS Alexander Ivanov
2026-11-17 17:49 ` no-reply
2026-11-19 16:32 ` Andrey Drobyshev
2026-11-18 11:32 ` [PATCH hci-8.1 v6 0/7] vhost-blk: switch from VHOST_SET_NWORKERS to the mainstream worker ioctls Andrey Zhadchenko
2026-11-19 16:35 ` Andrey Drobyshev
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=0ec6cd65-d1b8-489e-88bb-d523b4ebffc1@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=no-reply@sashiko.virtuozzo.com \
--cc=svt-core@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.