[PATCH] D74178: [scudo][standalone] 32-bit improvement
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 17:02:33 PST 2020
cryptoad updated this revision to Diff 243055.
cryptoad added a comment.
Without extra `.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74178/new/
https://reviews.llvm.org/D74178
Files:
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/size_class_map.h
compiler-rt/lib/scudo/standalone/wrappers_c_bionic.cpp
Index: compiler-rt/lib/scudo/standalone/wrappers_c_bionic.cpp
===================================================================
--- compiler-rt/lib/scudo/standalone/wrappers_c_bionic.cpp
+++ compiler-rt/lib/scudo/standalone/wrappers_c_bionic.cpp
@@ -55,11 +55,9 @@
#undef SCUDO_ALLOCATOR
#undef SCUDO_PREFIX
-// The following is the only function that will end up initializing both
-// allocators, which will result in a slight increase in memory footprint.
+// TODO(kostyak): support both allocators.
INTERFACE void __scudo_print_stats(void) {
Allocator.printStats();
- SvelteAllocator.printStats();
}
#endif // SCUDO_ANDROID && _BIONIC
Index: compiler-rt/lib/scudo/standalone/size_class_map.h
===================================================================
--- compiler-rt/lib/scudo/standalone/size_class_map.h
+++ compiler-rt/lib/scudo/standalone/size_class_map.h
@@ -144,7 +144,7 @@
typedef SizeClassMap<2, 5, 9, 16, 14, 14> AndroidSizeClassMap;
#else
typedef SizeClassMap<4, 3, 7, 14, 5, 10> SvelteSizeClassMap;
-typedef SizeClassMap<2, 5, 9, 16, 14, 14> AndroidSizeClassMap;
+typedef SizeClassMap<3, 4, 8, 16, 14, 14> AndroidSizeClassMap;
#endif
} // namespace scudo
Index: compiler-rt/lib/scudo/standalone/primary32.h
===================================================================
--- compiler-rt/lib/scudo/standalone/primary32.h
+++ compiler-rt/lib/scudo/standalone/primary32.h
@@ -88,7 +88,7 @@
unmap(reinterpret_cast<void *>(RegionsStash[--NumberOfStashedRegions]),
RegionSize);
// TODO(kostyak): unmap the TransferBatch regions as well.
- for (uptr I = 0; I < NumRegions; I++)
+ for (uptr I = MinRegionIndex; I <= MaxRegionIndex; I++)
if (PossibleRegions[I])
unmap(reinterpret_cast<void *>(I * RegionSize), RegionSize);
PossibleRegions.unmapTestOnly();
@@ -258,14 +258,12 @@
if (!Region)
Region = allocateRegionSlow();
if (LIKELY(Region)) {
- if (ClassId) {
- const uptr RegionIndex = computeRegionId(Region);
- if (RegionIndex < MinRegionIndex)
- MinRegionIndex = RegionIndex;
- if (RegionIndex > MaxRegionIndex)
- MaxRegionIndex = RegionIndex;
- PossibleRegions.set(RegionIndex, static_cast<u8>(ClassId));
- }
+ const uptr RegionIndex = computeRegionId(Region);
+ if (RegionIndex < MinRegionIndex)
+ MinRegionIndex = RegionIndex;
+ if (RegionIndex > MaxRegionIndex)
+ MaxRegionIndex = RegionIndex;
+ PossibleRegions.set(RegionIndex, static_cast<u8>(ClassId));
}
return Region;
}
@@ -350,10 +348,10 @@
const uptr InUse = Sci->Stats.PoppedBlocks - Sci->Stats.PushedBlocks;
const uptr AvailableChunks = Sci->AllocatedUser / getSizeByClassId(ClassId);
Str->append(" %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu "
- "inuse: %6zu avail: %6zu rss: %6zuK\n",
+ "inuse: %6zu avail: %6zu rss: %6zuK releases: %6zu\n",
ClassId, getSizeByClassId(ClassId), Sci->AllocatedUser >> 10,
Sci->Stats.PoppedBlocks, Sci->Stats.PushedBlocks, InUse,
- AvailableChunks, Rss >> 10);
+ AvailableChunks, Rss >> 10, Sci->ReleaseInfo.RangesReleased);
}
NOINLINE uptr releaseToOSMaybe(SizeClassInfo *Sci, uptr ClassId,
@@ -390,9 +388,10 @@
uptr TotalReleasedBytes = 0;
for (uptr I = MinRegionIndex; I <= MaxRegionIndex; I++) {
if (PossibleRegions[I] == ClassId) {
- ReleaseRecorder Recorder(I * RegionSize);
- releaseFreeMemoryToOS(Sci->FreeList, I * RegionSize,
- RegionSize / PageSize, BlockSize, &Recorder);
+ const uptr Region = I * RegionSize;
+ ReleaseRecorder Recorder(Region);
+ releaseFreeMemoryToOS(Sci->FreeList, Region, RegionSize / PageSize,
+ BlockSize, &Recorder);
if (Recorder.getReleasedRangesCount() > 0) {
Sci->ReleaseInfo.PushedBlocksAtLastRelease = Sci->Stats.PushedBlocks;
Sci->ReleaseInfo.RangesReleased += Recorder.getReleasedRangesCount();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74178.243055.patch
Type: text/x-patch
Size: 4119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200207/b397aded/attachment.bin>
More information about the llvm-commits
mailing list