aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/classify/vnet_classify.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-04-05 19:18:20 +0200
committerDave Barach <openvpp@barachs.net>2017-04-06 11:31:39 +0000
commit586afd762bfa149f5ca167bd5fd5a0cd59ce94fe (patch)
tree808b57c61e0fe1a181871bb1ad94398c5ba42671 /src/vnet/classify/vnet_classify.c
parentbc799c92d761a2d45105aa6a1685b3663687d2a4 (diff)
Use thread local storage for thread index
This patch deprecates stack-based thread identification, Also removes requirement that thread stacks are adjacent. Finally, possibly annoying for some folks, it renames all occurences of cpu_index and cpu_number with thread index. Using word "cpu" is misleading here as thread can be migrated ti different CPU, and also it is not related to linux cpu index. Change-Id: I68cdaf661e701d2336fc953dcb9978d10a70f7c1 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/classify/vnet_classify.c')
-rw-r--r--src/vnet/classify/vnet_classify.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c
index 98842a481b8..70a189b08ef 100644
--- a/src/vnet/classify/vnet_classify.c
+++ b/src/vnet/classify/vnet_classify.c
@@ -251,12 +251,12 @@ static inline void make_working_copy
vnet_classify_entry_##size##_t * working_copy##size = 0;
foreach_size_in_u32x4;
#undef _
- u32 cpu_number = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
- if (cpu_number >= vec_len (t->working_copies))
+ if (thread_index >= vec_len (t->working_copies))
{
oldheap = clib_mem_set_heap (t->mheap);
- vec_validate (t->working_copies, cpu_number);
+ vec_validate (t->working_copies, thread_index);
clib_mem_set_heap (oldheap);
}
@@ -265,7 +265,7 @@ static inline void make_working_copy
* updates from multiple threads will not result in sporadic, spurious
* lookup failures.
*/
- working_copy = t->working_copies[cpu_number];
+ working_copy = t->working_copies[thread_index];
t->saved_bucket.as_u64 = b->as_u64;
oldheap = clib_mem_set_heap (t->mheap);
@@ -290,7 +290,7 @@ static inline void make_working_copy
default:
abort();
}
- t->working_copies[cpu_number] = working_copy;
+ t->working_copies[thread_index] = working_copy;
}
_vec_len(working_copy) = (1<<b->log2_pages)*t->entries_per_page;
@@ -318,7 +318,7 @@ static inline void make_working_copy
working_bucket.offset = vnet_classify_get_offset (t, working_copy);
CLIB_MEMORY_BARRIER();
b->as_u64 = working_bucket.as_u64;
- t->working_copies[cpu_number] = working_copy;
+ t->working_copies[thread_index] = working_copy;
}
static vnet_classify_entry_t *
@@ -387,7 +387,7 @@ int vnet_classify_add_del (vnet_classify_table_t * t,
int i;
u64 hash, new_hash;
u32 new_log2_pages;
- u32 cpu_number = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
u8 * key_minus_skip;
ASSERT ((add_v->flags & VNET_CLASSIFY_ENTRY_FREE) == 0);
@@ -498,7 +498,7 @@ int vnet_classify_add_del (vnet_classify_table_t * t,
new_log2_pages = t->saved_bucket.log2_pages + 1;
expand_again:
- working_copy = t->working_copies[cpu_number];
+ working_copy = t->working_copies[thread_index];
new_v = split_and_rehash (t, working_copy, new_log2_pages);
if (new_v == 0)