Skip to content

Commit

Permalink
Add PID information to -LL_miss_file output (#6896)
Browse files Browse the repository at this point in the history
When using simulator parameters -LL_miss_file option, I noticed that the
output was insufficient for detailed analysis, especially when
distinguishing cache misses across processes. This limitation becomes
more apparent in environments where multiple processes may experience
cache misses at similar virtual memory addresses, potentially leading to
ambiguous outputs.

So, I have updated the dump_miss function within
caching_device_stats.cpp to include the PID in the output. This small
yet impactful change ensures that each cache miss log entry is prefixed
with the PID of the process, thereby enabling users to better correlate
the cache misses with specific processes.
  • Loading branch information
jin11109 authored Aug 1, 2024
1 parent 07c6582 commit 7d39db4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ changes:
signature between AArch64 and RISC-V.
- Renamed dr_get_sve_vector_length() to dr_get_vector_length() to share function
signature between AArch64 and RISC-V.
- Changed the drcachesim -LL_miss_file option by adding a process ID field to the output.
This helps in better analyzing cache misses in multi-process environments.

Further non-compatibility-affecting changes include:
- Added DWARF-5 support to the drsyms library by linking in 4 static libraries
Expand Down
10 changes: 5 additions & 5 deletions clients/drcachesim/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ droption_t<std::string> op_LL_miss_file(
"Path for dumping LLC misses or prefetching hints",
"If non-empty, when running the cache simulator, requests that "
"every last-level cache miss be written to a file at the specified path. Each miss "
"is written in text format as a <program counter, address> pair. If this tool is "
"linked with zlib, the file is written in gzip-compressed format. If non-empty, when "
"running the cache miss analyzer, requests that prefetching hints based on the miss "
"analysis be written to the specified file. Each hint is written in text format as a "
"<program counter, stride, locality level> tuple.");
"is written in text format as a <process id, program counter, address> tuple. If "
"this tool is linked with zlib, the file is written in gzip-compressed format. If "
"non-empty, when running the cache miss analyzer, requests that prefetching hints "
"based on the miss analysis be written to the specified file. Each hint is written "
"in text format as a <program counter, stride, locality level> tuple.");

droption_t<bool> op_L0_filter_deprecated(
DROPTION_SCOPE_CLIENT, "L0_filter", false,
Expand Down
2 changes: 2 additions & 0 deletions clients/drcachesim/simulator/cache_miss_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ cache_miss_stats_t::dump_miss(const memref_t &memref)
return;
}

// TODO i#6905: Consider incorporating PID information into the pc_cache_misses_ hash
// map and adjusting subsequent calculations that depend on this data.
const addr_t pc = memref.data.pc;
const addr_t addr = memref.data.addr / kLineSize;
pc_cache_misses_[pc].push_back(addr);
Expand Down
10 changes: 8 additions & 2 deletions clients/drcachesim/simulator/caching_device_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void
caching_device_stats_t::dump_miss(const memref_t &memref)
{
addr_t pc, addr;
memref_pid_t pid;
if (type_is_instr(memref.instr.type))
pc = memref.instr.addr;
else { // data ref: others shouldn't get here
Expand All @@ -163,10 +164,15 @@ caching_device_stats_t::dump_miss(const memref_t &memref)
pc = memref.data.pc;
}
addr = memref.data.addr;
pid = memref.data.pid;

// XXX: This writing method to the same file from multiple processes is racy.
// It works most of the time but consider using a directory with individual files
// per process as a future safer alternative.
#ifdef HAS_ZLIB
gzprintf(file_, "0x%zx,0x%zx\n", pc, addr);
gzprintf(file_, "%lld,0x%zx,0x%zx\n", pid, pc, addr);
#else
fprintf(file_, "0x%zx,0x%zx\n", pc, addr);
fprintf(file_, "%lld,0x%zx,0x%zx\n", pid, pc, addr);
#endif
}

Expand Down

0 comments on commit 7d39db4

Please sign in to comment.