diff --git a/libs/platform/ebpf_epoch.c b/libs/platform/ebpf_epoch.c index 48ba4052cf..124899a722 100644 --- a/libs/platform/ebpf_epoch.c +++ b/libs/platform/ebpf_epoch.c @@ -336,7 +336,7 @@ ebpf_epoch_enter() if (is_preemptible) { // Find the first available thread entry. ebpf_epoch_thread_entry_t* thread_entry = _ebpf_epoch_get_thread_entry(&_ebpf_epoch_cpu_table[current_cpu], 0); - ebpf_assert(thread_entry != NULL); + _Analysis_assume_(thread_entry != NULL); ebpf_assert(thread_entry->thread_id == 0); // Mark thread entry as in use. @@ -382,7 +382,7 @@ ebpf_epoch_exit() _ebpf_epoch_get_thread_entry(&_ebpf_epoch_cpu_table[current_cpu], thread_id); // Having a thread entry is a precondition for calling ebpf_epoch_exit(). - ebpf_assert(thread_entry != NULL); + _Analysis_assume_(thread_entry != NULL); ebpf_assert(thread_entry->thread_id == thread_id); // Mark thread entry as free. diff --git a/tests/end_to_end/end_to_end.cpp b/tests/end_to_end/end_to_end.cpp index fb141dc0e1..77445bab3c 100644 --- a/tests/end_to_end/end_to_end.cpp +++ b/tests/end_to_end/end_to_end.cpp @@ -2578,13 +2578,29 @@ TEST_CASE("load_native_program_invalid5", "[end-to-end]") { _load_invalid_program("invalid_maps3_um.dll", EBPF_EXECUTION_NATIVE, -EINVAL); } + +typedef struct _ebpf_scoped_non_preemptible +{ + _ebpf_scoped_non_preemptible() + { + ebpf_assert_success( + ebpf_set_current_thread_affinity((uintptr_t)1 << ebpf_get_current_cpu(), &old_thread_affinity)); + ebpf_non_preemptible = true; + } + ~_ebpf_scoped_non_preemptible() + { + ebpf_non_preemptible = false; + ebpf_restore_current_thread_affinity(old_thread_affinity); + } + uintptr_t old_thread_affinity = 0; +} ebpf_scoped_non_preemptible_t; + TEST_CASE("load_native_program_invalid5-non-preemptible", "[end-to-end]") { // Setting ebpf_non_preemptible to true will ensure ebpf_native_load queues // a workitem and that code path is executed. - ebpf_non_preemptible = true; + ebpf_scoped_non_preemptible_t non_preemptible; _load_invalid_program("invalid_maps3_um.dll", EBPF_EXECUTION_NATIVE, -EINVAL); - ebpf_non_preemptible = false; } #endif