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

i#4014 dr$sim phys: Add offline -use_physical support #5516

Merged
merged 6 commits into from
Jun 7, 2022

Conversation

derekbruening
Copy link
Contributor

Adds support for physical addresses to offline dr$sim traces. To
support simulators wanting both virtual and physical addresses, and to
simplify post-processing where the virtual PC values are needed, the
regular trace entries remain all virtual. A new marker type
TRACE_MARKER_TYPE_PHYSICAL_ADDRESS listing the corresponding physical
address is added. The mappings are assumed to not change, allowing
just one marker for each newly-observed page. This is done
per-thread.

An explicit TRACE_MARKER_TYPE_PHYSICAL_ADDRESS_NOT_AVAILABLE marker is
inserted on failure to translate, to prevent analyzers from having to
infer this due to the lack of the already-sparse markers.

Separately emitted pairs of virtual and physical address markers were
considered, with raw2trace inserting the physical at the right place,
but that presents complexities with buffer handoff and with the first
buffer. Instead, the physical are inserted via memmove directly into
the buffer. This does not seem to be a performance concern: the
translation lookup is the bottleneck.

Adds support for the new markers to the view tool.

Adds a Linux x86_64 test that runs a tiny asm app and ensures a
physical address marker is inserted. The test needs to run as sudo,
along with its pre- and post- commands. Currently it is enabled
everywhere, so a user running interactive tests will have it pause
while it waits for input. This might cause issues with manually
running the test suite.

A number of items remain for further work:

  • Performance is poor: the hashtable and caching need improvement.
  • There is a hardcoded limit on how many markers can be added
    per buffer. Once this is exceeded, further markers are dropped.
    We should split the buffer to handle this.
  • We may want to add a mode that checks for mapping changes.
  • Missing privileges results in every physical address being 0 instead
    of showing the failure. We need to check the capabilities to distinguish.
  • Better testing that we're actually getting physical addresses for online
    tests.
  • Better offline testing with larger apps.
  • Basic blocks that cross a page have only the first one translated.
  • A file descriptor per thread is used, which will not scale well with
    DR's descriptor protection and might hit rlimits.

Issue: #4014

Adds support for physical addresses to offline dr$sim traces.  To
support simulators wanting both virtual and physical addresses, and to
simplify post-processing where the virtual PC values are needed, the
regular trace entries remain all virtual.  A new marker type
TRACE_MARKER_TYPE_PHYSICAL_ADDRESS listing the corresponding physical
address is added.  The mappings are assumed to not change, allowing
just one marker for each newly-observed page.  This is done
per-thread.

An explicit TRACE_MARKER_TYPE_PHYSICAL_ADDRESS_NOT_AVAILABLE marker is
inserted on failure to translate, to prevent analyzers from having to
infer this due to the lack of the already-sparse markers.

Separately emitted pairs of virtual and physical address markers were
considered, with raw2trace inserting the physical at the right place,
but that presents complexities with buffer handoff and with the first
buffer.  Instead, the physical are inserted via memmove directly into
the buffer.  This does not seem to be a performance concern: the
translation lookup is the bottleneck.

Adds support for the new markers to the view tool.

Adds a Linux x86_64 test that runs a tiny asm app and ensures a
physical address marker is inserted.  The test needs to run as sudo,
along with its pre- and post- commands.  Currently it is enabled
everywhere, so a user running interactive tests will have it pause
while it waits for input.  This might cause issues with manually
running the test suite.

A number of items remain for further work:
+ Performance is poor: the hashtable and caching need improvement.
+ There is a hardcoded limit on how many markers can be added
  per buffer.  Once this is exceeded, further markers are dropped.
  We should split the buffer to handle this.
+ We may want to add a mode that checks for mapping changes.
+ Missing privileges results in every physical address being 0 instead
  of showing the failure.  We need to check the capabilities to distinguish.
+ Better testing that we're actually getting physical addresses for online
  tests.
+ Better offline testing with larger apps.
+ Basic blocks that cross a page have only the first one translated.
+ A file descriptor per thread is used, which will not scale well with
  DR's descriptor protection and might hit rlimits.

Issue: #4014
@derekbruening
Copy link
Contributor Author

The failure is the known flake #5514

clients/drcachesim/common/trace_entry.h Show resolved Hide resolved
clients/drcachesim/tools/view.cpp Show resolved Hide resolved
clients/drcachesim/tracer/tracer.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tracer/tracer.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tracer/tracer.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tracer/instru_offline.cpp Show resolved Hide resolved
clients/drcachesim/tracer/physaddr.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tracer/physaddr.h Show resolved Hide resolved
suite/tests/CMakeLists.txt Show resolved Hide resolved
clients/drcachesim/tracer/tracer.cpp Show resolved Hide resolved
@derekbruening
Copy link
Contributor Author

scattergather again failed: #5329

@derekbruening derekbruening merged commit d96d930 into master Jun 7, 2022
@derekbruening derekbruening deleted the i4014-phys-offline branch June 7, 2022 15:35
dolanzhao pushed a commit that referenced this pull request Jun 8, 2022
Adds support for physical addresses to offline dr$sim traces.  To
support simulators wanting both virtual and physical addresses, and to
simplify post-processing where the virtual PC values are needed, the
regular trace entries remain all virtual.  A new marker type
TRACE_MARKER_TYPE_PHYSICAL_ADDRESS listing the corresponding physical
address is added.  The mappings are assumed to not change, allowing
just one marker for each newly-observed page.  This is done
per-thread.

An explicit TRACE_MARKER_TYPE_PHYSICAL_ADDRESS_NOT_AVAILABLE marker is
inserted on failure to translate, to prevent analyzers from having to
infer this due to the lack of the already-sparse markers.

Separately emitted pairs of virtual and physical address markers were
considered, with raw2trace inserting the physical at the right place,
but that presents complexities with buffer handoff and with the first
buffer.  Instead, the physical are inserted via memmove directly into
the buffer.  This does not seem to be a performance concern: the
translation lookup is the bottleneck.  Since the memmoves occur only on the
first instance of each page, they are much rarer than all the virtual-to-physical
translations.

Adds support for the new markers to the view tool.

Adds a Linux x86_64 test that runs a tiny asm app and ensures a
physical address marker is inserted.  The test needs to run as sudo,
along with its pre- and post- commands.  To avoid a confusing blocking
password query in local runs, a new set of tests controlled by a new
CMake option RUN_SUDO_TESTS is added.  It is set only for automated_ci,
where we assume a passwordless sudo.

A number of items remain for further work:
+ Performance is poor: the hashtable and caching need improvement.
+ There is a hardcoded limit on how many markers can be added
  per buffer.  Once this is exceeded, further markers are dropped.
  We should split the buffer to handle this.
+ We may want to add a mode that checks for mapping changes.
+ Missing privileges results in every physical address being 0 instead
  of showing the failure.  We need to check the capabilities to distinguish.
+ Better testing that we're actually getting physical addresses for online
  tests.
+ Better offline testing with larger apps.
+ Basic blocks that cross a page have only the first one translated.
+ A file descriptor per thread is used, which will not scale well with
  DR's descriptor protection and might hit rlimits.
+ Online traces still replace all virtual addresses with physical.
  We should break compatibility and transition them to use these markers,
  with dr$sim computing the physical addresses from the markers.

Issue: #4014
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.

2 participants