[7/7] vhost: improve FD manager logging

Message ID 20240229122502.2572343-8-maxime.coquelin@redhat.com (mailing list archive)
State Superseded
Delegated to: Maxime Coquelin
Headers
Series vhost: FD manager improvements |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/intel-Testing fail Testing issues
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Maxime Coquelin Feb. 29, 2024, 12:25 p.m. UTC
  Convert the logging macro to pass the fdset name
as argument.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/fd_man.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
  

Patch

diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c
index 6a5bd74656..18426095b4 100644
--- a/lib/vhost/fd_man.c
+++ b/lib/vhost/fd_man.c
@@ -19,8 +19,8 @@ 
 
 RTE_LOG_REGISTER_SUFFIX(vhost_fdset_logtype, fdset, INFO);
 #define RTE_LOGTYPE_VHOST_FDMAN vhost_fdset_logtype
-#define VHOST_FDMAN_LOG(level, ...) \
-	RTE_LOG_LINE(level, VHOST_FDMAN, "" __VA_ARGS__)
+#define VHOST_FDMAN_LOG(prefix, level, fmt, args...) \
+	RTE_LOG_LINE(level, VHOST_FDMAN, "(%s) " fmt, prefix, ##args)
 
 #define FDPOLLERR (POLLERR | POLLHUP | POLLNVAL)
 
@@ -126,15 +126,13 @@  fdset_sync_init(struct fdset *fdset)
 
 	fdset->sync_fd = eventfd(0, 0);
 	if (fdset->sync_fd < 0) {
-		VHOST_FDMAN_LOG(ERR, "failed to create eventfd for %s fdset", fdset->name);
+		VHOST_FDMAN_LOG(fdset->name, ERR, "failed to create eventfd");
 		return -1;
 	}
 
 	ret = fdset_add_no_sync(fdset, fdset->sync_fd, fdset_sync_read_cb, NULL, fdset);
 	if (ret < 0) {
-		VHOST_FDMAN_LOG(ERR, "failed to add eventfd %d to %s fdset",
-			fdset->sync_fd, fdset->name);
-
+		VHOST_FDMAN_LOG(fdset->name, ERR, "failed to add eventfd %d", fdset->sync_fd);
 		fdset_sync_uninit(fdset);
 		return -1;
 	}
@@ -152,8 +150,8 @@  fdset_sync(struct fdset *fdset)
 	fdset->sync = false;
 	ret = eventfd_write(fdset->sync_fd, (eventfd_t)1);
 	if (ret < 0) {
-		VHOST_FDMAN_LOG(ERR, "Failed to write sync eventfd for %s fdset: %s",
-			fdset->name, strerror(errno));
+		VHOST_FDMAN_LOG(fdset->name, ERR, "Failed to write sync eventfd: %s",
+				strerror(errno));
 		goto out_unlock;
 	}
 
@@ -251,7 +249,7 @@  fdset_init(const char *name)
 	int i;
 
 	if (name == NULL) {
-		VHOST_FDMAN_LOG(ERR, "Invalid name");
+		VHOST_FDMAN_LOG("fdset", ERR, "Invalid name");
 		goto err;
 	}
 
@@ -264,7 +262,7 @@  fdset_init(const char *name)
 
 	fdset = rte_zmalloc(NULL, sizeof(*fdset), 0);
 	if (!fdset) {
-		VHOST_FDMAN_LOG(ERR, "Failed to alloc fdset %s", name);
+		VHOST_FDMAN_LOG(name, ERR, "Failed to alloc fdset");
 		goto err_unlock;
 	}
 
@@ -280,19 +278,18 @@  fdset_init(const char *name)
 	fdset->num = 0;
 
 	if (fdset_sync_init(fdset)) {
-		VHOST_FDMAN_LOG(ERR, "Failed to init sync for %s", name);
+		VHOST_FDMAN_LOG(fdset->name, ERR, "Failed to init sync");
 		goto err_free;
 	}
 
 	if (rte_thread_create_internal_control(&fdset->tid, fdset->name,
 					fdset_event_dispatch, fdset)) {
-		VHOST_FDMAN_LOG(ERR, "Failed to create %s event dispatch thread",
-				fdset->name);
+		VHOST_FDMAN_LOG(fdset->name, ERR, "Failed to create event dispatch thread");
 		goto err_sync;
 	}
 
 	if (fdset_insert(fdset)) {
-		VHOST_FDMAN_LOG(ERR, "Failed to insert fdset %s", name);
+		VHOST_FDMAN_LOG(fdset->name, ERR, "Failed to insert fdset");
 		goto err_thread;
 	}