Skip to content

Commit 833ab91

Browse files
committed
Reduce perf impact of Ziccid
Modifications are expected to be uncommon, so don't flush the I$ quite so often.
1 parent cce834e commit 833ab91

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

riscv/execute.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ void processor_t::step(size_t n)
226226
if (extension_enabled(EXT_ZICCID)) {
227227
// Ziccid requires stores eventually become visible to instruction fetch,
228228
// so periodically flush the I$
229-
_mmu->flush_icache();
229+
if (ziccid_flush_count-- == 0) {
230+
ziccid_flush_count += ZICCID_FLUSH_PERIOD;
231+
_mmu->flush_icache();
232+
}
230233
}
231234

232235
while (n > 0) {

riscv/processor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ class processor_t : public abstract_device_t
412412
static const size_t OPCODE_CACHE_SIZE = 4095;
413413
opcode_cache_entry_t opcode_cache[OPCODE_CACHE_SIZE];
414414

415+
unsigned ziccid_flush_count = 0;
416+
static const unsigned ZICCID_FLUSH_PERIOD = 10;
417+
415418
bool is_handled_in_vs();
416419
void take_pending_interrupt() { take_interrupt(state.mip->read() & state.mie->read()); }
417420
void take_interrupt(reg_t mask); // take first enabled interrupt in mask

0 commit comments

Comments
 (0)