From: Chenbo Xia <chenbox@nvidia.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
David Marchand <david.marchand@redhat.com>
Subject: Re: [PATCH v3 4/5] vhost: improve fdset initialization
Date: Fri, 26 Apr 2024 07:40:50 +0000 [thread overview]
Message-ID: <2CC8E7C2-D630-4907-92FA-15D7AFC864D1@nvidia.com> (raw)
In-Reply-To: <20240409114845.1336403-5-maxime.coquelin@redhat.com>
Hi Maxime,
> On Apr 9, 2024, at 19:48, Maxime Coquelin <maxime.coquelin@redhat.com> wrote:
>
> External email: Use caution opening links or attachments
>
>
> This patch heavily reworks fdset initialization:
> - fdsets are now dynamically allocated by the FD manager
> - the event dispatcher is now created by the FD manager
> - struct fdset is now opaque to VDUSE and Vhost
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> lib/vhost/fd_man.c | 177 ++++++++++++++++++++++++++++++++++++++++-----
> lib/vhost/fd_man.h | 39 +---------
> lib/vhost/socket.c | 24 ++----
> lib/vhost/vduse.c | 29 ++------
> 4 files changed, 177 insertions(+), 92 deletions(-)
>
> diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c
> index 0ae481b785..8b47c97d45 100644
> --- a/lib/vhost/fd_man.c
> +++ b/lib/vhost/fd_man.c
> @@ -3,12 +3,16 @@
> */
>
> #include <errno.h>
> +#include <pthread.h>
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>
>
> #include <rte_common.h>
> #include <rte_log.h>
> +#include <rte_malloc.h>
> +#include <rte_string_fns.h>
> +#include <rte_thread.h>
>
> #include "fd_man.h"
>
> @@ -19,6 +23,79 @@ RTE_LOG_REGISTER_SUFFIX(vhost_fdset_logtype, fdset, INFO);
>
> #define FDPOLLERR (POLLERR | POLLHUP | POLLNVAL)
>
> +struct fdentry {
> + int fd; /* -1 indicates this entry is empty */
> + fd_cb rcb; /* callback when this fd is readable. */
> + fd_cb wcb; /* callback when this fd is writeable.*/
> + void *dat; /* fd context */
> + int busy; /* whether this entry is being used in cb. */
> +};
> +
> +struct fdset {
> + char name[RTE_THREAD_NAME_SIZE];
> + struct pollfd rwfds[MAX_FDS];
> + struct fdentry fd[MAX_FDS];
> + rte_thread_t tid;
> + pthread_mutex_t fd_mutex;
> + pthread_mutex_t fd_polling_mutex;
> + int num; /* current fd number of this fdset */
> +
> + union pipefds {
> + struct {
> + int pipefd[2];
> + };
> + struct {
> + int readfd;
> + int writefd;
> + };
> + } u;
> +
> + pthread_mutex_t sync_mutex;
> + pthread_cond_t sync_cond;
> + bool sync;
> + bool destroy;
> +};
> +
> +static int fdset_add_no_sync(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat);
> +static uint32_t fdset_event_dispatch(void *arg);
> +
> +#define MAX_FDSETS 8
> +
> +static struct fdset *fdsets[MAX_FDSETS];
> +pthread_mutex_t fdsets_mutex = PTHREAD_MUTEX_INITIALIZER;
Static pthread_mutex_t ?
Thanks,
Chenbo
next prev parent reply other threads:[~2024-04-26 7:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 11:48 [PATCH v3 0/5] vhost: FD manager improvements Maxime Coquelin
2024-04-09 11:48 ` [PATCH v3 1/5] vhost: rename polling mutex Maxime Coquelin
2024-04-09 11:48 ` [PATCH v3 2/5] vhost: make use of FD manager init function Maxime Coquelin
2024-04-09 16:38 ` Stephen Hemminger
2024-04-10 6:22 ` Maxime Coquelin
2024-04-09 11:48 ` [PATCH v3 3/5] vhost: hide synchronization within FD manager Maxime Coquelin
2024-04-09 11:48 ` [PATCH v3 4/5] vhost: improve fdset initialization Maxime Coquelin
2024-04-26 7:40 ` Chenbo Xia [this message]
2024-04-26 7:46 ` Maxime Coquelin
2024-04-09 11:48 ` [PATCH v3 5/5] vhost: manage FD with epoll Maxime Coquelin
2024-04-28 3:22 ` Chenbo Xia
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=2CC8E7C2-D630-4907-92FA-15D7AFC864D1@nvidia.com \
--to=chenbox@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.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;
as well as URLs for NNTP newsgroup(s).