added few tlb specific cpustat counters

This commit is contained in:
Stanislav Shwartsman 2015-09-28 19:09:32 +00:00
parent 0e37969e32
commit ad52e15860
3 changed files with 19 additions and 3 deletions

View File

@ -42,7 +42,11 @@ struct bx_cpu_statistics
// tlb lookup statistics
Bit64u tlbLookups;
Bit64u tlbExecuteLookups;
Bit64u tlbWriteLookups;
Bit64u tlbMisses;
Bit64u tlbExecuteMisses;
Bit64u tlbWriteMisses;
// tlb flush statistics
Bit64u tlbGlobalFlushes;
@ -56,7 +60,8 @@ struct bx_cpu_statistics
bx_cpu_statistics():
iCacheLookups(0), iCachePrefetch(0), iCacheMisses(0),
tlbLookups(0), tlbMisses(0),
tlbLookups(0), tlbExecuteLookups(0), tlbWriteLookups(0),
tlbMisses(0), tlbExecuteMisses(0), tlbWriteMisses(0),
tlbGlobalFlushes(0), tlbNonGlobalFlushes(0),
stackPrefetch(0), smc(0) {}

View File

@ -152,7 +152,11 @@ void BX_CPU_C::init_statistics(void)
#if InstrumentTLB
new bx_shadow_num_c(cpu, "tlbLookups", &stats->tlbLookups);
new bx_shadow_num_c(cpu, "tlbExecuteLookups", &stats->tlbExecuteLookups);
new bx_shadow_num_c(cpu, "tlbWriteLookups", &stats->tlbWriteLookups);
new bx_shadow_num_c(cpu, "tlbMisses", &stats->tlbMisses);
new bx_shadow_num_c(cpu, "tlbExecuteMisses", &stats->tlbExecuteMisses);
new bx_shadow_num_c(cpu, "tlbWriteMisses", &stats->tlbWriteMisses);
#endif
#if InstrumentTLBFlush

View File

@ -1130,10 +1130,13 @@ bx_phy_address BX_CPU_C::translate_linear(bx_TLB_entry *tlbEntry, bx_address lad
bx_phy_address paddress, ppf, poffset = PAGE_OFFSET(laddr);
unsigned isWrite = rw & 1; // write or r-m-w
unsigned isExecute = (rw == BX_EXECUTE);
bx_address lpf = LPFOf(laddr);
INC_TLB_STAT(tlbLookups);
bx_address lpf = LPFOf(laddr);
if (isExecute)
INC_TLB_STAT(tlbExecuteLookups);
if (isWrite)
INC_TLB_STAT(tlbWriteLookups);
// already looked up TLB for code access
if (! isExecute && TLB_LPFOf(tlbEntry->lpf) == lpf)
@ -1150,6 +1153,10 @@ bx_phy_address BX_CPU_C::translate_linear(bx_TLB_entry *tlbEntry, bx_address lad
}
INC_TLB_STAT(tlbMisses);
if (isExecute)
INC_TLB_STAT(tlbExecuteMisses);
if (isWrite)
INC_TLB_STAT(tlbWriteMisses);
Bit32u lpf_mask = 0xfff; // 4K pages
Bit32u combined_access = 0x06;