Skip to content

Commit

Permalink
Eliminate unneeded interlocked operation on LPM updates (#3239)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
Co-authored-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett and Alan Jowett authored Feb 5, 2024
1 parent 946a9d4 commit 060033c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/execution_context/ebpf_maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,10 @@ _update_lpm_map_entry(

ebpf_result_t result = _update_hash_map_entry(map, key, data, option);
if (result == EBPF_SUCCESS) {
ebpf_bitmap_set_bit((ebpf_bitmap_t*)trie_map->data, prefix_length, true);
// Test if the bit is set before setting it. This avoids the overhead of a the interlocked operation.
if (!ebpf_bitmap_test_bit((ebpf_bitmap_t*)trie_map->data, prefix_length)) {
ebpf_bitmap_set_bit((ebpf_bitmap_t*)trie_map->data, prefix_length, true);
}
}
return result;
}
Expand Down

0 comments on commit 060033c

Please sign in to comment.