DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [PATCH] vhost: only emit debug log with invalid FD
Date: Mon, 24 Jun 2024 16:46:13 +0200	[thread overview]
Message-ID: <20240624144613.1855582-1-maxime.coquelin@redhat.com> (raw)

This patch improves the FD manager logging in case
of FD removal from the epoll FD set failure.

When the FD is not more valid, like for example if it
has already been closed, only emit a debug log and not
an error one.

Fixes: 0e38b42bf61c ("vhost: manage FD with epoll")

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/fd_man.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c
index 87a8dc3f3e..9bc7e50b93 100644
--- a/lib/vhost/fd_man.c
+++ b/lib/vhost/fd_man.c
@@ -256,9 +256,14 @@ fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)
 static void
 fdset_del_locked(struct fdset *pfdset, struct fdentry *pfdentry)
 {
-	if (epoll_ctl(pfdset->epfd, EPOLL_CTL_DEL, pfdentry->fd, NULL) == -1)
-		VHOST_FDMAN_LOG(ERR, "could not remove %d fd from %d epfd: %s",
-			pfdentry->fd, pfdset->epfd, strerror(errno));
+	if (epoll_ctl(pfdset->epfd, EPOLL_CTL_DEL, pfdentry->fd, NULL) == -1) {
+		if (errno == EBADF) /* File might have already been closed. */
+			VHOST_FDMAN_LOG(DEBUG, "could not remove %d fd from %d epfd: %s",
+				pfdentry->fd, pfdset->epfd, strerror(errno));
+		else
+			VHOST_FDMAN_LOG(ERR, "could not remove %d fd from %d epfd: %s",
+				pfdentry->fd, pfdset->epfd, strerror(errno));
+	}
 
 	fdset_remove_entry(pfdset, pfdentry);
 }
-- 
2.45.1


             reply	other threads:[~2024-06-24 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 14:46 Maxime Coquelin [this message]
2024-06-25  7:35 ` David Marchand
2024-06-25 11:47   ` Maxime Coquelin

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=20240624144613.1855582-1-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=chenbox@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.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;
as well as URLs for NNTP newsgroup(s).