OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2] Revert "drivers/vhost: add ioctl to increase the number of workers"
Date: Thu, 26 Nov 2026 09:16:46 +0100	[thread overview]
Message-ID: <20261126081646.863702-1-alexander.ivanov@virtuozzo.com> (raw)

This reverts commit 705a4b3eefde336713aaa0b84b1b74e69dcdef30.

VHOST_SET_NWORKERS was a stopgap to run our userspace on the rh10
kernel unchanged. Userspace should use the mainstream worker ioctls
(VHOST_NEW_WORKER, VHOST_ATTACH_VRING_WORKER etc.) instead.

The 0x1F ioctl number is freed: VHOST_SET_NWORKERS now fails with
-ENOTTY. A QEMU that still issues it fails to start vhost-blk with
num-threads other than 1 and the guest hangs, so QEMU has to move to
the worker ioctls ("vhost-blk: create kernel threads with the
mainstream worker ioctls" in QEMU) before this kernel ships.

https://virtuozzo.atlassian.net/browse/VSTOR-107537
Feature: vhost-blk: in-kernel accelerator for virtio-blk guests

Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
 drivers/vhost/vhost.c      | 57 +-------------------------------------
 drivers/vhost/vhost.h      |  1 -
 include/uapi/linux/vhost.h |  8 ------
 3 files changed, 1 insertion(+), 65 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 422cac6f2298..56c0ecbb8352 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -605,8 +605,6 @@ void vhost_dev_init(struct vhost_dev *dev,
 	spin_lock_init(&dev->iotlb_lock);
 	xa_init_flags(&dev->worker_xa, XA_FLAGS_ALLOC);
 
-	dev->workers_set = false;
-
 	for (i = 0; i < dev->nvqs; ++i) {
 		vq = dev->vqs[i];
 		vq->log = NULL;
@@ -1089,47 +1087,6 @@ long vhost_worker_ioctl(struct vhost_dev *dev, unsigned int ioctl,
 }
 EXPORT_SYMBOL_GPL(vhost_worker_ioctl);
 
-static void vhost_propagate_workers(struct vhost_dev *dev, int nworkers)
-{
-	int i, j = 0;
-
-	for (i = nworkers; i < dev->nvqs; i++) {
-		struct vhost_worker *worker;
-
-		worker = rcu_dereference_check(dev->vqs[j]->worker,
-					       lockdep_is_held(&dev->mutex));
-		if (worker)
-			__vhost_vq_attach_worker(dev->vqs[i], worker);
-		if (++j >= nworkers)
-			j = 0;
-	}
-}
-
-
-static int vhost_set_workers(struct vhost_dev *dev, int n)
-{
-	struct vhost_worker *worker;
-	int i, ret = 0;
-
-	if (n > dev->nvqs)
-		n = dev->nvqs;
-
-	dev->workers_set = true;
-
-	for (i = 1; i < n; i++) {
-		worker = vhost_worker_create(dev);
-		if (!worker) {
-			ret = -ENOMEM;
-			break;
-		}
-		__vhost_vq_attach_worker(dev->vqs[i], worker);
-	}
-
-	vhost_propagate_workers(dev, i);
-
-	return ret;
-}
-
 /* Caller should have device mutex */
 long vhost_dev_set_owner(struct vhost_dev *dev)
 {
@@ -1264,7 +1221,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
 	wake_up_interruptible_poll(&dev->wait, EPOLLIN | EPOLLRDNORM);
 	vhost_workers_free(dev);
 	vhost_detach_mm(dev);
-	dev->workers_set = false;
 }
 EXPORT_SYMBOL_GPL(vhost_dev_cleanup);
 
@@ -2350,7 +2306,7 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
 	struct eventfd_ctx *ctx;
 	u64 p;
 	long r;
-	int i, fd, n;
+	int i, fd;
 
 	/* If you are not the owner, you can become one */
 	if (ioctl == VHOST_SET_OWNER) {
@@ -2446,17 +2402,6 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
 		if (ctx)
 			eventfd_ctx_put(ctx);
 		break;
-	case VHOST_SET_NWORKERS:
-		r = get_user(n, (int __user *)argp);
-		if (r < 0)
-			break;
-		if (!d->use_worker || d->workers_set) {
-			r = -EINVAL;
-			break;
-		}
-
-		r = vhost_set_workers(d, n);
-		break;
 	default:
 		r = -ENOIOCTLCMD;
 		break;
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 37ade2f1cb7d..077fa4d0cf36 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -198,7 +198,6 @@ struct vhost_dev {
 	 * The default value is set by fork_from_owner_default
 	 */
 	bool fork_owner;
-	bool workers_set;
 	int (*msg_handler)(struct vhost_dev *dev, u32 asid,
 			   struct vhost_iotlb_msg *msg);
 };
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index 5553522fbf48..4371703948b9 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -102,14 +102,6 @@
 #define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16,		\
 				     struct vhost_vring_worker)
 
-/* Set number of vhost workers.
- * This can be done only once until reset.
- * All workers are freed upon reset.
- * If the value is too big it is silently truncated to the maximum number of
- * supported vhost workers
- */
-#define VHOST_SET_NWORKERS _IOW(VHOST_VIRTIO, 0x1F, int)
-
 /* The following ioctls use eventfd file descriptors to signal and poll
  * for events. */
 
-- 
2.53.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

             reply	other threads:[~2026-11-26  8:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:16 Alexander Ivanov [this message]
2026-11-26 11:34 ` Andrey Zhadchenko
2026-11-30 15:30 ` Konstantin Khorenko
2026-11-30 15:41   ` Konstantin Khorenko
2026-11-30 15:45 ` Konstantin Khorenko

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=20261126081646.863702-1-alexander.ivanov@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.org \
    /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