From 4eb96aeba0181c195a3fa5408db12d82663d99eb Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 19 May 2021 14:29:20 +0900 Subject: [PATCH] thread: Inline poller_remove_timer() into thread_poll() We already hold thehe next closest timed poller in tmp. Inlining poller_remove_timer() into thread_poll() makes the cache update more efficient. After this patch, poller_remove_timer() is called only in a single case and the case is compiled only on Linux. So add it inside of a temporary block is much clearner. However it will be used by spdk_poller_reschedule() in the end of this patch series. So keep the current position. Signed-off-by: Shuhei Matsumoto Change-Id: I2e6858223713eed84f5d70b160da6122edae6d03 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7910 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Aleksey Marchuk --- lib/thread/thread.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 90ab5a3be..815bf3cda 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -681,6 +681,7 @@ poller_insert_timer(struct spdk_thread *thread, struct spdk_poller *poller, uint thread->first_timed_poller = poller; } +#ifdef __linux__ static inline void poller_remove_timer(struct spdk_thread *thread, struct spdk_poller *poller) { @@ -690,6 +691,7 @@ poller_remove_timer(struct spdk_thread *thread, struct spdk_poller *poller) thread->first_timed_poller = TAILQ_FIRST(&thread->timed_pollers); } } +#endif static void thread_insert_poller(struct spdk_thread *thread, struct spdk_poller *poller) @@ -876,7 +878,15 @@ thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) } tmp = TAILQ_NEXT(poller, tailq); - poller_remove_timer(thread, poller); + TAILQ_REMOVE(&thread->timed_pollers, poller, tailq); + + /* Update the cache to the next timed poller in the list + * only if the current poller is still the closest, otherwise, + * do nothing because the cache has been already updated. + */ + if (thread->first_timed_poller == poller) { + thread->first_timed_poller = tmp; + } timer_rc = thread_execute_timed_poller(thread, poller, now); if (timer_rc > rc) {