add name to fd groups

For debugging purposes, take a name for identifying fds added to a group.

Signed-off-by: John Levon <john.levon@nutanix.com>
Change-Id: If1654e56e19f7fa964446ef1b9e71debf74979d1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9731
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
John Levon 2021-09-07 22:49:31 +01:00 committed by Tomasz Zawadzki
parent 2d48b7dc10
commit 17199cdc8f
6 changed files with 34 additions and 16 deletions

View File

@ -76,6 +76,10 @@ Added `spdk_nvme_ctrlr_get_opts` to retrieve the current controller options.
Updated DPDK submodule to DPDK 21.08.
### util
The `spdk_fd_group_add` API now takes a `name` parameter.
## v21.07
### accel_fw

View File

@ -110,11 +110,19 @@ int spdk_fd_group_get_fd(struct spdk_fd_group *fgrp);
* \param efd File descriptor of the event source.
* \param fn Called each time there are events in event source.
* \param arg Function argument for fn.
* \param name Name of the event source.
*
* \return 0 if success or -errno if failed
*/
int spdk_fd_group_add(struct spdk_fd_group *fgrp,
int efd, spdk_fd_fn fn, void *arg);
int spdk_fd_group_add(struct spdk_fd_group *fgrp, int efd,
spdk_fd_fn fn, void *arg, const char *name);
/*
* \brief Register an event source with the name set to the string of the
* callback function.
*/
#define SPDK_FD_GROUP_ADD(fgrp, efd, fn, arg) \
spdk_fd_group_add(fgrp, efd, fn, arg, #fn)
/**
* Unregister one event source from one fgrp.

View File

@ -1150,7 +1150,8 @@ _schedule_thread(void *arg1, void *arg2)
int rc;
efd = spdk_thread_get_interrupt_fd(thread);
rc = spdk_fd_group_add(reactor->fgrp, efd, thread_process_interrupts, thread);
rc = SPDK_FD_GROUP_ADD(reactor->fgrp, efd,
thread_process_interrupts, thread);
if (rc < 0) {
SPDK_ERRLOG("Failed to schedule spdk_thread: %s.\n", spdk_strerror(-rc));
}
@ -1413,7 +1414,7 @@ reactor_interrupt_init(struct spdk_reactor *reactor)
goto err;
}
rc = spdk_fd_group_add(reactor->fgrp, reactor->resched_fd, reactor_schedule_thread_event,
rc = SPDK_FD_GROUP_ADD(reactor->fgrp, reactor->resched_fd, reactor_schedule_thread_event,
reactor);
if (rc) {
close(reactor->resched_fd);
@ -1429,7 +1430,7 @@ reactor_interrupt_init(struct spdk_reactor *reactor)
goto err;
}
rc = spdk_fd_group_add(reactor->fgrp, reactor->events_fd,
rc = SPDK_FD_GROUP_ADD(reactor->fgrp, reactor->events_fd,
event_queue_run_batch, reactor);
if (rc) {
spdk_fd_group_remove(reactor->fgrp, reactor->resched_fd);

View File

@ -1263,8 +1263,7 @@ period_poller_interrupt_init(struct spdk_poller *poller)
return -errno;
}
rc = spdk_fd_group_add(fgrp, timerfd,
interrupt_timerfd_process, poller);
rc = SPDK_FD_GROUP_ADD(fgrp, timerfd, interrupt_timerfd_process, poller);
if (rc < 0) {
close(timerfd);
return rc;
@ -1352,7 +1351,8 @@ busy_poller_interrupt_init(struct spdk_poller *poller)
return -errno;
}
rc = spdk_fd_group_add(poller->thread->fgrp, busy_efd, poller->fn, poller->arg);
rc = spdk_fd_group_add(poller->thread->fgrp, busy_efd,
poller->fn, poller->arg, poller->name);
if (rc < 0) {
close(busy_efd);
return rc;
@ -2487,7 +2487,8 @@ thread_interrupt_create(struct spdk_thread *thread)
return rc;
}
return spdk_fd_group_add(thread->fgrp, thread->msg_fd, thread_interrupt_msg_process, thread);
return SPDK_FD_GROUP_ADD(thread->fgrp, thread->msg_fd,
thread_interrupt_msg_process, thread);
}
#else
static int
@ -2516,7 +2517,7 @@ spdk_interrupt_register(int efd, spdk_interrupt_fn fn,
return NULL;
}
ret = spdk_fd_group_add(thread->fgrp, efd, fn, arg);
ret = spdk_fd_group_add(thread->fgrp, efd, fn, arg, name);
if (ret != 0) {
SPDK_ERRLOG("thread %s: failed to add fd %d: %s\n",

View File

@ -34,8 +34,8 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
SO_VER := 3
SO_MINOR := 1
SO_VER := 4
SO_MINOR := 0
C_SRCS = base64.c bit_array.c cpuset.c crc16.c crc32.c crc32c.c crc32_ieee.c \
dif.c fd.c file.c iov.c math.c pipe.c strerror_tls.c string.c uuid.c \

View File

@ -39,6 +39,8 @@
#include <sys/epoll.h>
#endif
#define SPDK_MAX_EVENT_NAME_LEN 256
enum event_handler_state {
/* The event_handler is added into an fd_group waiting for event,
* but not currently in the execution of a wait loop.
@ -63,6 +65,7 @@ struct event_handler {
void *fn_arg;
/* file descriptor of the interrupt event */
int fd;
char name[SPDK_MAX_EVENT_NAME_LEN + 1];
};
struct spdk_fd_group {
@ -82,8 +85,8 @@ spdk_fd_group_get_fd(struct spdk_fd_group *fgrp)
#ifdef __linux__
int
spdk_fd_group_add(struct spdk_fd_group *fgrp,
int efd, spdk_fd_fn fn, void *arg)
spdk_fd_group_add(struct spdk_fd_group *fgrp, int efd, spdk_fd_fn fn,
void *arg, const char *name)
{
struct event_handler *ehdlr = NULL;
struct epoll_event epevent = {0};
@ -111,6 +114,7 @@ spdk_fd_group_add(struct spdk_fd_group *fgrp,
ehdlr->fn = fn;
ehdlr->fn_arg = arg;
ehdlr->state = EVENT_HANDLER_STATE_WAITING;
snprintf(ehdlr->name, sizeof(ehdlr->name), "%s", name);
epevent.events = EPOLLIN;
epevent.data.ptr = ehdlr;
@ -313,8 +317,8 @@ spdk_fd_group_wait(struct spdk_fd_group *fgrp, int timeout)
#else
int
spdk_fd_group_add(struct spdk_fd_group *fgrp,
int efd, spdk_fd_fn fn, void *arg)
spdk_fd_group_add(struct spdk_fd_group *fgrp, int efd, spdk_fd_fn fn,
void *arg, const char *name)
{
return -ENOTSUP;
}