From: Cunming Liang Date: Tue, 17 Feb 2015 02:08:12 +0000 (+0800) Subject: spinlock: support non-EAL thread X-Git-Tag: spdx-start~9569 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ca2e2dab079a98f105c8e73ebaf1a27e246597f8;p=dpdk.git spinlock: support non-EAL thread In non-EAL thread, lcore_id always be LCORE_ID_ANY. It can't be used as unique id for recursive spinlock. Then use rte_gettid() to replace it. Signed-off-by: Cunming Liang Acked-by: Olivier Matz Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_eal/common/include/generic/rte_spinlock.h b/lib/librte_eal/common/include/generic/rte_spinlock.h index dea885c349..c7fb0dfa29 100644 --- a/lib/librte_eal/common/include/generic/rte_spinlock.h +++ b/lib/librte_eal/common/include/generic/rte_spinlock.h @@ -179,7 +179,7 @@ static inline void rte_spinlock_recursive_init(rte_spinlock_recursive_t *slr) */ static inline void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr) { - int id = rte_lcore_id(); + int id = rte_gettid(); if (slr->user != id) { rte_spinlock_lock(&slr->sl); @@ -212,7 +212,7 @@ static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr) */ static inline int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr) { - int id = rte_lcore_id(); + int id = rte_gettid(); if (slr->user != id) { if (rte_spinlock_trylock(&slr->sl) == 0) diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index e1bd974c68..20a58eb392 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -87,7 +87,7 @@ RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread "cpuset". */ /** * Return the ID of the execution unit we are running on. * @return - * Logical core ID(in EAL thread) or LCORE_ID_ANY(in non-EAL thread) + * Logical core ID (in EAL thread) or LCORE_ID_ANY (in non-EAL thread) */ static inline unsigned rte_lcore_id(void)