Skip to content

Commit

Permalink
i#4014 dr$sim phys: Add page size marker
Browse files Browse the repository at this point in the history
To use the new physical address markers in a trace analysis tool, the
page size must be known.  Here we add a new marker to the thread
headers holding the page size.  Sanity tests are added.

Issue: #4014
  • Loading branch information
derekbruening committed Jun 15, 2022
1 parent fe24ab6 commit 3159532
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Further non-compatibility-affecting changes include:
libraries must be avoided and open addressing is best: dr_hashtable_create(),
dr_hashtable_destroy(), dr_hashtable_clear(), dr_hashtable_lookup(),
dr_hashtable_add(), dr_hashtable_remove().
- Added a new #TRACE_MARKER_TYPE_PAGE_SIZE record to drcachesim offline traces.

The changes between version 9.0.1 and 9.0.0 include the following compatibility
changes:
Expand Down
5 changes: 5 additions & 0 deletions clients/drcachesim/common/trace_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ typedef enum {
*/
TRACE_MARKER_TYPE_PHYSICAL_ADDRESS_NOT_AVAILABLE,

/**
* The marker value contains the traced process's page size in bytes.
*/
TRACE_MARKER_TYPE_PAGE_SIZE,

// ...
// These values are reserved for future built-in marker types.
// ...
Expand Down
9 changes: 8 additions & 1 deletion clients/drcachesim/tests/burst_aarch64_sys.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2020 Google, Inc. All rights reserved.
* Copyright (c) 2020-2022 Google, Inc. All rights reserved.
* **********************************************************/

/*
Expand Down Expand Up @@ -223,6 +223,7 @@ main(int argc, const char *argv[])
<< "\n";
}
bool found_cache_line_size_marker = false;
bool found_page_size_marker = false;
int dc_zva_instr_count = 0;
int dc_zva_memref_count = 0;
addr_t last_dc_zva_pc = 0;
Expand All @@ -233,6 +234,11 @@ main(int argc, const char *argv[])
found_cache_line_size_marker = true;
assert(memref.marker.marker_value == proc_get_cache_line_size());
}
if (memref.marker.type == TRACE_TYPE_MARKER &&
memref.marker.marker_type == TRACE_MARKER_TYPE_PAGE_SIZE) {
found_page_size_marker = true;
assert(memref.marker.marker_value == dr_page_size());
}
if (is_dc_zva_instr(dr_context, memref)) {
dc_zva_instr_count++;
last_dc_zva_pc = memref.instr.addr;
Expand All @@ -255,6 +261,7 @@ main(int argc, const char *argv[])
assert(dc_zva_memref_count != 0);
assert(dc_zva_instr_count == dc_zva_memref_count);
assert(found_cache_line_size_marker);
assert(found_page_size_marker);
dr_standalone_exit();

return 0;
Expand Down
9 changes: 5 additions & 4 deletions clients/drcachesim/tests/offline-phys.templatex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Output format:
1: T[0-9]+ <marker: version 3>
2: T[0-9]+ <marker: filetype 0x40>
3: T[0-9]+ <marker: cache line size [0-9]+>
4: T[0-9]+ <marker: timestamp [0-9]+>
5: T[0-9]+ <marker: tid [0-9]+ on core [0-9]+>
6: T[0-9]+ <marker: physical address for following entry: 0x[0-9a-f][0-9a-f]+>
7: T[0-9]+ ifetch .*
4: T[0-9]+ <marker: page size [0-9]+>
5: T[0-9]+ <marker: timestamp [0-9]+>
6: T[0-9]+ <marker: tid [0-9]+ on core [0-9]+>
7: T[0-9]+ <marker: physical address for following entry: 0x[0-9a-f][0-9a-f]+>
8: T[0-9]+ ifetch .*
6 changes: 6 additions & 0 deletions clients/drcachesim/tools/invariant_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ invariant_checker_t::parallel_shard_memref(void *shard_data, const memref_t &mem
memref.marker.marker_type == TRACE_MARKER_TYPE_CACHE_LINE_SIZE) {
shard->found_cache_line_size_marker_ = true;
}
if (memref.marker.type == TRACE_TYPE_MARKER &&
memref.marker.marker_type == TRACE_MARKER_TYPE_PAGE_SIZE) {
shard->found_page_size_marker_ = true;
}

if (memref.exit.type == TRACE_TYPE_THREAD_EXIT) {
report_if_false(shard,
Expand All @@ -194,6 +198,8 @@ invariant_checker_t::parallel_shard_memref(void *shard_data, const memref_t &mem
"Missing instr count markers");
report_if_false(shard, shard->found_cache_line_size_marker_,
"Missing cache line marker");
report_if_false(shard, shard->found_page_size_marker_,
"Missing page size marker");
if (knob_test_name_ == "filter_asm_instr_count") {
static constexpr int ASM_INSTR_COUNT = 133;
report_if_false(shard, shard->last_instr_count_marker_ == ASM_INSTR_COUNT,
Expand Down
3 changes: 3 additions & 0 deletions clients/drcachesim/tools/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ view_t::process_memref(const memref_t &memref)
std::cerr << "<marker: cache line size " << memref.marker.marker_value
<< ">\n";
break;
case TRACE_MARKER_TYPE_PAGE_SIZE:
std::cerr << "<marker: page size " << memref.marker.marker_value << ">\n";
break;
case TRACE_MARKER_TYPE_PHYSICAL_ADDRESS:
std::cerr << "<marker: physical address for following entry: 0x" << std::hex
<< memref.marker.marker_value << std::dec << ">\n";
Expand Down
1 change: 1 addition & 0 deletions clients/drcachesim/tracer/instru_offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ offline_instru_t::append_thread_header(byte *buf_ptr, thread_id_t tid,
new_buf += append_pid(new_buf, dr_get_process_id());
new_buf += append_marker(new_buf, TRACE_MARKER_TYPE_CACHE_LINE_SIZE,
proc_get_cache_line_size());
new_buf += append_marker(new_buf, TRACE_MARKER_TYPE_PAGE_SIZE, dr_page_size());
return (int)(new_buf - buf_ptr);
}

Expand Down

0 comments on commit 3159532

Please sign in to comment.