lib/thread: Add spdk_thread_get_by_id() API to get thread whose ID matches
Add an new API spdk_thread_get_by_id(). This will be used in the subsequent patches to set the cpumask of the running thread to the specified value. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ib5d02b9d7b499477c43e6527cf8f603d8323e063 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/966 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
515733ca4a
commit
ee8134099a
@ -372,6 +372,14 @@ const char *spdk_thread_get_name(const struct spdk_thread *thread);
|
||||
*/
|
||||
uint64_t spdk_thread_get_id(const struct spdk_thread *thread);
|
||||
|
||||
/**
|
||||
* Get the thread by the ID.
|
||||
*
|
||||
* \param id ID of the thread.
|
||||
* \return Thread whose ID matches or NULL otherwise.
|
||||
*/
|
||||
struct spdk_thread *spdk_thread_get_by_id(uint64_t id);
|
||||
|
||||
struct spdk_thread_stats {
|
||||
uint64_t busy_tsc;
|
||||
uint64_t idle_tsc;
|
||||
|
@ -735,6 +735,24 @@ spdk_thread_get_id(const struct spdk_thread *thread)
|
||||
return thread->id;
|
||||
}
|
||||
|
||||
struct spdk_thread *
|
||||
spdk_thread_get_by_id(uint64_t id)
|
||||
{
|
||||
struct spdk_thread *thread;
|
||||
|
||||
pthread_mutex_lock(&g_devlist_mutex);
|
||||
TAILQ_FOREACH(thread, &g_threads, tailq) {
|
||||
if (thread->id == id) {
|
||||
pthread_mutex_unlock(&g_devlist_mutex);
|
||||
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&g_devlist_mutex);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_thread_get_stats(struct spdk_thread_stats *stats)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user