Skip to content

Commit

Permalink
Don't stall in TLB shootdown.
Browse files Browse the repository at this point in the history
This is an artifact of a sub-par TLB shootdown algorithm that needs to
be updated. That'll be a future PR, in the meantime, this removes a
possible deadlock.
  • Loading branch information
dbittman committed Nov 8, 2024
1 parent 1340567 commit 7f1bd3b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/kernel/src/arch/amd64/memory/pagetables/consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,31 @@ impl ArchTlbMgr {
self.data.do_invalidation();

if count > 0 {
// Ensure we don't wait too long -- TODO: this is because this TLB shootdown algorithm
// is Not Great (tm) and should be improved (targeted shootdown, pcid tracking, ...)
const MAX_ITERS: usize = 100;
// Wait for each processor to report that it is done.
with_each_active_processor(|p| {
let mut iters = 0;
if p.id != proc.id {
spin_wait_until(
|| {
if p.arch.tlb_shootdown_info.is_finished() {
if p.arch.tlb_shootdown_info.is_finished() || iters >= MAX_ITERS {
if iters >= MAX_ITERS {
logln!(
"warning -- TLB shootdown pause on CPUs {} -> {}",
proc.id,
p.id
);
}
Some(())
} else {
None
}
},
|| {},
|| {
iters += 1;
},
);
}
});
Expand Down

0 comments on commit 7f1bd3b

Please sign in to comment.