Commit 35ef80e
KVM: x86/mmu: Batch TLB flushes when zapping collapsible TDP MMU SPTEs
Set SPTEs directly to SHADOW_NONPRESENT_VALUE and batch up TLB flushes
when zapping collapsible SPTEs, rather than freezing them first.
Freezing the SPTE first is not required. It is fine for another thread
holding mmu_lock for read to immediately install a present entry before
TLBs are flushed because the underlying mapping is not changing. vCPUs
that translate through the stale 4K mappings or a new huge page mapping
will still observe the same GPA->HPA translations.
KVM must only flush TLBs before dropping RCU (to avoid use-after-free of
the zapped page tables) and before dropping mmu_lock (to synchronize
with mmu_notifiers invalidating mappings).
In VMs backed with 2MiB pages, batching TLB flushes improves the time it
takes to zap collapsible SPTEs to disable dirty logging:
$ ./dirty_log_perf_test -s anonymous_hugetlb_2mb -v 64 -e -b 4g
Before: Disabling dirty logging time: 14.334453428s (131072 flushes)
After: Disabling dirty logging time: 4.794969689s (76 flushes)
Skipping freezing SPTEs also avoids stalling vCPU threads on the frozen
SPTE for the time it takes to perform a remote TLB flush. vCPUs faulting
on the zapped mapping can now immediately install a new huge mapping and
proceed with guest execution.
Signed-off-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20240823235648.3236880-3-dmatlack@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 8ccd51c commit 35ef80e
1 file changed
Lines changed: 10 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | 586 | | |
629 | 587 | | |
630 | 588 | | |
| |||
1596 | 1554 | | |
1597 | 1555 | | |
1598 | 1556 | | |
| 1557 | + | |
1599 | 1558 | | |
1600 | 1559 | | |
1601 | 1560 | | |
1602 | 1561 | | |
1603 | 1562 | | |
1604 | | - | |
| 1563 | + | |
| 1564 | + | |
1605 | 1565 | | |
| 1566 | + | |
1606 | 1567 | | |
1607 | 1568 | | |
1608 | 1569 | | |
| |||
1630 | 1591 | | |
1631 | 1592 | | |
1632 | 1593 | | |
1633 | | - | |
1634 | | - | |
| 1594 | + | |
1635 | 1595 | | |
| 1596 | + | |
| 1597 | + | |
1636 | 1598 | | |
1637 | 1599 | | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
1638 | 1603 | | |
1639 | 1604 | | |
1640 | 1605 | | |
| |||
0 commit comments