accel/tcg: Skip clean MMU modes when resetting TLB dirty flags
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 accel/tcg: Skip clean MMU modes when resetting TLB dirty flags
tlb_reset_dirty() scans every MMU mode, including modes whose TLBs contain no entries. These scans waste work while holding the TLB lock.
Use the dirty MMU bitmap to scan only modes that may contain entries. A clear bit indicates an empty TLB, so skipping those modes preserves the dirty flag reset behavior and reduces time spent under the lock.
Signed-off-by Murat Seker <[email protected]>
--- accel/tcg/cputlb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
accel/tcg/cputlb.c +7 -2
@@ -883,10 +883,15 @@ static inline void copy_tlb_helper_locked(CPUTLBEntry *d, const CPUTLBEntry *s)*/ void tlb_reset_dirty (CPUState *cpu,uintptr_t start,uintptr_t length) { -int mmu_idx; +MMUIdxMap work;qemu_spin_lock (&cpu->neg.tlb.c.lock); -for (mmu_idx =0 ; mmu_idx <NB_MMU_MODES ; mmu_idx++) { +/* +* An mmu_idx that is clean in c.dirty has been flushed and holds no +* entries, so only the dirty ones need scanning. +*/ +for (work = cpu->neg.tlb.c.dirty; work !=0 ; work &= work -1 ) { +int mmu_idx =ctz32 (work);CPUTLBDesc *desc = &cpu->neg.tlb.d[mmu_idx];CPUTLBDescFast *fast =cpu_tlb_fast (cpu, mmu_idx);unsigned int n =tlb_n_entries (fast);
Signature · 1 line
2.53.1-Meta