From patchwork Tue Dec 10 16:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 13901766 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 86804233D99 for ; Tue, 10 Dec 2024 16:45:14 +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=1733849116; cv=none; b=knkTjFZeg7F6XAREjj3KtrZoP+uOVFzwTsX5VNH+MYakF/drR5lIgdM9HUaa0Y9uqDwT4qCxgcjj/QcaT76wT3/cuuhGKuZJo75wLczf+7Tqrb6BC//NcCYFV2m3QfaScqwVvSMt1tE7lnPNBn1djJR65hLcU1F5PP0RxhWpzGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733849116; c=relaxed/simple; bh=jZWHDBC1em9YSxJA7OCoxzWdArjA3A0TYOkpGg7ZSRk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=USAmXuGIzY5xfPotQSdmIOoKXKEPjk/yubP0gVnhnBkDtitL+pH5KOgfBbCEtk46W+m1OUEPFUuA08cDd9wOzSTFCsiEBE4Hh7M/syMqnaRvV5tU+7afqVC7FbUQb339u15p+c+dO5A7H9nqiXRU29oDqn66UwkZE2fCALdI8ZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=Wd4u7OzG; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="Wd4u7OzG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733849113; 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=Kx5deBxNNDBqr/ibOJLZi9NoxS8td60GQR/dfMsL+Dk=; b=Wd4u7OzG/IFBVaB9xbMxPQ2vtIQKj3Jr7+8mZWwn5yaL6EfvH2dTnI+39vpIi/EOJZZjl5 cQ9QN8jAebHVZKPJwTO/6r8ciDzFNJYTk0ncqQM83E/wzD/Ue6KWVUWIw8BAsnHRLAbVA8 R2cub+qzvIP/2YHJOg3cWBCtQGYnD7E= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-JlGozaCIM8eXm6SCrWnjag-1; Tue, 10 Dec 2024 11:45:10 -0500 X-MC-Unique: JlGozaCIM8eXm6SCrWnjag-1 X-Mimecast-MFC-AGG-ID: JlGozaCIM8eXm6SCrWnjag Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B943219560BF; Tue, 10 Dec 2024 16:45:09 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.152]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C9F619560A2; Tue, 10 Dec 2024 16: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 v4 1/8] vhost: Add a new parameter in vhost_dev to allow user select kthread Date: Wed, 11 Dec 2024 00:41:40 +0800 Message-ID: <20241210164456.925060-2-lulu@redhat.com> In-Reply-To: <20241210164456.925060-1-lulu@redhat.com> References: <20241210164456.925060-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 app, Therefore, we are reintroducing kthread API support. Introduce a new parameter to enable users to choose between kthread and task mode. Signed-off-by: Cindy Lu --- drivers/vhost/vhost.c | 1 + drivers/vhost/vhost.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 9ac25d08f473..eaddbd39c29b 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 = byte_weight; dev->use_worker = use_worker; dev->msg_handler = msg_handler; + dev->inherit_owner = 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..c650c4506c70 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -176,6 +176,7 @@ struct vhost_dev { int byte_weight; struct xarray worker_xa; bool use_worker; + bool inherit_owner; int (*msg_handler)(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg); };