A commit copies into each copied host buffer the bytes the CPU changed in
its pages, before any of the command buffer's work is submitted. A batch
that waits for an event runs its commands only once the event reaches
the value, and on Metal those commands read the pages as they stand
then. So a CPU write made after the commit and before the host's signal
(or before a later command buffer's signal) never reached the copy, and
the waiting command buffer read the bytes from before it.
The commit now notes, before its copy in, the batches that wait for an
event value not yet reached (CopiesAgain::unreached, from each event's
timeline). When the scheduler submits such a batch, which it does only
once the wait is met, submit_batch first copies in again
(copy_in_again): the copies the command buffer reaches, as at the
commit, take the CPU's changes since. This runs with no lock of the
command buffer held, since a copy over logged pages waits for the log's
publication. A batch with no wait, or whose every wait was already
reached at the commit, copies nothing more. The new counter is
WorkCounts::copied_copy_ins_after_waits.
The same mechanism serves a reader held by an event across queues: the
signal of a batch submitted while a copy is live is seen only at its
completion turn, after the merge back. The FAST-PATHS gap that listed
event-ordered reads across queues as stale now says the held reader
copies in again; that case is expected from the code and not run.
Docs: copied.rs (Coherence, the two-memories bullet, copy_in),
dirty_pages.rs (stamps), HOWTO (copied host buffers), FAST-PATHS (cost
row and gap), api_signatures.tsv (the new field).
Verified: waited_reads in the jobs named in the report. The copied leg
fails at cae2e24b4d and passes here; the no-wait copied leg makes 0
copies in again.