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

Speedup ebpf_handle_table_terminate by avoiding acquire/release of lock #3605

Merged
merged 7 commits into from
Jun 25, 2024
9 changes: 7 additions & 2 deletions libs/runtime/user/ebpf_handle_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ ebpf_handle_table_terminate()
EBPF_RETURN_VOID();
}

ebpf_lock_state_t state;
state = ebpf_lock_lock(&_ebpf_handle_table_lock);
for (handle = 0; handle < EBPF_COUNT_OF(_ebpf_handle_table); handle++) {
// Ignore invalid handle close.
(void)ebpf_handle_close(handle);
if (_ebpf_handle_table[handle] != NULL) {
EBPF_OBJECT_RELEASE_REFERENCE_INDIRECT(_ebpf_handle_table[handle]);
_ebpf_handle_table[handle] = NULL;
}
}
ebpf_lock_unlock(&_ebpf_handle_table_lock, state);
_ebpf_handle_table_initiated = false;
EBPF_RETURN_VOID();
}
Expand Down
2 changes: 2 additions & 0 deletions tests/end_to_end/end_to_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ ebpf_program_load(
}
}
bpf_object__close(new_object);
// Add delay to permit the native module handle cleanup to complete.
std::this_thread::sleep_for(std::chrono::milliseconds(100));
return error;
}

Expand Down
Loading