Skip to content

Commit

Permalink
Switch to more performant API
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
  • Loading branch information
Alan Jowett committed Oct 22, 2024
1 parent 14df17e commit 5641ea7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
10 changes: 0 additions & 10 deletions libs/runtime/ebpf_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ ebpf_is_preemptible()
return irql < DISPATCH_LEVEL;
}

uint32_t
ebpf_get_current_cpu()
{
PROCESSOR_NUMBER processor_number;

KeGetCurrentProcessorNumberEx(&processor_number);

return KeGetProcessorIndexFromNumber(&processor_number);
}

uint64_t
ebpf_get_current_thread_id()
{
Expand Down
1 change: 1 addition & 0 deletions libs/runtime/ebpf_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ extern "C"
* running on. Only valid if ebpf_is_preemptible() == true.
* @retval Zero based index of CPUs.
*/
EBPF_INLINE_HINT
uint32_t
ebpf_get_current_cpu();

Expand Down
6 changes: 6 additions & 0 deletions libs/runtime/kernel/ebpf_platform_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,9 @@ _IRQL_requires_max_(PASSIVE_LEVEL) _Must_inspect_result_ ebpf_result_t

return EBPF_SUCCESS;
}

uint32_t
ebpf_get_current_cpu()
{
return KeGetCurrentProcessorIndex();
}
10 changes: 10 additions & 0 deletions libs/runtime/user/ebpf_platform_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,13 @@ _IRQL_requires_max_(PASSIVE_LEVEL) _Must_inspect_result_ ebpf_result_t
NTSTATUS status = usersim_platform_get_authentication_id(authentication_id);
return ntstatus_to_ebpf_result(status);
}

uint32_t
ebpf_get_current_cpu()
{
PROCESSOR_NUMBER processor_number;

KeGetCurrentProcessorNumberEx(&processor_number);

return KeGetProcessorIndexFromNumber(&processor_number);
}

0 comments on commit 5641ea7

Please sign in to comment.