get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/139213/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 139213,
    "url": "http://patches.dpdk.org/api/patches/139213/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240409114845.1336403-5-maxime.coquelin@redhat.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20240409114845.1336403-5-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240409114845.1336403-5-maxime.coquelin@redhat.com",
    "date": "2024-04-09T11:48:44",
    "name": "[v3,4/5] vhost: improve fdset initialization",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "90c60612728269402f7dd4bc39cec659468e7b57",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240409114845.1336403-5-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 31711,
            "url": "http://patches.dpdk.org/api/series/31711/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31711",
            "date": "2024-04-09T11:48:40",
            "name": "vhost: FD manager improvements",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/31711/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/139213/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/139213/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id E9EEE43E29;\n\tTue,  9 Apr 2024 13:49:23 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1FEE840693;\n\tTue,  9 Apr 2024 13:49:05 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id 999934067A\n for <dev@dpdk.org>; Tue,  9 Apr 2024 13:49:02 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73])\n by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-SclmpvlnMvyKYUXj5Be74Q-1; Tue,\n 09 Apr 2024 07:49:00 -0400",
            "from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com\n [10.11.54.3])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFED1380009B;\n Tue,  9 Apr 2024 11:48:59 +0000 (UTC)",
            "from max-p1.redhat.com (unknown [10.39.208.27])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 8CAF2100F4D8;\n Tue,  9 Apr 2024 11:48:58 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1712663342;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=stsbroYmOc4gOqmLWIKVxRNR1WImC4I7sjfz4QKBvk4=;\n b=GnRy750ANDw5rsoEB0Hud/whnV04R+1pjCAvmhM+jDtGxuZGjQYEzWWpgYpShEbydfz+5I\n bVB3DPDizhiaPLlNG+Fj6yuSPi+hHPb4kRYw5cnEClvDZbrXuUN9OxNPK208tl1QdqNwmM\n fUkneNx4gqDek5/X7fAuERVdql5Z5Zs=",
        "X-MC-Unique": "SclmpvlnMvyKYUXj5Be74Q-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org,\n\tdavid.marchand@redhat.com,\n\tchenbox@nvidia.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[PATCH v3 4/5] vhost: improve fdset initialization",
        "Date": "Tue,  9 Apr 2024 13:48:44 +0200",
        "Message-ID": "<20240409114845.1336403-5-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20240409114845.1336403-1-maxime.coquelin@redhat.com>",
        "References": "<20240409114845.1336403-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.3",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "This patch heavily reworks fdset initialization:\n - fdsets are now dynamically allocated by the FD manager\n - the event dispatcher is now created by the FD manager\n - struct fdset is now opaque to VDUSE and Vhost\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/vhost/fd_man.c | 177 ++++++++++++++++++++++++++++++++++++++++-----\n lib/vhost/fd_man.h |  39 +---------\n lib/vhost/socket.c |  24 ++----\n lib/vhost/vduse.c  |  29 ++------\n 4 files changed, 177 insertions(+), 92 deletions(-)",
    "diff": "diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c\nindex 0ae481b785..8b47c97d45 100644\n--- a/lib/vhost/fd_man.c\n+++ b/lib/vhost/fd_man.c\n@@ -3,12 +3,16 @@\n  */\n \n #include <errno.h>\n+#include <pthread.h>\n #include <stdio.h>\n #include <string.h>\n #include <unistd.h>\n \n #include <rte_common.h>\n #include <rte_log.h>\n+#include <rte_malloc.h>\n+#include <rte_string_fns.h>\n+#include <rte_thread.h>\n \n #include \"fd_man.h\"\n \n@@ -19,6 +23,79 @@ RTE_LOG_REGISTER_SUFFIX(vhost_fdset_logtype, fdset, INFO);\n \n #define FDPOLLERR (POLLERR | POLLHUP | POLLNVAL)\n \n+struct fdentry {\n+\tint fd;\t\t/* -1 indicates this entry is empty */\n+\tfd_cb rcb;\t/* callback when this fd is readable. */\n+\tfd_cb wcb;\t/* callback when this fd is writeable.*/\n+\tvoid *dat;\t/* fd context */\n+\tint busy;\t/* whether this entry is being used in cb. */\n+};\n+\n+struct fdset {\n+\tchar name[RTE_THREAD_NAME_SIZE];\n+\tstruct pollfd rwfds[MAX_FDS];\n+\tstruct fdentry fd[MAX_FDS];\n+\trte_thread_t tid;\n+\tpthread_mutex_t fd_mutex;\n+\tpthread_mutex_t fd_polling_mutex;\n+\tint num;\t/* current fd number of this fdset */\n+\n+\tunion pipefds {\n+\t\tstruct {\n+\t\t\tint pipefd[2];\n+\t\t};\n+\t\tstruct {\n+\t\t\tint readfd;\n+\t\t\tint writefd;\n+\t\t};\n+\t} u;\n+\n+\tpthread_mutex_t sync_mutex;\n+\tpthread_cond_t sync_cond;\n+\tbool sync;\n+\tbool destroy;\n+};\n+\n+static int fdset_add_no_sync(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat);\n+static uint32_t fdset_event_dispatch(void *arg);\n+\n+#define MAX_FDSETS 8\n+\n+static struct fdset *fdsets[MAX_FDSETS];\n+pthread_mutex_t fdsets_mutex = PTHREAD_MUTEX_INITIALIZER;\n+\n+static struct fdset *\n+fdset_lookup(const char *name)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_FDSETS; i++) {\n+\t\tstruct fdset *fdset = fdsets[i];\n+\t\tif (fdset == NULL)\n+\t\t\tcontinue;\n+\n+\t\tif (!strncmp(fdset->name, name, RTE_THREAD_NAME_SIZE))\n+\t\t\treturn fdset;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+static int\n+fdset_insert(struct fdset *fdset)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_FDSETS; i++) {\n+\t\tif (fdsets[i] == NULL) {\n+\t\t\tfdsets[i] = fdset;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1;\n+}\n+\n static void\n fdset_pipe_read_cb(int readfd, void *dat,\n \t\t   int *remove __rte_unused)\n@@ -63,7 +140,7 @@ fdset_pipe_init(struct fdset *fdset)\n \t\treturn -1;\n \t}\n \n-\tret = fdset_add(fdset, fdset->u.readfd,\n+\tret = fdset_add_no_sync(fdset, fdset->u.readfd,\n \t\t\tfdset_pipe_read_cb, NULL, fdset);\n \tif (ret < 0) {\n \t\tVHOST_FDMAN_LOG(ERR,\n@@ -179,37 +256,82 @@ fdset_add_fd(struct fdset *pfdset, int idx, int fd,\n \tpfd->revents = 0;\n }\n \n-void\n-fdset_uninit(struct fdset *pfdset)\n-{\n-\tfdset_pipe_uninit(pfdset);\n-}\n-\n-int\n-fdset_init(struct fdset *pfdset)\n+struct fdset *\n+fdset_init(const char *name)\n {\n+\tstruct fdset *fdset;\n+\tuint32_t val;\n \tint i;\n \n-\tif (pfdset == NULL)\n-\t\treturn -1;\n+\tif (name == NULL) {\n+\t\tVHOST_FDMAN_LOG(ERR, \"Invalid name\");\n+\t\tgoto err;\n+\t}\n \n-\tpthread_mutex_init(&pfdset->fd_mutex, NULL);\n-\tpthread_mutex_init(&pfdset->fd_polling_mutex, NULL);\n+\tpthread_mutex_lock(&fdsets_mutex);\n+\tfdset = fdset_lookup(name);\n+\tif (fdset) {\n+\t\tpthread_mutex_unlock(&fdsets_mutex);\n+\t\treturn fdset;\n+\t}\n+\n+\tfdset = rte_zmalloc(NULL, sizeof(*fdset), 0);\n+\tif (!fdset) {\n+\t\tVHOST_FDMAN_LOG(ERR, \"Failed to alloc fdset %s\", name);\n+\t\tgoto err_unlock;\n+\t}\n+\n+\trte_strscpy(fdset->name, name, RTE_THREAD_NAME_SIZE);\n+\n+\tpthread_mutex_init(&fdset->fd_mutex, NULL);\n+\tpthread_mutex_init(&fdset->fd_polling_mutex, NULL);\n \n \tfor (i = 0; i < MAX_FDS; i++) {\n-\t\tpfdset->fd[i].fd = -1;\n-\t\tpfdset->fd[i].dat = NULL;\n+\t\tfdset->fd[i].fd = -1;\n+\t\tfdset->fd[i].dat = NULL;\n \t}\n-\tpfdset->num = 0;\n+\tfdset->num = 0;\n \n-\treturn fdset_pipe_init(pfdset);\n+\tif (fdset_pipe_init(fdset)) {\n+\t\tVHOST_FDMAN_LOG(ERR, \"Failed to init pipe for %s\", name);\n+\t\tgoto err_free;\n+\t}\n+\n+\tif (rte_thread_create_internal_control(&fdset->tid, fdset->name,\n+\t\t\t\t\tfdset_event_dispatch, fdset)) {\n+\t\tVHOST_FDMAN_LOG(ERR, \"Failed to create %s event dispatch thread\",\n+\t\t\t\tfdset->name);\n+\t\tgoto err_pipe;\n+\t}\n+\n+\tif (fdset_insert(fdset)) {\n+\t\tVHOST_FDMAN_LOG(ERR, \"Failed to insert fdset %s\", name);\n+\t\tgoto err_thread;\n+\t}\n+\n+\tpthread_mutex_unlock(&fdsets_mutex);\n+\n+\treturn fdset;\n+\n+err_thread:\n+\tfdset->destroy = true;\n+\tfdset_sync(fdset);\n+\trte_thread_join(fdset->tid, &val);\n+err_pipe:\n+\tfdset_pipe_uninit(fdset);\n+err_free:\n+\trte_free(fdset);\n+err_unlock:\n+\tpthread_mutex_unlock(&fdsets_mutex);\n+err:\n+\treturn NULL;\n }\n \n /**\n  * Register the fd in the fdset with read/write handler and context.\n  */\n-int\n-fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)\n+static int\n+fdset_add_no_sync(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)\n {\n \tint i;\n \n@@ -232,6 +354,18 @@ fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)\n \tfdset_add_fd(pfdset, i, fd, rcb, wcb, dat);\n \tpthread_mutex_unlock(&pfdset->fd_mutex);\n \n+\treturn 0;\n+}\n+\n+int\n+fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)\n+{\n+\tint ret;\n+\n+\tret = fdset_add_no_sync(pfdset, fd, rcb, wcb, dat);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n \tfdset_sync(pfdset);\n \n \treturn 0;\n@@ -315,7 +449,7 @@ fdset_try_del(struct fdset *pfdset, int fd)\n  * will wait until the flag is reset to zero(which indicates the callback is\n  * finished), then it could free the context after fdset_del.\n  */\n-uint32_t\n+static uint32_t\n fdset_event_dispatch(void *arg)\n {\n \tint i;\n@@ -404,6 +538,9 @@ fdset_event_dispatch(void *arg)\n \n \t\tif (need_shrink)\n \t\t\tfdset_shrink(pfdset);\n+\n+\t\tif (pfdset->destroy)\n+\t\t\tbreak;\n \t}\n \n \treturn 0;\ndiff --git a/lib/vhost/fd_man.h b/lib/vhost/fd_man.h\nindex c18e3a435c..079fa0155f 100644\n--- a/lib/vhost/fd_man.h\n+++ b/lib/vhost/fd_man.h\n@@ -8,50 +8,19 @@\n #include <poll.h>\n #include <stdbool.h>\n \n+struct fdset;\n+\n #define MAX_FDS 1024\n \n typedef void (*fd_cb)(int fd, void *dat, int *remove);\n \n-struct fdentry {\n-\tint fd;\t\t/* -1 indicates this entry is empty */\n-\tfd_cb rcb;\t/* callback when this fd is readable. */\n-\tfd_cb wcb;\t/* callback when this fd is writeable.*/\n-\tvoid *dat;\t/* fd context */\n-\tint busy;\t/* whether this entry is being used in cb. */\n-};\n-\n-struct fdset {\n-\tstruct pollfd rwfds[MAX_FDS];\n-\tstruct fdentry fd[MAX_FDS];\n-\tpthread_mutex_t fd_mutex;\n-\tpthread_mutex_t fd_polling_mutex;\n-\tint num;\t/* current fd number of this fdset */\n-\n-\tunion pipefds {\n-\t\tstruct {\n-\t\t\tint pipefd[2];\n-\t\t};\n-\t\tstruct {\n-\t\t\tint readfd;\n-\t\t\tint writefd;\n-\t\t};\n-\t} u;\n-\n-\tpthread_mutex_t sync_mutex;\n-\tpthread_cond_t sync_cond;\n-\tbool sync;\n-};\n-\n-void fdset_uninit(struct fdset *pfdset);\n-\n-int fdset_init(struct fdset *pfdset);\n+struct fdset *fdset_init(const char *name);\n \n int fdset_add(struct fdset *pfdset, int fd,\n \tfd_cb rcb, fd_cb wcb, void *dat);\n \n void *fdset_del(struct fdset *pfdset, int fd);\n-int fdset_try_del(struct fdset *pfdset, int fd);\n \n-uint32_t fdset_event_dispatch(void *arg);\n+int fdset_try_del(struct fdset *pfdset, int fd);\n \n #endif\ndiff --git a/lib/vhost/socket.c b/lib/vhost/socket.c\nindex 5afb952a21..c68e9bd5a8 100644\n--- a/lib/vhost/socket.c\n+++ b/lib/vhost/socket.c\n@@ -76,7 +76,7 @@ struct vhost_user_connection {\n #define MAX_VHOST_SOCKET 1024\n struct vhost_user {\n \tstruct vhost_user_socket *vsockets[MAX_VHOST_SOCKET];\n-\tstruct fdset fdset;\n+\tstruct fdset *fdset;\n \tint vsocket_cnt;\n \tpthread_mutex_t mutex;\n };\n@@ -261,7 +261,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)\n \tconn->connfd = fd;\n \tconn->vsocket = vsocket;\n \tconn->vid = vid;\n-\tret = fdset_add(&vhost_user.fdset, fd, vhost_user_read_cb,\n+\tret = fdset_add(vhost_user.fdset, fd, vhost_user_read_cb,\n \t\t\tNULL, conn);\n \tif (ret < 0) {\n \t\tVHOST_CONFIG_LOG(vsocket->path, ERR,\n@@ -394,7 +394,7 @@ vhost_user_start_server(struct vhost_user_socket *vsocket)\n \tif (ret < 0)\n \t\tgoto err;\n \n-\tret = fdset_add(&vhost_user.fdset, fd, vhost_user_server_new_connection,\n+\tret = fdset_add(vhost_user.fdset, fd, vhost_user_server_new_connection,\n \t\t  NULL, vsocket);\n \tif (ret < 0) {\n \t\tVHOST_CONFIG_LOG(path, ERR, \"failed to add listen fd %d to vhost server fdset\",\n@@ -1079,7 +1079,7 @@ rte_vhost_driver_unregister(const char *path)\n \t\t\t * mutex lock, and try again since the r/wcb\n \t\t\t * may use the mutex lock.\n \t\t\t */\n-\t\t\tif (fdset_try_del(&vhost_user.fdset, vsocket->socket_fd) == -1) {\n+\t\t\tif (fdset_try_del(vhost_user.fdset, vsocket->socket_fd) == -1) {\n \t\t\t\tpthread_mutex_unlock(&vhost_user.mutex);\n \t\t\t\tgoto again;\n \t\t\t}\n@@ -1099,7 +1099,7 @@ rte_vhost_driver_unregister(const char *path)\n \t\t\t * try again since the r/wcb may use the\n \t\t\t * conn_mutex and mutex locks.\n \t\t\t */\n-\t\t\tif (fdset_try_del(&vhost_user.fdset,\n+\t\t\tif (fdset_try_del(vhost_user.fdset,\n \t\t\t\t\t  conn->connfd) == -1) {\n \t\t\t\tpthread_mutex_unlock(&vsocket->conn_mutex);\n \t\t\t\tpthread_mutex_unlock(&vhost_user.mutex);\n@@ -1167,7 +1167,6 @@ int\n rte_vhost_driver_start(const char *path)\n {\n \tstruct vhost_user_socket *vsocket;\n-\tstatic rte_thread_t fdset_tid;\n \n \tpthread_mutex_lock(&vhost_user.mutex);\n \tvsocket = find_vhost_user_socket(path);\n@@ -1179,19 +1178,12 @@ rte_vhost_driver_start(const char *path)\n \tif (vsocket->is_vduse)\n \t\treturn vduse_device_create(path, vsocket->net_compliant_ol_flags);\n \n-\tif (fdset_tid.opaque_id == 0) {\n-\t\tif (fdset_init(&vhost_user.fdset) < 0) {\n+\tif (vhost_user.fdset == NULL) {\n+\t\tvhost_user.fdset = fdset_init(\"vhost-evt\");\n+\t\tif (vhost_user.fdset == NULL) {\n \t\t\tVHOST_CONFIG_LOG(path, ERR, \"failed to init Vhost-user fdset\");\n \t\t\treturn -1;\n \t\t}\n-\n-\t\tint ret = rte_thread_create_internal_control(&fdset_tid,\n-\t\t\t\t\"vhost-evt\", fdset_event_dispatch, &vhost_user.fdset);\n-\t\tif (ret != 0) {\n-\t\t\tVHOST_CONFIG_LOG(path, ERR, \"failed to create fdset handling thread\");\n-\t\t\tfdset_uninit(&vhost_user.fdset);\n-\t\t\treturn -1;\n-\t\t}\n \t}\n \n \tif (vsocket->is_server)\ndiff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c\nindex d87fc500d4..c66602905c 100644\n--- a/lib/vhost/vduse.c\n+++ b/lib/vhost/vduse.c\n@@ -28,13 +28,11 @@\n #define VDUSE_CTRL_PATH \"/dev/vduse/control\"\n \n struct vduse {\n-\tstruct fdset fdset;\n+\tstruct fdset *fdset;\n };\n \n static struct vduse vduse;\n \n-static bool vduse_events_thread;\n-\n static const char * const vduse_reqs_str[] = {\n \t\"VDUSE_GET_VQ_STATE\",\n \t\"VDUSE_SET_STATUS\",\n@@ -215,7 +213,7 @@ vduse_vring_setup(struct virtio_net *dev, unsigned int index)\n \t}\n \n \tif (vq == dev->cvq) {\n-\t\tret = fdset_add(&vduse.fdset, vq->kickfd, vduse_control_queue_event, NULL, dev);\n+\t\tret = fdset_add(vduse.fdset, vq->kickfd, vduse_control_queue_event, NULL, dev);\n \t\tif (ret) {\n \t\t\tVHOST_CONFIG_LOG(dev->ifname, ERR,\n \t\t\t\t\t\"Failed to setup kickfd handler for VQ %u: %s\",\n@@ -238,7 +236,7 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)\n \tint ret;\n \n \tif (vq == dev->cvq && vq->kickfd >= 0)\n-\t\tfdset_del(&vduse.fdset, vq->kickfd);\n+\t\tfdset_del(vduse.fdset, vq->kickfd);\n \n \tvq_efd.index = index;\n \tvq_efd.fd = VDUSE_EVENTFD_DEASSIGN;\n@@ -413,7 +411,6 @@ int\n vduse_device_create(const char *path, bool compliant_ol_flags)\n {\n \tint control_fd, dev_fd, vid, ret;\n-\trte_thread_t fdset_tid;\n \tuint32_t i, max_queue_pairs, total_queues;\n \tstruct virtio_net *dev;\n \tstruct virtio_net_config vnet_config = {{ 0 }};\n@@ -422,22 +419,12 @@ vduse_device_create(const char *path, bool compliant_ol_flags)\n \tstruct vduse_dev_config *dev_config = NULL;\n \tconst char *name = path + strlen(\"/dev/vduse/\");\n \n-\t/* If first device, create events dispatcher thread */\n-\tif (vduse_events_thread == false) {\n-\t\tif (fdset_init(&vduse.fdset) < 0) {\n+\tif (vduse.fdset == NULL) {\n+\t\tvduse.fdset = fdset_init(\"vduse-evt\");\n+\t\tif (vduse.fdset == NULL) {\n \t\t\tVHOST_CONFIG_LOG(path, ERR, \"failed to init VDUSE fdset\");\n \t\t\treturn -1;\n \t\t}\n-\n-\t\tret = rte_thread_create_internal_control(&fdset_tid, \"vduse-evt\",\n-\t\t\t\tfdset_event_dispatch, &vduse.fdset);\n-\t\tif (ret != 0) {\n-\t\t\tVHOST_CONFIG_LOG(path, ERR, \"failed to create vduse fdset handling thread\");\n-\t\t\tfdset_uninit(&vduse.fdset);\n-\t\t\treturn -1;\n-\t\t}\n-\n-\t\tvduse_events_thread = true;\n \t}\n \n \tcontrol_fd = open(VDUSE_CTRL_PATH, O_RDWR);\n@@ -555,7 +542,7 @@ vduse_device_create(const char *path, bool compliant_ol_flags)\n \n \tdev->cvq = dev->virtqueue[max_queue_pairs * 2];\n \n-\tret = fdset_add(&vduse.fdset, dev->vduse_dev_fd, vduse_events_handler, NULL, dev);\n+\tret = fdset_add(vduse.fdset, dev->vduse_dev_fd, vduse_events_handler, NULL, dev);\n \tif (ret) {\n \t\tVHOST_CONFIG_LOG(name, ERR, \"Failed to add fd %d to vduse fdset\",\n \t\t\t\tdev->vduse_dev_fd);\n@@ -602,7 +589,7 @@ vduse_device_destroy(const char *path)\n \n \tvduse_device_stop(dev);\n \n-\tfdset_del(&vduse.fdset, dev->vduse_dev_fd);\n+\tfdset_del(vduse.fdset, dev->vduse_dev_fd);\n \n \tif (dev->vduse_dev_fd >= 0) {\n \t\tclose(dev->vduse_dev_fd);\n",
    "prefixes": [
        "v3",
        "4/5"
    ]
}