diff --git a/core/libs/prx/libSceAgcDriver/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/CMakeLists.txt index 269477c12c..02bd78d020 100644 --- a/core/libs/prx/libSceAgcDriver/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/CMakeLists.txt @@ -484,6 +484,7 @@ if(BUILD_TESTING) add_test_executable(agc_private_collect_tests EXCLUDE_FROM_ALL tests/PrivateCollect.cpp) target_include_directories(agc_private_collect_tests PRIVATE ${LIBS_INCLUDE_DIR}) target_link_libraries(agc_private_collect_tests PRIVATE libc) + target_compile_definitions(agc_private_collect_tests PRIVATE APS5_COUNT_MAPPING_QUERIES=1) set_target_properties(agc_private_collect_tests PROPERTIES CXX_EXTENSIONS OFF) configure_windows_unwind(agc_private_collect_tests) add_test(NAME agc_private_collect COMMAND agc_private_collect_tests) diff --git a/core/libs/prx/libc/include/GuestArena.hpp b/core/libs/prx/libc/include/GuestArena.hpp index b3dc5accd5..bf0d756d40 100644 --- a/core/libs/prx/libc/include/GuestArena.hpp +++ b/core/libs/prx/libc/include/GuestArena.hpp @@ -46,7 +46,6 @@ bool GuestArenaProtection_nid_postfix(std::uintptr_t address, std::uint32_t* pro bool GuestArenaCollectWrites_nid_postfix(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear); bool GuestArenaCollectArmedWrites_nid_postfix(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear); bool GuestArenaCollectFreshWrites_nid_postfix(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear); -void GuestArenaCollectWork_nid_postfix(std::uint64_t* systemCalls, std::uint64_t* pieces); bool GuestArenaHostRegionOverlaps_nid_postfix(std::uintptr_t address, std::size_t bytes); std::uint64_t GuestArenaCommitGeneration_nid_postfix(); void GuestArenaSetPrivateMappingObserver_nid_postfix(void (*callback)(std::uintptr_t address, std::size_t bytes, std::uint64_t generation)); diff --git a/core/libs/prx/libc/include/WindowsMappings.hpp b/core/libs/prx/libc/include/WindowsMappings.hpp index 1d21d9ae5a..0bab480f58 100644 --- a/core/libs/prx/libc/include/WindowsMappings.hpp +++ b/core/libs/prx/libc/include/WindowsMappings.hpp @@ -381,11 +381,13 @@ public: return true; } +#ifdef APS5_COUNT_MAPPING_QUERIES void CollectWork(std::uint64_t* systemCalls, std::uint64_t* pieces) { std::lock_guard lock(mutex); *systemCalls = collectSystemCalls; *pieces = collectPieces; } +#endif bool Collect(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear, Collection collection = Collection::All) { std::lock_guard lock(mutex); @@ -528,8 +530,10 @@ public: const auto touched = (((stop + 4095) & ~static_cast(4095)) - (cursor & ~static_cast(4095))) / 4096; ULONG_PTR available = std::min(capacity - *count, touched); DWORD granularity = 0; +#ifdef APS5_COUNT_MAPPING_QUERIES ++collectSystemCalls; collectPieces += (stop + pageBytes - 1) / pageBytes - cursor / pageBytes; +#endif const bool committed = !verifyDirect() || committedPrivate(cursor, stop); if (GetWriteWatch(clear ? WRITE_WATCH_FLAG_RESET : 0, reinterpret_cast(cursor), stop - cursor, pages + *count, &available, &granularity) != 0) { const auto memory = query(cursor); @@ -1148,8 +1152,10 @@ private: Ranges cleanRanges; Ranges collectableRanges; Ranges privateAllocations; +#ifdef APS5_COUNT_MAPPING_QUERIES std::uint64_t collectSystemCalls = 0; std::uint64_t collectPieces = 0; +#endif Ranges freshRanges; std::map views; diff --git a/core/libs/prx/libc/src/GuestArena.cpp b/core/libs/prx/libc/src/GuestArena.cpp index 7ec6010aeb..20cdbc1820 100644 --- a/core/libs/prx/libc/src/GuestArena.cpp +++ b/core/libs/prx/libc/src/GuestArena.cpp @@ -438,10 +438,6 @@ bool GuestArenaCollectFreshWrites_nid_postfix(std::uintptr_t address, std::size_ return WindowsMappings::Get().Collect(address, bytes, pages, count, clear, WindowsMappings::Collection::Fresh); } -void GuestArenaCollectWork_nid_postfix(std::uint64_t* systemCalls, std::uint64_t* pieces) { - WindowsMappings::Get().CollectWork(systemCalls, pieces); -} - bool GuestArenaHostRegionOverlaps_nid_postfix(std::uintptr_t address, std::size_t bytes) { return Arena::Get().OverlapsHostRegion(address, bytes); }