From c74421c1c088fccecc6b4607e0ad1a08033198f4 Mon Sep 17 00:00:00 2001 From: Liu Xiaodong Date: Thu, 22 Apr 2021 05:14:12 -0400 Subject: [PATCH] poller: rename timerfd to interruptfd In next patch, if poller doesn't have a period, eventfd will be created which's always busy automatically. This eventfd can be combined with timerfd. So rename timerfd to interruptfd. Change-Id: Ibffa30ecfcaa73e55f47e97fac854641b74f2dfb Signed-off-by: Liu Xiaodong Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7546 Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- include/spdk_internal/thread.h | 2 +- lib/thread/thread.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/spdk_internal/thread.h b/include/spdk_internal/thread.h index 875282d504..6d9e830d43 100644 --- a/include/spdk_internal/thread.h +++ b/include/spdk_internal/thread.h @@ -74,7 +74,7 @@ struct spdk_poller { spdk_poller_fn fn; void *arg; struct spdk_thread *thread; - int timerfd; + int interruptfd; spdk_poller_set_interrupt_mode_cb set_intr_cb_fn; void *set_intr_cb_arg; diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 26f5a5b387..2201ce16d1 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -990,7 +990,7 @@ interrupt_timerfd_process(void *arg) int rc; /* clear the level of interval timer */ - rc = read(poller->timerfd, &exp, sizeof(exp)); + rc = read(poller->interruptfd, &exp, sizeof(exp)); if (rc < 0) { if (rc == -EAGAIN) { return 0; @@ -1011,7 +1011,7 @@ period_poller_interrupt_init(struct spdk_poller *poller) int timerfd; int rc; - SPDK_DEBUGLOG(thread, "timerfd init for period poller %s\n", poller->name); + SPDK_DEBUGLOG(thread, "timerfd init for periodic poller %s\n", poller->name); timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); if (timerfd < 0) { return -errno; @@ -1024,14 +1024,14 @@ period_poller_interrupt_init(struct spdk_poller *poller) return rc; } - poller->timerfd = timerfd; + poller->interruptfd = timerfd; return 0; } static void period_poller_set_interrupt_mode(struct spdk_poller *poller, void *cb_arg, bool interrupt_mode) { - int timerfd = poller->timerfd; + int timerfd = poller->interruptfd; uint64_t now_tick = spdk_get_ticks(); uint64_t ticks = spdk_get_ticks_hz(); int ret; @@ -1087,10 +1087,10 @@ static void period_poller_interrupt_fini(struct spdk_poller *poller) { SPDK_DEBUGLOG(thread, "timerfd fini for poller %s\n", poller->name); - assert(poller->timerfd >= 0); - spdk_fd_group_remove(poller->thread->fgrp, poller->timerfd); - close(poller->timerfd); - poller->timerfd = -1; + assert(poller->interruptfd >= 0); + spdk_fd_group_remove(poller->thread->fgrp, poller->interruptfd); + close(poller->interruptfd); + poller->interruptfd = -1; } #else @@ -1171,7 +1171,7 @@ poller_register(spdk_poller_fn fn, poller->fn = fn; poller->arg = arg; poller->thread = thread; - poller->timerfd = -1; + poller->interruptfd = -1; if (period_microseconds) { quotient = period_microseconds / SPDK_SEC_TO_USEC; @@ -1243,7 +1243,7 @@ spdk_poller_unregister(struct spdk_poller **ppoller) return; } - if (spdk_interrupt_mode_is_enabled() && poller->timerfd >= 0) { + if (spdk_interrupt_mode_is_enabled() && poller->interruptfd >= 0) { period_poller_interrupt_fini(poller); }