mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
ke/smr: allow invalid sequences in deferred_advance_commit
This was buggy when the race was lost and it ended up trying to commit a deferred advance of 0, now explicitly make the magazine's sequence invalid and do nothing in deferred_advance_commit, avoiding an integer underflow.
This commit is contained in:
@@ -274,6 +274,8 @@ pub fn deferred_advance(dom: *Domain) Sequence {
|
||||
/// Actually advance the global clock to a value previously returned by
|
||||
/// deferred_advance().
|
||||
pub fn deferred_advance_commit(dom: *Domain, seq: Sequence) void {
|
||||
if (seq == seq_invalid) return;
|
||||
|
||||
_ = dom.clock.write_seq.cmpxchgStrong(
|
||||
seq - seq_incr,
|
||||
seq,
|
||||
|
||||
@@ -792,6 +792,10 @@ pub const Zone = struct {
|
||||
// We lost the race. If the magazine we got was fully filled,
|
||||
// then put it in the depot. Otherwise, dispose of it.
|
||||
if (cnt == magazine_size.load()) {
|
||||
// Ensure this magazine isn't counted as a freed one,
|
||||
// it is instantly reclaimable.
|
||||
nm.seq = ke.smr.seq_invalid;
|
||||
|
||||
Depot.free(nm, &cpu.depot.full_mags, self.reuse_policy);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user