Virtuozzo QEMU development (svt-core@virtuozzo.com)
 help / color / mirror / Atom feed
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 v2 1/2] vhost-blk: create kernel threads with the mainstream worker ioctls
Date: Tue, 27 Oct 2026 14:05:10 +0100	[thread overview]
Message-ID: <892b5863-b9ba-45d3-b170-05235ff1189e@virtuozzo.com> (raw)
In-Reply-To: <010701a17d6b8c66-fa71b243-6c44-4564-80b3-75bfebb1f4ec-000000@eu-central-1.amazonses.com>

>> @@ -51,15 +97,37 @@ static int vhost_blk_start(VirtIODevice *vdev)
>>           return 0;
>>       }
>>   
>> +    nworkers = MIN(s->conf.num_threads, s->dev.nvqs);
>> +    if (nworkers > 1) {
> [Severity: Low]
> This isn't a crash, but the new code changes how num-threads=0 and values
> above the queue count are handled. Is that intended?
>
> Before this patch, vhost_blk_start() passed nworkers to VHOST_SET_NWORKERS
> whenever it was not 1. A value of 0 was therefore passed to the kernel,
> and as far as I can tell start failed with "unable to set number of kernel
> threads". I could not check how the kernel handled 0.
>
> Now nworkers = MIN(num_threads, nvqs) evaluates to 0 for num-threads=0, so
> "nworkers > 1" is false. The device starts silently with a single kernel
> thread, as if num-threads=1 had been given.
>
> The same happens when num-threads is larger than the number of queues. The
> count is clamped to nvqs and no diagnostic is printed.
>
> The num-threads property is DEFINE_PROP_UINT16 with a default of 1, and
> vhost_blk_device_realize() only validates num_queues. Nothing checks
> num_threads there either.
>
> Should realize reject num-threads=0, and should it warn or fail when
> num-threads exceeds num-queues?
This matches the old behaviour. The kernel's VHOST_SET_NWORKERS handler
clamped n to nvqs and, for n=0, created no extra workers and returned
success, so num-threads=0 already ran a single thread and values above
num-queues were already clamped silently. The patch keeps those semantics.
Rejecting num-threads=0 in realize would break configurations that work
today, so I'd leave validation out of this series.

  reply	other threads:[~2026-10-27 13:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 12:47 [PATCH hci-8.1 v2 0/2] vhost-blk: switch from VHOST_SET_NWORKERS to " Alexander Ivanov
2026-10-27 12:47 ` [PATCH hci-8.1 v2 1/2] vhost-blk: create kernel threads with " Alexander Ivanov
2026-10-27 12:52   ` no-reply
2026-10-27 13:05     ` Alexander Ivanov [this message]
2026-10-27 14:22   ` Andrey Drobyshev
2026-10-28 11:48     ` Alexander Ivanov
2026-10-27 12:47 ` [PATCH hci-8.1 v2 2/2] linux-headers: drop VHOST_SET_NWORKERS Alexander Ivanov
2026-10-27 12:50   ` no-reply
2026-10-27 14:22   ` 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=892b5863-b9ba-45d3-b170-05235ff1189e@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox