Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Use thread local storage for thread index
[vpp.git]
/
src
/
vpp
/
stats
/
stats.c
diff --git
a/src/vpp/stats/stats.c
b/src/vpp/stats/stats.c
index
042d02e
..
4309cd5
100644
(file)
--- a/
src/vpp/stats/stats.c
+++ b/
src/vpp/stats/stats.c
@@
-66,14
+66,14
@@
_(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
void
dslock (stats_main_t * sm, int release_hint, int tag)
{
void
dslock (stats_main_t * sm, int release_hint, int tag)
{
- u32 thread_i
d
;
+ u32 thread_i
ndex
;
data_structure_lock_t *l = sm->data_structure_lock;
if (PREDICT_FALSE (l == 0))
return;
data_structure_lock_t *l = sm->data_structure_lock;
if (PREDICT_FALSE (l == 0))
return;
- thread_i
d = os_get_cpu_number
();
- if (l->lock && l->thread_i
d == thread_id
)
+ thread_i
ndex = vlib_get_thread_index
();
+ if (l->lock && l->thread_i
ndex == thread_index
)
{
l->count++;
return;
{
l->count++;
return;
@@
-85,7
+85,7
@@
dslock (stats_main_t * sm, int release_hint, int tag)
while (__sync_lock_test_and_set (&l->lock, 1))
/* zzzz */ ;
l->tag = tag;
while (__sync_lock_test_and_set (&l->lock, 1))
/* zzzz */ ;
l->tag = tag;
- l->thread_i
d = thread_id
;
+ l->thread_i
ndex = thread_index
;
l->count = 1;
}
l->count = 1;
}
@@
-99,14
+99,14
@@
stats_dslock_with_hint (int hint, int tag)
void
dsunlock (stats_main_t * sm)
{
void
dsunlock (stats_main_t * sm)
{
- u32 thread_i
d
;
+ u32 thread_i
ndex
;
data_structure_lock_t *l = sm->data_structure_lock;
if (PREDICT_FALSE (l == 0))
return;
data_structure_lock_t *l = sm->data_structure_lock;
if (PREDICT_FALSE (l == 0))
return;
- thread_i
d = os_get_cpu_number
();
- ASSERT (l->lock && l->thread_i
d == thread_id
);
+ thread_i
ndex = vlib_get_thread_index
();
+ ASSERT (l->lock && l->thread_i
ndex == thread_index
);
l->count--;
if (l->count == 0)
{
l->count--;
if (l->count == 0)
{