spinlock: support non-EAL thread
authorCunming Liang <cunming.liang@intel.com>
Tue, 17 Feb 2015 02:08:12 +0000 (10:08 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 24 Feb 2015 19:22:48 +0000 (20:22 +0100)
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 <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
lib/librte_eal/common/include/generic/rte_spinlock.h
lib/librte_eal/common/include/rte_lcore.h

index dea885c..c7fb0df 100644 (file)
@@ -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)
index e1bd974..20a58eb 100644 (file)
@@ -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)