All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@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: Tue, 17 Nov 2026 17:47:49 +0000	[thread overview]
Message-ID: <010701a1ea9f47c8-3aaae176-4d7e-4af5-a213-91567ef96db8-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261117173734.3225443-7-alexander.ivanov@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] vhost-blk: only -ENOTTY tolerated from
  VHOST_SET_FORK_FROM_OWNER on old kernels
- [Low] vhost-blk: num-threads 0 or above nvqs silently runs fewer
  threads than asked
--

commit 5a199dd1e71178edbd183c4cb5040003c105bf45
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>

vhost-blk: create kernel threads with the mainstream worker ioctls

This commit replaces the VHOST_SET_NWORKERS ioctl with VHOST_NEW_WORKER and VHOST_ATTACH_VRING_WORKER. It spreads the virtqueues round-robin over num-threads kernel threads. It also switches the device to vhost_task mode with VHOST_SET_FORK_FROM_OWNER before VHOST_SET_OWNER.

> diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
> index c817d0e3edfe..c9c7d2d0feed 100644
> --- a/hw/block/vhost-blk.c
> +++ b/hw/block/vhost-blk.c

[ ... ]

> @@ -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?

> -    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?

[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

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117173734.3225443-1-alexander.ivanov@virtuozzo.com?part=6

  reply	other threads:[~2026-11-17 17:47 UTC|newest]

Thread overview: 15+ 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-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-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-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 [this message]
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

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=010701a1ea9f47c8-3aaae176-4d7e-4af5-a213-91567ef96db8-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=andrey.zhadchenko@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.