thread: add spdk_thread_is_idle()

This function add possibility to check if there are any scheduled operations
on particular thread.

Return from spdk_thread_poll() will be used as a way to load-balance and
signify if any work was performed during the single iteration.
A poller could return 0, but still be registered.

This helps especially in fio_plugin that only checked active_pollers or
messages via spdk_thread_poll().

Change-Id: Id6237278eb3b4bd4922b2abaa3c8ebd5e434d45d
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/445915
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Tomasz Zawadzki 2019-02-22 08:58:46 -05:00 committed by Darek Stojaczyk
parent 7173e9bd02
commit 154eb3399a
4 changed files with 27 additions and 4 deletions

View File

@ -17,6 +17,9 @@ strip_size. The strip_size rpc param is deprecated.
Added spdk_thread_has_pollers() function to verify if there are
any registered pollers to be run on the thread.
Added spdk_thread_is_idle() function to check if there are any scheduled operations
to be performed on the thread at given time.
## v19.01:
### ocf bdev

View File

@ -140,7 +140,9 @@ spdk_fio_cleanup_thread(struct spdk_fio_thread *fio_thread)
{
spdk_thread_send_msg(fio_thread->thread, spdk_fio_bdev_close_targets, fio_thread);
while (spdk_fio_poll_thread(fio_thread) > 0) {}
while (!spdk_thread_is_idle(fio_thread->thread)) {
spdk_fio_poll_thread(fio_thread);
}
spdk_set_thread(fio_thread->thread);
@ -330,9 +332,7 @@ spdk_init_thread_poll(void *arg)
do {
spdk_fio_poll_thread(fio_thread);
} while (!done);
while (spdk_fio_poll_thread(fio_thread) > 0) {};
} while (!done && !spdk_thread_is_idle(fio_thread->thread));
spdk_fio_cleanup_thread(fio_thread);

View File

@ -277,6 +277,15 @@ int spdk_thread_has_active_pollers(struct spdk_thread *thread);
*/
bool spdk_thread_has_pollers(struct spdk_thread *thread);
/**
* Returns whether there are scheduled operations to be run on the thread.
*
* \param thread The thread to check.
*
* \return true if there are no scheduled operations, false otherwise.
*/
bool spdk_thread_is_idle(struct spdk_thread *thread);
/**
* Get count of allocated threads.
*/

View File

@ -560,6 +560,17 @@ spdk_thread_has_pollers(struct spdk_thread *thread)
return true;
}
bool
spdk_thread_is_idle(struct spdk_thread *thread)
{
if (spdk_ring_count(thread->messages) ||
spdk_thread_has_pollers(thread)) {
return false;
}
return true;
}
uint32_t
spdk_thread_get_count(void)
{