From 067cd6229a47ea3ba8b59a2a04090e80afb5bd2c Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 11 Jul 2018 12:47:43 +0200 Subject: avoid using thread local storage for thread index It is cheaper to get thread index from vlib_main_t if available... Change-Id: I4582e160d06d9d7fccdc54271912f0635da79b50 Signed-off-by: Damjan Marion --- src/plugins/nat/dslite_in2out.c | 2 +- src/plugins/nat/dslite_out2in.c | 2 +- src/plugins/nat/in2out.c | 10 +++++----- src/plugins/nat/nat64.c | 4 ++-- src/plugins/nat/nat64_in2out.c | 6 +++--- src/plugins/nat/nat64_out2in.c | 6 +++--- src/plugins/nat/nat66_in2out.c | 2 +- src/plugins/nat/nat66_out2in.c | 2 +- src/plugins/nat/out2in.c | 10 +++++----- 9 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/plugins/nat') diff --git a/src/plugins/nat/dslite_in2out.c b/src/plugins/nat/dslite_in2out.c index ab0055cfee2..991d6eda775 100644 --- a/src/plugins/nat/dslite_in2out.c +++ b/src/plugins/nat/dslite_in2out.c @@ -228,7 +228,7 @@ dslite_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node, dslite_in2out_next_t next_index; u32 node_index; vlib_node_runtime_t *error_node; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; f64 now = vlib_time_now (vm); dslite_main_t *dm = &dslite_main; diff --git a/src/plugins/nat/dslite_out2in.c b/src/plugins/nat/dslite_out2in.c index 6bfc6e979cd..798367db6b1 100644 --- a/src/plugins/nat/dslite_out2in.c +++ b/src/plugins/nat/dslite_out2in.c @@ -101,7 +101,7 @@ dslite_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left_from, *from, *to_next; dslite_out2in_next_t next_index; vlib_node_runtime_t *error_node; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; f64 now = vlib_time_now (vm); dslite_main_t *dm = &dslite_main; diff --git a/src/plugins/nat/in2out.c b/src/plugins/nat/in2out.c index ae9c836b773..be1ddb3db7e 100755 --- a/src/plugins/nat/in2out.c +++ b/src/plugins/nat/in2out.c @@ -1100,7 +1100,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, snat_main_t * sm = &snat_main; f64 now = vlib_time_now (vm); u32 stats_node_index; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; stats_node_index = is_slow_path ? snat_in2out_slowpath_node.index : snat_in2out_node.index; @@ -2066,7 +2066,7 @@ nat44_in2out_reass_node_fn (vlib_main_t * vm, u32 pkts_processed = 0; snat_main_t *sm = &snat_main; f64 now = vlib_time_now (vm); - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; snat_main_per_thread_data_t *per_thread_data = &sm->per_thread_data[thread_index]; u32 *fragments_to_drop = 0; @@ -2985,7 +2985,7 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, snat_in2out_next_t next_index; snat_main_t *sm = &snat_main; f64 now = vlib_time_now (vm); - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index]; stats_node_index = is_slow_path ? nat44_ed_in2out_slowpath_node.index : @@ -3793,7 +3793,7 @@ snat_det_in2out_node_fn (vlib_main_t * vm, u32 pkts_processed = 0; snat_main_t * sm = &snat_main; u32 now = (u32) vlib_time_now (vm); - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -4558,7 +4558,7 @@ snat_in2out_worker_handoff_fn_inline (vlib_main_t * vm, u32 n_left_to_next_worker = 0, *to_next_worker = 0; u32 next_worker_index = 0; u32 current_worker_index = ~0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; u32 fq_index; u32 to_node_index; vlib_frame_t *d = 0; diff --git a/src/plugins/nat/nat64.c b/src/plugins/nat/nat64.c index 53c2caba2fa..1ca5e369b98 100644 --- a/src/plugins/nat/nat64.c +++ b/src/plugins/nat/nat64.c @@ -573,7 +573,7 @@ nat64_static_bib_worker_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { nat64_main_t *nm = &nat64_main; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; nat64_db_t *db = &nm->db[thread_index]; nat64_static_bib_to_update_t *static_bib; nat64_db_bib_entry_t *bibe; @@ -1155,7 +1155,7 @@ nat64_expire_worker_walk_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { nat64_main_t *nm = &nat64_main; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; nat64_db_t *db = &nm->db[thread_index]; u32 now = (u32) vlib_time_now (vm); diff --git a/src/plugins/nat/nat64_in2out.c b/src/plugins/nat/nat64_in2out.c index 6ff428bbb86..cdfe9b8d80c 100644 --- a/src/plugins/nat/nat64_in2out.c +++ b/src/plugins/nat/nat64_in2out.c @@ -922,7 +922,7 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node, nat64_in2out_next_t next_index; u32 pkts_processed = 0; u32 stats_node_index; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; stats_node_index = is_slow_path ? nat64_in2out_slowpath_node.index : nat64_in2out_node.index; @@ -1316,7 +1316,7 @@ nat64_in2out_reass_node_fn (vlib_main_t * vm, u32 *fragments_to_drop = 0; u32 *fragments_to_loopback = 0; nat64_main_t *nm = &nat64_main; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -1644,7 +1644,7 @@ nat64_in2out_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left_to_next_worker = 0, *to_next_worker = 0; u32 next_worker_index = 0; u32 current_worker_index = ~0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; u32 fq_index; u32 to_node_index; diff --git a/src/plugins/nat/nat64_out2in.c b/src/plugins/nat/nat64_out2in.c index f43d3e081b4..f7d4dd417f5 100644 --- a/src/plugins/nat/nat64_out2in.c +++ b/src/plugins/nat/nat64_out2in.c @@ -408,7 +408,7 @@ nat64_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left_from, *from, *to_next; nat64_out2in_next_t next_index; u32 pkts_processed = 0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -650,7 +650,7 @@ nat64_out2in_reass_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 *fragments_to_drop = 0; u32 *fragments_to_loopback = 0; nat64_main_t *nm = &nat64_main; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -930,7 +930,7 @@ nat64_out2in_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left_to_next_worker = 0, *to_next_worker = 0; u32 next_worker_index = 0; u32 current_worker_index = ~0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; u32 fq_index; u32 to_node_index; diff --git a/src/plugins/nat/nat66_in2out.c b/src/plugins/nat/nat66_in2out.c index d606bf46260..6bcf6ec667c 100644 --- a/src/plugins/nat/nat66_in2out.c +++ b/src/plugins/nat/nat66_in2out.c @@ -116,7 +116,7 @@ nat66_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left_from, *from, *to_next; nat66_in2out_next_t next_index; u32 pkts_processed = 0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; nat66_main_t *nm = &nat66_main; from = vlib_frame_vector_args (frame); diff --git a/src/plugins/nat/nat66_out2in.c b/src/plugins/nat/nat66_out2in.c index a28a4c3ade5..f264765448c 100644 --- a/src/plugins/nat/nat66_out2in.c +++ b/src/plugins/nat/nat66_out2in.c @@ -76,7 +76,7 @@ nat66_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left_from, *from, *to_next; nat66_out2in_next_t next_index; u32 pkts_processed = 0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; nat66_main_t *nm = &nat66_main; from = vlib_frame_vector_args (frame); diff --git a/src/plugins/nat/out2in.c b/src/plugins/nat/out2in.c index 1a1a1f1f639..ecfabc9c07a 100755 --- a/src/plugins/nat/out2in.c +++ b/src/plugins/nat/out2in.c @@ -653,7 +653,7 @@ snat_out2in_node_fn (vlib_main_t * vm, u32 pkts_processed = 0; snat_main_t * sm = &snat_main; f64 now = vlib_time_now (vm); - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -1256,7 +1256,7 @@ nat44_out2in_reass_node_fn (vlib_main_t * vm, u32 pkts_processed = 0; snat_main_t *sm = &snat_main; f64 now = vlib_time_now (vm); - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; snat_main_per_thread_data_t *per_thread_data = &sm->per_thread_data[thread_index]; u32 *fragments_to_drop = 0; @@ -2038,7 +2038,7 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm, nat44_ed_out2in_next_t next_index; snat_main_t *sm = &snat_main; f64 now = vlib_time_now (vm); - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index]; stats_node_index = is_slow_path ? nat44_ed_out2in_slowpath_node.index : @@ -2837,7 +2837,7 @@ snat_det_out2in_node_fn (vlib_main_t * vm, snat_out2in_next_t next_index; u32 pkts_processed = 0; snat_main_t * sm = &snat_main; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -3473,7 +3473,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm, u32 n_left_to_next_worker = 0, *to_next_worker = 0; u32 next_worker_index = 0; u32 current_worker_index = ~0; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index = vm->thread_index; vlib_frame_t *d = 0; ASSERT (vec_len (sm->workers)); -- cgit 1.2.3-korg