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

[vioscsi] Implement cold and hot tracing paths #1228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benyamin-codez
Copy link
Contributor

  1. Introduced three (3) compile-time environment variables:
    a) RUN_WPP_ALL_PATHS
    Compile WPP for the hot path too.
    Is the inverse of RUN_COLD_PATH_ONLY, which is the default behaviour.
    b) FORCE_RUN_UNCHECKED
    Run without EVENT_TRACING or DBG. Defines RUN_UNCHECKED.
    c) FORCE_RUN_DEBUG
    Run with DBG rather than EVENT_TRACING. Undefines EVENT_TRACING.

  2. WPP scans for WPP config on a per file basis. Sections of the config file cannot be excluded and conditional macros will be ignored. To solve this, we establish two new files with WPP configuration data. One holds exclusively cold path data (wpp_cold_path.h) and the other holds data for all paths (wpp_all_paths.h). Which file to use is set conditionally per the vioscsi.vcxproj project file configuration.

  3. The hot path DBG and WPP macro variants are a clone of the cold path macros, but with a "_HP" suffix. The exception to this is RhelDbgPrint() which we extend as RhelDbgPrintHotPath().

  4. Encapsulated exisitng cold and and hot trace messages in compile-time conditional macros and in same manner drops *.tmh includes when necessary. The general format for the cold path is #if !defined(RUN_UNCHECKED) and for the hot path #if !defined(RUN_UNCHECKED) || !defined(RUN_COLD_PATH_ONLY).

  5. Minor refactoring of:
    a) helper.c - GetScsiConfig()
    b) helper.c - SetGuestFeatures()

  6. Major refactoring of:
    a) trace.h
    b) vioscsi.c - VioScsiHwInitialize() - corrects order of init for benefit of clean trace.

  7. Major new instrumentation of:
    a) helper.c - InitVirtIODevice()

  8. Reconfigured the following for INLINE function tracing:
    a) vioscsi.c - HandleResponse()
    b) vioscsi.c - PreProcessRequest()
    c) vioscsi.c - PostProcessRequest()
    d) vioscsi.c - DispatchQueue()

  9. Mnemonic rename of VioScsiPassiveInitializeRoutine() to VioScsiPassiveDpcInitializeRoutine().

  10. Correct struct virtio_bar for bMemorySpace rather than bPortSpace (vioscsi.h and virtio_pci.c).

  11. Add missing structs for PCI Capabilities (vioscsi.h).

  12. Included stddef.h for offsetof function.

Hard to split this one up further methinks.
I do have a fair bit of additional instrumentation to merge after this one.

1. Introduced three (3) compile-time environment variables:
   RUN_WPP_ALL_PATHS   - Compile WPP for the hot path too.
                         Is the inverse of RUN_COLD_PATH_ONLY, which is the default behaviour.
   FORCE_RUN_UNCHECKED - Run without EVENT_TRACING or DBG. Defines RUN_UNCHECKED.
   FORCE_RUN_DEBUG     - Run with DBG rather than EVENT_TRACING. Undefines EVENT_TRACING.

2. WPP scans for WPP config on a per file basis. Sections of the config file cannot be excluded
    and conditional macros will be ignored. To solve this, we establish two new files with WPP
    configuration data. One holds exclusively cold path data (wpp_cold_path.h) and the other
    holds data for all paths (wpp_all_paths.h). Which file to use is set conditionally per the
    vioscsi.vcxproj project file configuration.

3. The hot path DBG and WPP macro variants are a clone of the cold path macros, but with a "_HP"
    suffix. The exception to this is RhelDbgPrint() which we extend as RhelDbgPrintHotPath().

4. Encapsulated exisitng cold and and hot trace messages in compile-time conditional macros and
    in same manner drops *.tmh includes when necessary.

5. Minor refactoring of:
    a) helper.c - GetScsiConfig()
    b) helper.c - SetGuestFeatures()

6. Major refactoring of:
    a) trace.h
    b) vioscsi.c - VioScsiHwInitialize() - corrects order of init for benefit of clean trace.

7. Major new instrumentation of:
    a) helper.c - InitVirtIODevice()

8. Reconfigured the following for INLINE function tracing:
    a) vioscsi.c - HandleResponse()
    b) vioscsi.c - PreProcessRequest()
    c) vioscsi.c - PostProcessRequest()
    d) vioscsi.c - DispatchQueue()

9. Mnemonic rename of VioScsiPassiveInitializeRoutine() to VioScsiPassiveDpcInitializeRoutine().

10. Correct struct virtio_bar for bMemorySpace rather than bPortSpace (vioscsi.h and virtio_pci.c).

11. Add missing structs for PCI Capabilities (vioscsi.h).

Hard to split this one up further methinks.
I do have a fair bit of additional instrumentation to merge after this one.

Signed-off-by: benyamin-codez <[email protected]>
@benyamin-codez
Copy link
Contributor Author

Note somewhat cheeky inclusion to raise the NTDDI_VERSION for Win11 builds to NTDDI_WIN10_CO, i.e. Cobalt / 21H2.

<ItemDefinitionGroup Condition="'$(Configuration)'=='Win11 Release'">
<ClCompile>
<PreprocessorDefinitions Condition="'$(DisableTracing)'=='true'">%(PreprocessorDefinitions);RUN_UNCHECKED=1</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(LimitPathsWPP)'=='WPPColdPathOnly'">%(PreprocessorDefinitions);RUN_COLD_PATH_ONLY=1</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(UseDebugTracing)'!='true'">%(PreprocessorDefinitions);EVENT_TRACING=1</PreprocessorDefinitions>
<PreprocessorDefinitions>%(PreprocessorDefinitions);NTDDI_VERSION=NTDDI_WIN10_CO</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>

benyamin-codez added a commit to benyamin-codez/kvm-guest-drivers-windows that referenced this pull request Dec 21, 2024
Addendum to b6edb81, b7904fc and acaf26d.

1. Split NTDDI_ definitions to new file ntddi_ver.h with minor refactor.
2. Minor refactor for RegistryPath reporting to appear outside of conditional.
3. Removed references to obsoleted RUN_MIN_CHECKED definition (PR virtio-win#1228).

Signed-off-by: benyamin-codez <[email protected]>
benyamin-codez added a commit to benyamin-codez/kvm-guest-drivers-windows that referenced this pull request Dec 21, 2024
Addendum to 100af3e.

1. Removed references to obsoleted RUN_MIN_CHECKED definition (PR virtio-win#1228).
2. Add comment to conditionally excluded variable.

Signed-off-by: benyamin-codez <[email protected]>
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.

1 participant