Perf: Fix false store-to-load collisions across different physical pages#21
Conversation
|
Does the collision detector always compare addresses that are guaranteed to be in the same, normalized address form? Concretely, can store entries ever be written into the buffer before address translation (or with guest vs host PPN encodings), or does the design guarantee enqueue happens only after translation and normalization? Also, is the page-offset width assumed fixed (4KB) everywhere this logic runs? |
|
Building on @Saksham05oct's question — I think the answer is concretely "no", and it may make this change unsafe rather than just cosmetic. In
whereas So on those paths the load address feeding Two smaller things:
I might well be misreading the enqueue/dequeue ordering — if the design does guarantee the head is always translated before |
Fixes #20.
Description
This PR fixes a performance regression in the
store_bufferwhere loads were falsely stalled by in-flight stores.Previously, the collision detector only checked the page offset (bits
[11:0]) of the physical addresses. This meant that a store and a load on completely different physical pages would be falsely flagged as a collision if they happened to share the same page offset.This fix wraps the offset checks in an initial
ifstatement that first verifies the physical page numbers (PPN) match (data_rs1[PHY_VIRT_MAX_ADDR_SIZE-1:12]).Changes Made
store_buffer.sv: Added[PHY_VIRT_MAX_ADDR_SIZE-1:12]checks to ensure only accesses on the exact same physical page are evaluated for offset overlap.tb_store_buffer.sv: Added a new standalone SystemVerilog testbench that proves: