Skip to content

Commit

Permalink
Only call ebpf_should_yield_processor every batch_size invocations (#…
Browse files Browse the repository at this point in the history
…2797)

Signed-off-by: Alan Jowett <[email protected]>
Co-authored-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett and Alan Jowett authored Aug 29, 2023
1 parent d5f4bd9 commit 8304ae2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions libs/execution_context/ebpf_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -2078,25 +2078,25 @@ _ebpf_program_test_run_work_item(_Inout_opt_ void* work_item_context)
// Start a new epoch every batch_size iterations.
if ((i % batch_size == (batch_size - 1))) {
ebpf_epoch_exit(epoch_state);
epoch_state = ebpf_epoch_enter();
}
ebpf_program_invoke(context->program, context->context, &return_value, &execution_context_state);
if (ebpf_should_yield_processor()) {
// Compute the elapsed time since the last yield.
end_time = ebpf_query_time_since_boot(false);
if (ebpf_should_yield_processor()) {
// Compute the elapsed time since the last yield.
end_time = ebpf_query_time_since_boot(false);

// Add the elapsed time to the cumulative time.
cumulative_time += end_time - start_time;
// Add the elapsed time to the cumulative time.
cumulative_time += end_time - start_time;

// Yield the CPU.
ebpf_lower_irql(old_irql);
// Yield the CPU.
ebpf_lower_irql(old_irql);

// Reacquire the CPU.
old_irql = ebpf_raise_irql(context->required_irql);
// Reacquire the CPU.
old_irql = ebpf_raise_irql(context->required_irql);

// Reset the start time.
start_time = ebpf_query_time_since_boot(false);
// Reset the start time.
start_time = ebpf_query_time_since_boot(false);
}
epoch_state = ebpf_epoch_enter(epoch_state);
}
ebpf_program_invoke(context->program, context->context, &return_value, &execution_context_state);
}
end_time = ebpf_query_time_since_boot(false);

Expand Down

0 comments on commit 8304ae2

Please sign in to comment.