summaryrefslogtreecommitdiffstats
path: root/src/vlib/counter.h
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/vlib/counter.h
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/vlib/counter.h')
-rw-r--r--src/vlib/counter.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/vlib/counter.h b/src/vlib/counter.h
index 17a8521776b..60e2055d232 100644
--- a/src/vlib/counter.h
+++ b/src/vlib/counter.h
@@ -70,17 +70,17 @@ u32 vlib_simple_counter_n_counters (const vlib_simple_counter_main_t * cm);
/** Increment a simple counter
@param cm - (vlib_simple_counter_main_t *) simple counter main pointer
- @param cpu_index - (u32) the current cpu index
+ @param thread_index - (u32) the current cpu index
@param index - (u32) index of the counter to increment
@param increment - (u64) quantitiy to add to the counter
*/
always_inline void
vlib_increment_simple_counter (vlib_simple_counter_main_t * cm,
- u32 cpu_index, u32 index, u64 increment)
+ u32 thread_index, u32 index, u64 increment)
{
counter_t *my_counters;
- my_counters = cm->counters[cpu_index];
+ my_counters = cm->counters[thread_index];
my_counters[index] += increment;
}
@@ -201,7 +201,7 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm);
/** Increment a combined counter
@param cm - (vlib_combined_counter_main_t *) comined counter main pointer
- @param cpu_index - (u32) the current cpu index
+ @param thread_index - (u32) the current cpu index
@param index - (u32) index of the counter to increment
@param packet_increment - (u64) number of packets to add to the counter
@param byte_increment - (u64) number of bytes to add to the counter
@@ -209,13 +209,13 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm);
always_inline void
vlib_increment_combined_counter (vlib_combined_counter_main_t * cm,
- u32 cpu_index,
+ u32 thread_index,
u32 index, u64 n_packets, u64 n_bytes)
{
vlib_counter_t *my_counters;
/* Use this CPU's counter array */
- my_counters = cm->counters[cpu_index];
+ my_counters = cm->counters[thread_index];
my_counters[index].packets += n_packets;
my_counters[index].bytes += n_bytes;
@@ -224,14 +224,14 @@ vlib_increment_combined_counter (vlib_combined_counter_main_t * cm,
/** Pre-fetch a per-thread combined counter for the given object index */
always_inline void
vlib_prefetch_combined_counter (const vlib_combined_counter_main_t * cm,
- u32 cpu_index, u32 index)
+ u32 thread_index, u32 index)
{
vlib_counter_t *cpu_counters;
/*
* This CPU's index is assumed to already be in cache
*/
- cpu_counters = cm->counters[cpu_index];
+ cpu_counters = cm->counters[thread_index];
CLIB_PREFETCH (cpu_counters + index, CLIB_CACHE_LINE_BYTES, STORE);
}