[compiler-rt] [scudo] Move getResidentPages function (PR #183138)
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 12:56:56 PST 2026
================
@@ -131,6 +131,38 @@ void MemMapLinux::releaseAndZeroPagesToOSImpl(uptr From, uptr Size) {
}
}
+s64 MemMapLinux::getResidentPagesImpl(uptr From, uptr Size) {
+ unsigned char PageData[256];
+
+ uptr PageSize = getPageSizeCached();
+ uptr PageSizeLog = getPageSizeLogCached();
+
+ // Make sure the address is page aligned.
+ uptr CurrentAddress = From & ~(PageSize - 1);
+ uptr LastAddress = roundUp(From + Size, PageSize);
+ s64 ResidentPages = 0;
+ while (CurrentAddress < LastAddress) {
+ uptr Length = LastAddress - CurrentAddress;
+ if ((Length >> PageSizeLog) > sizeof(PageData)) {
+ Length = sizeof(PageData) << PageSizeLog;
+ }
+ if (mincore(reinterpret_cast<void *>(CurrentAddress), Length, PageData) ==
+ -1) {
+ ScopedString Str;
+ Str.append("mincore failed: %s\n", strerror(errno));
+ Str.output();
+ return 0;
----------------
cferris1000 wrote:
This should be returning -1.
https://github.com/llvm/llvm-project/pull/183138
More information about the llvm-commits
mailing list