-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[scudo] Add time of last page release to getStats() #164004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Having the time of last page release can help us figure out if the page release is skipped or not.
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Sadaf Ebrahimi (sadafebrahimi) ChangesHaving the time of last page release can help us figure out if the page release is skipped or not. Full diff: https://github.com/llvm/llvm-project/pull/164004.diff 1 Files Affected:
diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index 747b1a2233d32..27a9f851dcde7 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -24,6 +24,8 @@
#include "thread_annotations.h"
#include "tracing.h"
+#include <inttypes.h>
+
namespace scudo {
// SizeClassAllocator64 is an allocator tuned for 64-bit address space.
@@ -1146,17 +1148,24 @@ void SizeClassAllocator64<Config>::getStats(ScopedString *Str, uptr ClassId,
BytesInFreeList - Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint;
}
const uptr TotalChunks = Region->MemMapInfo.AllocatedUser / BlockSize;
+ const u64 CurTimeNs = getMonotonicTime();
+ const u64 DiffSinceLastReleaseNs =
+ CurTimeNs - Region->ReleaseInfo.LastReleaseAtNs;
+ const u64 LastReleaseSecAgo = DiffSinceLastReleaseNs / 1000000000;
+ const u64 LastReleaseMsAgo = (DiffSinceLastReleaseNs % 1000000000) / 1000000;
+
Str->append(
"%s %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu "
"inuse: %6zu total: %6zu releases attempted: %6zu last "
"released: %6zuK latest pushed bytes: %6zuK region: 0x%zx "
- "(0x%zx)\n",
+ "(0x%zx) Latest release: %" PRIu64 ":%" PRIu64 " seconds ago\n",
Region->Exhausted ? "E" : " ", ClassId, getSizeByClassId(ClassId),
Region->MemMapInfo.MappedUser >> 10, Region->FreeListInfo.PoppedBlocks,
Region->FreeListInfo.PushedBlocks, InUseBlocks, TotalChunks,
Region->ReleaseInfo.NumReleasesAttempted,
Region->ReleaseInfo.LastReleasedBytes >> 10, RegionPushedBytesDelta >> 10,
- Region->RegionBeg, getRegionBaseByClassId(ClassId));
+ Region->RegionBeg, getRegionBaseByClassId(ClassId), LastReleaseSecAgo,
+ LastReleaseMsAgo);
}
template <typename Config>
@@ -1486,7 +1495,7 @@ uptr SizeClassAllocator64<Config>::releaseToOSMaybe(RegionInfo *Region,
Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint = BytesInFreeList;
Region->ReleaseInfo.LastReleasedBytes = Recorder.getReleasedBytes();
}
- Region->ReleaseInfo.LastReleaseAtNs = getMonotonicTimeFast();
+ Region->ReleaseInfo.LastReleaseAtNs = getMonotonicTime();
if (Region->ReleaseInfo.PendingPushedBytesDelta > 0) {
// Instead of increasing the threshold by the amount of
|
Region->ReleaseInfo.LastReleasedBytes = Recorder.getReleasedBytes(); | ||
} | ||
Region->ReleaseInfo.LastReleaseAtNs = getMonotonicTimeFast(); | ||
Region->ReleaseInfo.LastReleaseAtNs = getMonotonicTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to keep this with the fast version as long as we have the precise one in getStats
const u64 LastReleaseSecAgo = DiffSinceLastReleaseNs / 1000000000; | ||
const u64 LastReleaseMsAgo = (DiffSinceLastReleaseNs % 1000000000) / 1000000; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a new thought about this, given that we have ReleaseToOsInterval
, can we print something like > ReleaseToOsInterval
< ReleaseToOsInterval
?
If we hit the threshold to do the page release but it's too close (diff time less than ReleaseToOsInterval) then we will skip the page release. Thus I think longer/shorter than the interval gives us enough information about why the pages aren't released.
Sorry I didn't think about this while came up with the work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's chat this offline for more details
Having the time of last page release can help us figure out if the page release is skipped or not.