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
1927da0
..
4309cd5
100644
(file)
--- a/
src/vpp/stats/stats.c
+++ b/
src/vpp/stats/stats.c
@@
-17,6
+17,7
@@
#include <vlib/threads.h>
#include <vnet/fib/fib_entry.h>
#include <vnet/fib/fib_table.h>
#include <vlib/threads.h>
#include <vnet/fib/fib_entry.h>
#include <vnet/fib/fib_table.h>
+#include <vnet/fib/ip4_fib.h>
#include <vnet/dpo/load_balance.h>
#define STATS_DEBUG 0
#include <vnet/dpo/load_balance.h>
#define STATS_DEBUG 0
@@
-65,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;
@@
-84,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;
}
@@
-98,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)
{
@@
-576,6
+577,7
@@
do_ip4_fibs (stats_main_t * sm)
static ip4_route_t *routes;
ip4_route_t *r;
fib_table_t *fib;
static ip4_route_t *routes;
ip4_route_t *r;
fib_table_t *fib;
+ ip4_fib_t *v4_fib;
ip_lookup_main_t *lm = &im4->lookup_main;
static uword *results;
vl_api_vnet_ip4_fib_counters_t *mp = 0;
ip_lookup_main_t *lm = &im4->lookup_main;
static uword *results;
vl_api_vnet_ip4_fib_counters_t *mp = 0;
@@
-592,6
+594,8
@@
again:
while ((fib - im4->fibs) < start_at_fib_index)
continue;
while ((fib - im4->fibs) < start_at_fib_index)
continue;
+ v4_fib = pool_elt_at_index (im4->v4_fibs, fib->ft_index);
+
if (mp == 0)
{
items_this_message = IP4_FIB_COUNTER_BATCH_SIZE;
if (mp == 0)
{
items_this_message = IP4_FIB_COUNTER_BATCH_SIZE;
@@
-615,9
+619,9
@@
again:
vec_reset_length (routes);
vec_reset_length (results);
vec_reset_length (routes);
vec_reset_length (results);
- for (i = 0; i < ARRAY_LEN (
fib->v4.
fib_entry_by_dst_address); i++)
+ for (i = 0; i < ARRAY_LEN (
v4_fib->
fib_entry_by_dst_address); i++)
{
{
- uword *hash =
fib->v4.
fib_entry_by_dst_address[i];
+ uword *hash =
v4_fib->
fib_entry_by_dst_address[i];
hash_pair_t *p;
ip4_route_t x;
hash_pair_t *p;
ip4_route_t x;