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 8 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
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
.*
20 changes: 10 additions & 10 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 @@ -25,14 +25,14 @@ Total counts:
0 total system call number markers
0 total blocking system call markers
12 total other markers
8429 total encodings
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 @@ -48,7 +48,7 @@ Thread 552306 counts:
0 system call number markers
0 blocking system call markers
4 other markers
6393 encodings
6390 encodings
Thread 552323 counts:
4674 \(fetched\) instructions
1028 unique \(fetched\) instructions
Expand Down
126 changes: 123 additions & 3 deletions clients/drcachesim/tests/raw2trace_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,10 @@ test_branch_delays(void *drcontext)
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_FILETYPE) &&
check_entry(entries, idx, TRACE_TYPE_THREAD, -1) &&
check_entry(entries, idx, TRACE_TYPE_PID, -1) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CACHE_LINE_SIZE) &&
check_entry(entries, idx, TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_CHUNK_INSTR_COUNT) &&
TRACE_MARKER_TYPE_CACHE_LINE_SIZE) && // 5 type: 28 size: 10 val: 64
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
check_entry(entries, idx, TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_CHUNK_INSTR_COUNT) && // 10000000
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_TIMESTAMP) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID) &&
// Both branches should be delayed until after the timestamp+cpu markers:
Expand Down Expand Up @@ -3156,6 +3157,124 @@ test_ifiltered(void *drcontext)
#endif
}

/* Tests asynchronous signal handling (i#7050). */
bool
test_asynchronous_signal(void *drcontext)
{
bool res = true;
{
std::cerr << "\n===============\nTesting instr removal by async signal\n";
instrlist_t *ilist = instrlist_create(drcontext);
// raw2trace doesn't like offsets of 0 so we shift with a nop.
instr_t *nop = XINST_CREATE_nop(drcontext);
instr_t *move =
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
XINST_CREATE_move(drcontext, opnd_create_reg(REG1), opnd_create_reg(REG2));
instr_t *move2 =
XINST_CREATE_move(drcontext, opnd_create_reg(REG2), opnd_create_reg(REG1));
instrlist_append(ilist, nop);
instrlist_append(ilist, move);
instrlist_append(ilist, move2);
size_t offs_nop = 0;
size_t offs_move1 = offs_nop + instr_length(drcontext, nop);

std::vector<offline_entry_t> raw;
raw.push_back(make_header());
raw.push_back(make_tid());
raw.push_back(make_pid());
raw.push_back(make_line_size());
raw.push_back(make_timestamp());
raw.push_back(make_core());
raw.push_back(make_block(offs_move1, 1));
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
raw.push_back(make_marker(TRACE_MARKER_TYPE_KERNEL_EVENT, offs_move1));
raw.push_back(make_exit());

std::vector<uint64_t> stats;
std::vector<trace_entry_t> entries;
if (!run_raw2trace(drcontext, raw, ilist, entries, &stats))
return false;
int idx = 0;
res = check_entry(entries, idx, TRACE_TYPE_HEADER, -1) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_VERSION) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_FILETYPE) &&
check_entry(entries, idx, TRACE_TYPE_THREAD, -1) &&
check_entry(entries, idx, TRACE_TYPE_PID, -1) &&
check_entry(entries, idx, TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_CACHE_LINE_SIZE) &&
check_entry(entries, idx, TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_CHUNK_INSTR_COUNT) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_TIMESTAMP) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID) &&
// The move instruction is removed because of the asynchronous signal.
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_KERNEL_EVENT,
offs_move1) &&
check_entry(entries, idx, TRACE_TYPE_THREAD_EXIT, -1) &&
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
check_entry(entries, idx, TRACE_TYPE_FOOTER, -1);
}
{
std::cerr
<< "\n===============\nTesting instr and memref removal by async signal\n";
instrlist_t *ilist = instrlist_create(drcontext);
// raw2trace doesn't like offsets of 0 so we shift with a nop.
instr_t *nop = XINST_CREATE_nop(drcontext);
instr_t *move =
XINST_CREATE_move(drcontext, opnd_create_reg(REG1), opnd_create_reg(REG2));
instr_t *store = XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(REG2, 0),
opnd_create_reg(REG1));
instr_t *move2 =
XINST_CREATE_move(drcontext, opnd_create_reg(REG2), opnd_create_reg(REG1));
instrlist_append(ilist, nop);
instrlist_append(ilist, move);
instrlist_append(ilist, store);
instrlist_append(ilist, move2);
size_t offs_nop = 0;
size_t offs_move1 = offs_nop + instr_length(drcontext, nop);
size_t offs_store = offs_move1 + instr_length(drcontext, move);
size_t offs_move2 = offs_store + instr_length(drcontext, store);

std::vector<offline_entry_t> raw;
raw.push_back(make_header());
raw.push_back(make_tid());
raw.push_back(make_pid());
raw.push_back(make_line_size());
raw.push_back(make_timestamp());
raw.push_back(make_core());
raw.push_back(make_block(offs_move1, 2));
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
raw.push_back(make_memref(42));
raw.push_back(make_marker(TRACE_MARKER_TYPE_KERNEL_EVENT, offs_store));
raw.push_back(make_block(offs_move2, 1));
raw.push_back(make_exit());

std::vector<uint64_t> stats;
std::vector<trace_entry_t> entries;
if (!run_raw2trace(drcontext, raw, ilist, entries, &stats))
return false;
int idx = 0;
res &=
(check_entry(entries, idx, TRACE_TYPE_HEADER, -1) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_VERSION) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_FILETYPE) &&
check_entry(entries, idx, TRACE_TYPE_THREAD, -1) &&
check_entry(entries, idx, TRACE_TYPE_PID, -1) &&
check_entry(entries, idx, TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_CACHE_LINE_SIZE) &&
check_entry(entries, idx, TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_CHUNK_INSTR_COUNT) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_TIMESTAMP) &&
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID) &&
// The move instruction.
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
check_entry(entries, idx, TRACE_TYPE_ENCODING, -1) &&
check_entry(entries, idx, TRACE_TYPE_INSTR, -1, offs_move1) &&
// The store instruction and the memref are removed.
check_entry(entries, idx, TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_KERNEL_EVENT,
offs_store) &&
check_entry(entries, idx, TRACE_TYPE_ENCODING, -1) &&
check_entry(entries, idx, TRACE_TYPE_INSTR, -1, offs_move2) &&
check_entry(entries, idx, TRACE_TYPE_THREAD_EXIT, -1) &&
check_entry(entries, idx, TRACE_TYPE_FOOTER, -1));
}
return res;
}

int
test_main(int argc, const char *argv[])
{
Expand All @@ -3177,7 +3296,8 @@ test_main(int argc, const char *argv[])
!test_xfer_modoffs(drcontext) || !test_xfer_absolute(drcontext) ||
!test_branch_decoration(drcontext) ||
!test_stats_timestamp_instr_count(drcontext) ||
!test_is_maybe_blocking_syscall(drcontext) || !test_ifiltered(drcontext))
!test_is_maybe_blocking_syscall(drcontext) || !test_ifiltered(drcontext) ||
!test_asynchronous_signal(drcontext))
return 1;
return 0;
}
Expand Down
24 changes: 16 additions & 8 deletions clients/drcachesim/tests/signal_invariants.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ GLOBAL_LABEL(FUNCNAME:)
#define FUNCNAME test_signal_midbb
DECLARE_FUNC(FUNCNAME)
GLOBAL_LABEL(FUNCNAME:)
/* prefetcht2's address is the instr count until a signal */
prefetcht2 [3]
/* prefetcht2's address is the instr count until a signal not counting
* the preempted instr.
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
ivankyluk marked this conversation as resolved.
Show resolved Hide resolved
*/
prefetcht2 [2]
nop
nop
ud2
Expand All @@ -205,8 +207,10 @@ GLOBAL_LABEL(FUNCNAME:)
#define FUNCNAME test_signal_startbb
DECLARE_FUNC(FUNCNAME)
GLOBAL_LABEL(FUNCNAME:)
/* prefetcht2's address is the instr count until a signal */
prefetcht2 [2]
/* prefetcht2's address is the instr count until a signal not counting
* the preempted instr.
*/
prefetcht2 [1]
jmp new_bb
new_bb:
ud2
Expand All @@ -221,10 +225,14 @@ GLOBAL_LABEL(FUNCNAME:)
* XXX i#3958: Today the 2nd movs memref is incorrectly included *before*
* the fault.
*/
/* prefetcht2's address is the instr count until a signal */
prefetcht2 [5]
/* prefetcht1's address is the memref count until a signal */
prefetcht1 [3]
/* prefetcht2's address is the instr count until a signal not counting
* the preempted instr.
*/
prefetcht2 [4]
/* prefetcht1's address is the memref count until a signal not counting
* the preempted memref.
*/
prefetcht1 [1]
mov REG_XSI, HEX(42)
mov REG_XDI, REG_XSP
push REG_XAX
Expand Down
Loading
Loading