Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap calls from ebpf_drv.c in epoch calls #2189

Merged
merged 4 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix code analysis failure and test failure
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
  • Loading branch information
Alan-Jowett committed Mar 22, 2023
commit af0f635b0baa579d2c1b9776b9a95e6461d12ae0
4 changes: 2 additions & 2 deletions libs/platform/ebpf_epoch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 18 additions & 2 deletions tests/end_to_end/end_to_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down