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#7050: Remove preempted and faulting instruction from the drmemtraces. #7058

Merged
merged 33 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
05ddb8a
i#7050: reset expected read and write record counts after a kernel tr…
ivankyluk Oct 22, 2024
b1feaeb
Merge branch 'master' into i7050-reset-expected-read-write-record-counts
ivankyluk Oct 22, 2024
0ffeb9e
Merge branch 'master' into i7050-reset-expected-read-write-record-counts
ivankyluk Oct 28, 2024
da6d3fa
Merge branch 'master' into i7050-reset-expected-read-write-record-counts
ivankyluk Oct 28, 2024
f02cd07
Merge branch 'master' into i7050-remove-preempted-instructions
ivankyluk Oct 28, 2024
f3ee810
Merge branch 'i7050-reset-expected-read-write-record-counts' of githu…
ivankyluk Oct 28, 2024
1ede682
Adding debug to confirm aarchxx results.
ivankyluk Oct 28, 2024
10c8705
Update signal_invariants.c to ignore preempted instr and memref.
ivankyluk Oct 28, 2024
7b699a1
Merge branch 'master' of github.com:DynamoRIO/dynamorio into i7050-re…
ivankyluk Nov 6, 2024
34936a1
Incorporate review comments.
ivankyluk Nov 8, 2024
5e4e80b
Merge branch 'master' into i7050-remove-preempted-instructions
ivankyluk Nov 8, 2024
565146f
clang-format fix.
ivankyluk Nov 8, 2024
d1168dd
Fix a copy and paste error in the code.
ivankyluk Nov 8, 2024
685f58a
Add TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION check to Interrupt mark…
ivankyluk Nov 8, 2024
8f978b8
fix format error.
ivankyluk Nov 8, 2024
232d8b8
Add a rep string test.
ivankyluk Nov 8, 2024
4ee03b5
Update comment to specify the code is checking rseq abort.
ivankyluk Nov 9, 2024
3acb121
Merge branch 'master' into i7050-remove-preempted-instructions
ivankyluk Nov 11, 2024
fd8a108
Incorporate review comments.
ivankyluk Nov 11, 2024
9fb4623
Update comments to add more details to the new TRACE_MARKER_TYPE_UNCO…
ivankyluk Nov 12, 2024
375b8af
Incorporate review comments.
ivankyluk Nov 12, 2024
653292d
Change #OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_ONLY to #dynamorio:…
ivankyluk Nov 12, 2024
f1a450e
Change #dynamorio::drmemtrace::OFFLINE_FILE_VERSION_RETIRED_INSTRUCTI…
ivankyluk Nov 12, 2024
7184724
Add doxygen description to OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_…
ivankyluk Nov 12, 2024
7db88c2
Add namespace names to OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_ONLY.
ivankyluk Nov 12, 2024
d0de986
Add doxygen comment to OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_ONLY.
ivankyluk Nov 13, 2024
5b94e4f
Remove erroneous file.
ivankyluk Nov 13, 2024
184b157
Merge branch 'master' into i7050-remove-preempted-instructions
ivankyluk Nov 13, 2024
2a91bad
Merge branch 'master' into i7050-remove-preempted-instructions
ivankyluk Nov 13, 2024
ec77a6d
Merge branch 'master' into i7050-remove-preempted-instructions
ivankyluk Nov 13, 2024
4b82d54
Add a comment to OFFLINE_FILE_VERSION_XFER_ABS_PC for doxygen.
ivankyluk Nov 13, 2024
b6db701
Use OPND_CREATE_MEMPTR instead of opnd_create_mem_instr.
ivankyluk Nov 14, 2024
9d38f36
Remove the extra encoding for X86_32.
ivankyluk Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@ clients.

The changes between version \DR_VERSION and 11.0.0 include the following compatibility
changes:
- Added X64 Linux support to dr_create_memory_dump(). This API has the same
restriction as dr_suspend_all_other_threads_ex().
- Removed uncompleted instructions and the corresponding memrefs from drmemtraces.
Instructions which are fetched but not completed due to asynchronous signal or
fault are removed. A new marker
#dynamorio::drmemtrace::TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION was added
to indicate an uncompleted instruction was removed. The value of the marker
is the encoding of the removed instruction up to a pointer's length. Added
#OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_ONLY to increase the trace version
for drmemtraces with uncompleted instructions removed.

Further non-compatibility-affecting changes include:
- No changes yet.
- Added X64 Linux support to dr_create_memory_dump(). This API has the same
restriction as dr_suspend_all_other_threads_ex().

**************************************************
<hr>
Expand Down
22 changes: 20 additions & 2 deletions clients/drcachesim/common/trace_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,21 @@ typedef enum {
*/
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
TRACE_MARKER_TYPE_SIGNAL_NUMBER,

/**
* This marker is used to indicate an instruction started to execute but
* didn't retire. The instruction was either preempted by an asynchronous
* signal or caused a fault. The instruction and corresponding memrefs
* are removed from the trace.
*
* The marker value is the raw encoding bytes of the instruction up to the
* length of a pointer. The encoding will be incomplete for instructions
* with long encodings. It is best-effort to help understand the sequence of
* generated code where encodings are not available offline. The PC of this
* instruction is available in a subsequent
* #dynamorio::drmemtrace::TRACE_MARKER_TYPE_KERNEL_EVENT marker.
*/
TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION,
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved

// ...
// These values are reserved for future built-in marker types.
// ...
Expand Down Expand Up @@ -946,8 +961,11 @@ typedef enum {
#define OFFLINE_FILE_VERSION_KERNEL_INT_PC 4
#define OFFLINE_FILE_VERSION_HEADER_FIELDS_SWAP 5
#define OFFLINE_FILE_VERSION_ENCODINGS 6
#define OFFLINE_FILE_VERSION_XFER_ABS_PC 7
#define OFFLINE_FILE_VERSION OFFLINE_FILE_VERSION_XFER_ABS_PC
#define OFFLINE_FILE_VERSION_XFER_ABS_PC \
7 /**< Use the absolute PC for kernel interruption PC for 64-bit mode.*/
#define OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_ONLY \
8 /**< Trace version which has only retired instructions in drmemtraces.*/
#define OFFLINE_FILE_VERSION OFFLINE_FILE_VERSION_RETIRED_INSTRUCTIONS_ONLY
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved

/**
* Bitfields used to describe the high-level characteristics of both an
Expand Down
42 changes: 42 additions & 0 deletions clients/drcachesim/docs/drcachesim.dox.in
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ Some of the more important markers are:

- #dynamorio::drmemtrace::TRACE_MARKER_TYPE_CORE_WAIT - This is inserted by the trace scheduler (see \ref sec_drcachesim_sched) during replay of a previously recorded schedule when one core gets too far ahead of another according to the recorded timestamps. This is an artificial wait to keep the replay on track, as opposed to the natural idle time of #dynamorio::drmemtrace::TRACE_MARKER_TYPE_CORE_IDLE.

- #dynamorio::drmemtrace::TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION - This is inserted when an uncompleted instruction and its corresponding memory records are removed. The marker value contains the encoding of the removed instruction up to the length of a pointer. The encoding will be incomplete for instructions with long encodings. It is best-effort to help understand the sequence for generated code where encodings are not available offline. The PC of this instruction is available in a subsequent #dynamorio::drmemtrace::TRACE_MARKER_TYPE_KERNEL_EVENT marker.

The full set of markers is listed under the enum #dynamorio::drmemtrace::trace_marker_type_t.

****************************************************************************
Expand Down Expand Up @@ -792,6 +794,46 @@ untaken conditional branch:
801377 601843: 1159769 ifetch 4 byte(s) @ 0x00007fc2c3aa5c72 48 83 c4 48 add $0x48, %rsp
\endcode

Here is an illustration of what a trace would look like when an uncompleted
instruction (mov) is interrupted by an asynchronous signal and the instruction
is not removed (The following trace is for demonstration purpose only):

\code

46914793 33950158: 3767811 ifetch 5 byte(s) @ 0x000055f52911b75e c4 42 f8 f5 e8 bzhi %r8, %rax, %r13
46914794 33950159: 3767811 ifetch 5 byte(s) @ 0x000055f52911b763 c4 62 f8 f5 c3 bzhi %rbx, %rax, %r8
46914795 33950160: 3767811 ifetch 4 byte(s) @ 0x000055f52911b768 48 c1 eb 33 shr $0x33, %rbx
46914796 33950161: 3767811 ifetch 3 byte(s) @ 0x000055f52911b76c 48 01 f3 add %rsi, %rbx
46914797 33950162: 3767811 ifetch 5 byte(s) @ 0x000055f52911b76f b8 04 00 00 00 mov $0x00000004, %eax
(The line below is for demonstration purpose only and will not appear in a real drmemtrace.)
46914798 33950163: 3767811 ifetch 6 byte(s) @ 0x000055f52911b774 89 85 68 ff ff ff mov %eax, -0x98(%rbp)
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
46914799 33950163: 3767811 <marker: kernel xfer from 0x55f52911b774 to handler>
46914800 33950163: 3767811 <marker: signal #27>
46914801 33950163: 3767811 <marker: timestamp 13373506292215933>
46914802 33950163: 3767811 <marker: tid 3767811 on core 4139>
46914803 33950164: 3767811 ifetch 1 byte(s) @ 0x000055f5298f7500 55 push %rbp
46914804 33950164: 3767811 write 8 byte(s) @ 0x00007fd98bd2f210 by PC 0x000055f5298f7500
\endcode

When the uncompleted mov instruction is removed, a
#dynamorio::drmemtrace::TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION marker is placed to indicate an
instruction has been removed:

\code
46914793 33950158: 3767811 ifetch 5 byte(s) @ 0x000055f52911b75e c4 42 f8 f5 e8 bzhi %r8, %rax, %r13
46914794 33950159: 3767811 ifetch 5 byte(s) @ 0x000055f52911b763 c4 62 f8 f5 c3 bzhi %rbx, %rax, %r8
46914795 33950160: 3767811 ifetch 4 byte(s) @ 0x000055f52911b768 48 c1 eb 33 shr $0x33, %rbx
46914796 33950161: 3767811 ifetch 3 byte(s) @ 0x000055f52911b76c 48 01 f3 add %rsi, %rbx
46914797 33950162: 3767811 ifetch 5 byte(s) @ 0x000055f52911b76f b8 04 00 00 00 mov $0x00000004, %eax
46914798 33950163: 3767811 <marker: uncompleted instruction, encoding 0x898568ff>
46914799 33950163: 3767811 <marker: kernel xfer from 0x55f52911b774 to handler>
46914800 33950163: 3767811 <marker: signal #27>
46914801 33950163: 3767811 <marker: timestamp 13373506292215933>
46914802 33950163: 3767811 <marker: tid 3767811 on core 4139>
46914803 33950164: 3767811 ifetch 1 byte(s) @ 0x000055f5298f7500 55 push %rbp
46914804 33950164: 3767811 write 8 byte(s) @ 0x00007fd98bd2f210 by PC 0x000055f5298f7500
\endcode

\section sec_tool_func_view View Function Calls

The func_view tool records function argument and return values for
Expand Down
4 changes: 2 additions & 2 deletions clients/drcachesim/tests/offline-burst_aarch64_sys.templatex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Total counts:
.* total data loads
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
.* total data stores
1 total icache flushes
4 total dcache flushes
3 total dcache flushes
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
1 total threads
.* total timestamp \+ cpuid markers
.*
Expand All @@ -25,6 +25,6 @@ Thread .* counts:
.* data loads
.* data stores
1 icache flushes
4 dcache flushes
3 dcache flushes
.* timestamp \+ cpuid markers
.*
24 changes: 12 additions & 12 deletions clients/drcachesim/tests/offline-legacy-int-offs.templatex
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ ERROR: failed to initialize analyzer: Directory setup failed: Failed sanity chec
#elif defined(X86) && defined(X64)
Basic counts tool results:
Total counts:
109205 total \(fetched\) instructions
6768 total unique \(fetched\) instructions
109201 total \(fetched\) instructions
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
6765 total unique \(fetched\) instructions
93 total non-fetched instructions
11 total prefetches
23974 total data loads
5544 total data stores
23972 total data loads
5543 total data stores
0 total icache flushes
0 total dcache flushes
3 total threads
Expand All @@ -24,15 +24,15 @@ Total counts:
0 total physical address unavailable markers
0 total system call number markers
0 total blocking system call markers
12 total other markers
8429 total encodings
16 total other markers
8426 total encodings
Thread 552306 counts:
101049 \(fetched\) instructions
6393 unique \(fetched\) instructions
101045 \(fetched\) instructions
6390 unique \(fetched\) instructions
93 non-fetched instructions
11 prefetches
21712 data loads
4442 data stores
21710 data loads
4441 data stores
0 icache flushes
0 dcache flushes
110 timestamp \+ cpuid markers
Expand All @@ -47,8 +47,8 @@ Thread 552306 counts:
0 physical address unavailable markers
0 system call number markers
0 blocking system call markers
4 other markers
6393 encodings
8 other markers
6390 encodings
Thread 552323 counts:
4674 \(fetched\) instructions
1028 unique \(fetched\) instructions
Expand Down
Loading
Loading