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

Add JIT & Interpreter build switches. #2031

Merged

Conversation

gtrevi
Copy link
Contributor

@gtrevi gtrevi commented Feb 4, 2023

Closes #1883

Description

This PR adds two build switches for individually disabling the JIT compiler and the interpreter, as well as adding the corresponding support into code and project files.

Testing

CI/CD pipeline.

Documentation

GettingStarted.md

@gtrevi gtrevi changed the title Gtrevi/add jit interpreter build switches Add JIT & Interpreter build switches. Feb 4, 2023
@codecov
Copy link

codecov bot commented Feb 4, 2023

Codecov Report

Merging #2031 (91a8b37) into main (c4f8f96) will increase coverage by 0.25%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2031      +/-   ##
==========================================
+ Coverage   82.41%   82.66%   +0.25%     
==========================================
  Files         141      152      +11     
  Lines       25402    27546    +2144     
==========================================
+ Hits        20935    22771    +1836     
- Misses       4467     4775     +308     
Impacted Files Coverage Δ
libs/execution_context/ebpf_core.c 92.25% <ø> (+1.62%) ⬆️
tests/sample/ext/app/sample_ext_app.cpp 98.59% <ø> (ø)
libs/execution_context/ebpf_program.c 82.40% <100.00%> (+1.87%) ⬆️
tests/api_test/api_test.cpp 97.54% <100.00%> (ø)
ebpfapi/rpc_client.cpp 56.14% <0.00%> (-1.01%) ⬇️
tools/bpf2c/bpf_code_generator.h 93.44% <0.00%> (ø)
x64/Release/Elf.c 0.00% <0.00%> (ø)
x64/Release/EverParse.h 0.00% <0.00%> (ø)
tests/bpf2c_tests/test_helpers.h 87.50% <0.00%> (ø)
tools/bpf2c/bpf_code_generator.cpp 96.67% <0.00%> (ø)
... and 40 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

docs/GettingStarted.md Show resolved Hide resolved
docs/GettingStarted.md Outdated Show resolved Hide resolved
dthaler
dthaler previously approved these changes Feb 4, 2023
cmake/options.cmake Outdated Show resolved Hide resolved
@@ -407,10 +413,12 @@ divide_by_zero_test_km(ebpf_execution_type_t execution_type)
// If we don't bug-check, the test passed.
}

#if !defined(CONFIG_BPF_JIT_DISABLED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we running the api_tests on 2 different flavors of the build (one which has JIT disabled and one which has JIT enabled)? If not, we will lose test coverage in kernel tests for JIT scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, none of the testes use the regular_native-only build, which is the only using the new switches.
Coverage and more will be taken care of on #2030.

Copy link
Collaborator

@dthaler dthaler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but see suggestion

@@ -3,7 +3,8 @@

option(EBPFFORWINDOWS_ENABLE_TESTS "Set to true to enable tests" true)
option(EBPFFORWINDOWS_ENABLE_INSTALL "Set to true to enable the install target")
option(EBPFFORWINDOWS_ENABLE_DISABLE_EBPF_INTERPRETER "Set to true to compile with the interpreter always disabled")
option(EBPFFORWINDOWS_DISABLE_JIT "Set to true to compile with the JIT compiler disabled")
option(EBPFFORWINDOWS_DISABLE_INTERPRETER "Set to true to compile with the Interpreter disabled")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the interpreter should be off by default, can we reverse the parity and require setting it to true to compile with the interpreter enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dthaler This was discussed internally, would alter the UX on Visual Studio, where you will have to build via CLI if you want the Interpreter enabled.

Copy link
Contributor Author

@gtrevi gtrevi Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: should the interpreter is disabled by default in Release builds (i.e., regardless of the switch)?

@@ -94,7 +94,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;%(PreprocessorDefinitions);_NO_CRT_STDIO_INLINE=1;CONFIG_BPF_JIT_ALWAYS_ON=1</PreprocessorDefinitions>
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;%(PreprocessorDefinitions);_NO_CRT_STDIO_INLINE=1;</PreprocessorDefinitions>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add CONFIG_BPF_INTERPRETER_DISABLED since we are now removing CONFIG_BPF_JIT_ALWAYS_ON?

@@ -67,7 +67,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;CONFIG_BPF_JIT_ALWAYS_ON=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above: Should we add CONFIG_BPF_INTERPRETER_DISABLED here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, it's now moved to the Directory.Build.props for global control.

@@ -67,7 +67,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;CONFIG_BPF_JIT_ALWAYS_ON=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, it's now moved to the Directory.Build.props for global control.

@dthaler dthaler enabled auto-merge (squash) February 7, 2023 14:19
@dthaler dthaler merged commit 694485a into microsoft:main Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide compile time option to disable JIT (similar to the interpreter option).
4 participants