Skip to content

Write a partly merged WCB line only when it must go - #368

Merged
willmccallion merged 1 commit into
mainfrom
wcb/drain-policy
Nov 24, 2026
Merged

willmccallion merged 1 commit into
mainfrom
wcb/drain-policy

Conversation

@willmccallion

Copy link
Copy Markdown
Owner

The write-combining buffer wrote its oldest line whenever the store buffers left the L1D write port free for a cycle, so a loop doing any work between its stores sent each line in pieces: a stream that computes each doubleword it stores reached the L1D as 768 writes for 128 lines. That also stops write streaming from seeing whole-line writes.

A partly merged line now goes only when:

  • its line is fully written;
  • a load needs bytes it holds only some of;
  • a store for another line needs its entry and none is free (the least recently merged line goes);
  • something must follow every older store: a barrier, an atomic at the ROB head, a drain of the memory system, or a store to a device. HTIF reads memory the moment tohost is written and the bundled libc does not fence before it, so a device store waits until the WCB has written everything older;
  • no store has merged into it for wcb_idle_cycles (new, default 16). No core documents this value; the default is not fitted to a measurement.

Tests:

  • a_store_stream_reaches_the_l1d_a_whole_line_at_a_time: 128 line writes for 128 lines (768 under the old policy).
  • an_unfenced_syscall_sees_the_stores_the_write_combining_buffer_held: an unfenced HTIF write prints what was stored; without the device-store wait the host reads a stale block and the program never exits.
  • WCB unit tests for the idle time, send-all and eviction; Python tests for the new field.

Locally: Rust and Python suites, make accuracy (unchanged), make lockstep-ci 858/858, riscv-tests on ref linux with 4 harts 188/188, multicore smoke 120/120.

The WCB wrote its oldest line whenever the store buffers left the write port free for a cycle, so a loop that did any work between its stores sent each line in pieces. A line now goes when it is full, when a load needs it, when a store for another line needs its entry, when something must follow every older store (a barrier, an atomic, a drain, or a store to a device such as HTIF, which reads memory as soon as it is written), or once no store has merged into it for wcb_idle_cycles (16 by default).
@willmccallion
willmccallion merged commit 3967299 into main Nov 24, 2026
6 checks passed
@willmccallion
willmccallion deleted the wcb/drain-policy branch November 24, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant