[HLE] Skip the region lock for writes to CPU-dirty pages

This commit is contained in:
ParantezTech 2026-10-11 01:40:50 +03:00
parent 643a565a22
commit 8c24a40bfa
2 changed files with 22 additions and 0 deletions

View File

@ -198,6 +198,14 @@ public sealed class GuestPageTracker
if (Volatile.Read(ref _regions[index]) is { } region)
{
tracked = true;
if (region.IsCpuDirtyThroughout(offset, bytes))
{
remaining -= bytes;
offset = 0;
index++;
continue;
}
using (region.Lock.Hold())
{
if (region.IsModified(WriteOrigin.Gpu, offset, bytes))

View File

@ -46,6 +46,20 @@ public sealed class TrackedRegion
return GetDirtyMask(side).AnyInRange(start, end);
}
public bool IsCpuDirtyThroughout(ulong offset, ulong size)
{
var (start, end) = GetPageRange(BaseAddress + offset, size);
for (var page = start; page < end; page++)
{
if (!_cpuDirty.Get(page))
{
return false;
}
}
return true;
}
public bool IsCpuWriteHot(ulong offset, ulong size)
{
var (start, end) = GetPageRange(BaseAddress + offset, size);