From nobody Mon Feb 9 18:01:23 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E27BD256C90 for ; Mon, 21 Apr 2025 02:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745203518; cv=none; b=EaFetOGD/6PlvRlBzpTUerOIT9Ksk21xOKvq43Xl4RE0pTJ2/CDf6as2yIG0nQVvCwyJYARFD6uxCloJj5D/zGv4zvCShGwtbAqXuWM/vkekACUpXMiPd1+jKZfS+uXXEKEZQ5BFLGXcytJqhXaJ46MOBnDjwPSAF1CLyGgkemU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745203518; c=relaxed/simple; bh=sumMjmwZxo0qJvhw7S8ltFSvno0RZA0jV5PI4oksXXk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eGNBLlNESDSTf/cGugQETWm69zq04AQOs/yYYGprIOOSr+MhZMMwBreLlBPdvQ+6Vfdbzipg/OJArXIpSWVb0yGzYN4XQ5JQNwK+jGlujEMc2bGAICyNPxNmWBvaIdltVsu4HxZM1odIiludQHIF/8b5HxNEVijrydPssoROMeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ir7QOPOC; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ir7QOPOC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745203514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NrTRtJXNWtpYPwMS+KZwGlCYM9RXuubPsDXsJSdgeYg=; b=ir7QOPOCR59SAvvCL7vuyeafrM4sWUhK8VsvC2bywGbjqJFyxkwn9amw4IZbOw9AGtTNFy IobDVbTmOcF31dcIHOc6f0oVZeybFt6NPw+CTjHaj6k4jh50quAy+/Cp4CZPkcHfYhYEOe GVlcOCCoD2awp2Oq0KnnpkwygLEQvpc= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-495-9UGXHUVXNde3xXFfbvUM-Q-1; Sun, 20 Apr 2025 22:45:11 -0400 X-MC-Unique: 9UGXHUVXNde3xXFfbvUM-Q-1 X-Mimecast-MFC-AGG-ID: 9UGXHUVXNde3xXFfbvUM-Q_1745203510 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 480301800570; Mon, 21 Apr 2025 02:45:10 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.29]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 33922180175B; Mon, 21 Apr 2025 02:45:05 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, michael.christie@oracle.com, sgarzare@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH v9 1/4] vhost: Add a new parameter in vhost_dev to allow user select kthread Date: Mon, 21 Apr 2025 10:44:07 +0800 Message-ID: <20250421024457.112163-2-lulu@redhat.com> In-Reply-To: <20250421024457.112163-1-lulu@redhat.com> References: <20250421024457.112163-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" The vhost now uses vhost_task and workers as a child of the owner thread. While this aligns with containerization principles, it confuses some legacy userspace applications, therefore, we are reintroducing kthread API support. Introduce a new parameter to enable users to choose between kthread and task mode. By default, this parameter is set to true, so the default behavior remains unchanged by this patch. Signed-off-by: Cindy Lu Acked-by: Jason Wang Reviewed-by: Stefano Garzarella --- drivers/vhost/vhost.c | 1 + drivers/vhost/vhost.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 63612faeab72..250dc43f1786 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -552,6 +552,7 @@ void vhost_dev_init(struct vhost_dev *dev, dev->byte_weight =3D byte_weight; dev->use_worker =3D use_worker; dev->msg_handler =3D msg_handler; + dev->inherit_owner =3D true; init_waitqueue_head(&dev->wait); INIT_LIST_HEAD(&dev->read_list); INIT_LIST_HEAD(&dev->pending_list); diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index bb75a292d50c..19bb94922a0e 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -176,6 +176,15 @@ struct vhost_dev { int byte_weight; struct xarray worker_xa; bool use_worker; + /* + * If inherit_owner is true we use vhost_tasks to create + * the worker so all settings/limits like cgroups, NPROC, + * scheduler, etc are inherited from the owner. If false, + * we use kthreads and only attach to the same cgroups + * as the owner for compat with older kernels. + * here we use true as default value + */ + bool inherit_owner; int (*msg_handler)(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg); }; --=20 2.45.0