Lines Matching +full:can +full:- +full:secondary

1 //===-- secondary.h ---------------------------------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
58 return reinterpret_cast<Header *>(addHeaderTag<Config>(Ptr)) - 1; in getHeader()
68 // Note that the `H->MapMap` is stored on the pages managed by itself. Take in unmap()
71 MemMapT MemMap = H->MemMap; in unmap()
108 // Not supported by the Secondary Cache, but not an error either. in setOption()
113 Str->append("Secondary Cache Disabled\n"); in getStats()
130 * and not over it. We can only do this if the address is page-aligned. in mapSecondary()
132 const uptr TaggedSize = AllocPos - CommitBase; in mapSecondary()
135 return MemMap.remap(CommitBase, TaggedSize, "scudo:secondary", in mapSecondary()
137 MemMap.remap(AllocPos, CommitSize - TaggedSize, "scudo:secondary", in mapSecondary()
142 return MemMap.remap(CommitBase, CommitSize, "scudo:secondary", in mapSecondary()
150 return MemMap.remap(CommitBase, UntaggedPos - CommitBase, "scudo:secondary", in mapSecondary()
152 MemMap.remap(UntaggedPos, CommitBase + CommitSize - UntaggedPos, in mapSecondary()
153 "scudo:secondary", Flags); in mapSecondary()
157 return MemMap.remap(CommitBase, CommitSize, "scudo:secondary", RemapFlags); in mapSecondary()
161 // Template specialization to avoid producing zero-length array
183 Str->append( in getStats()
187 atomic_load_relaxed(&MaxEntrySize), Interval >= 0 ? Interval : -1); in getStats()
188 Str->append("Stats: CacheRetrievalStats: SuccessRate: %u/%u " in getStats()
194 Str->append("StartBlockAddress: 0x%zx, EndBlockAddress: 0x%zx, " in getStats()
219 if (!canCache(H->CommitSize)) in store()
228 Entry.CommitBase = H->CommitBase; in store()
229 Entry.CommitSize = H->CommitSize; in store()
231 Entry.MemMap = H->MemMap; in store()
252 if (useMemoryTagging<Config>(Options) && QuarantinePos == -1U) { in store()
254 // read Options and when we locked Mutex. We can't insert our entry into in store()
293 releaseOlderThan(Time - static_cast<u64>(Interval) * 1000000); in store()
321 roundDown(CommitBase + CommitSize - Size, Alignment); in retrieve()
322 const uptr HeaderPos = AllocPos - HeadersSize; in retrieve()
330 const uptr Diff = HeaderPos - CommitBase; in retrieve()
334 (CommitBase + CommitSize - HeaderPos) / FragmentedBytesDivisor; in retrieve()
351 EntriesCount--; in retrieve()
374 (*H)->CommitBase = Entry.CommitBase; in retrieve()
375 (*H)->CommitSize = Entry.CommitSize; in retrieve()
376 (*H)->MemMap = Entry.MemMap; in retrieve()
405 // Not supported by the Secondary Cache, but not an error either. in setOption()
427 QuarantinePos = -1U; in disableMemoryTagging()
500 s32 ReleaseToOsInterval = -1) NO_THREAD_SAFETY_ANALYSIS {
506 S->link(&Stats);
517 return B->CommitBase + B->CommitSize; in getBlockEnd()
521 return getBlockEnd(Ptr) - reinterpret_cast<uptr>(Ptr); in getBlockSize()
576 // alignment, so that the frontend can align the user allocation. The hint
578 // (greater than a page) alignments on 32-bit platforms.
580 // an allocation from the Secondary with a large alignment would end up wasting
584 // the committed memory will amount to something close to Size - AlignmentHint
604 const uptr BlockEnd = H->CommitBase + H->CommitSize; in allocate()
614 BlockEnd - PtrInt); in allocate()
618 AllocatedBytes += H->CommitSize; in allocate()
619 FragmentedBytes += H->MemMap.getCapacity() - H->CommitSize; in allocate()
621 Stats.add(StatAllocated, H->CommitSize); in allocate()
622 Stats.add(StatMapped, H->MemMap.getCapacity()); in allocate()
631 RoundedSize += Alignment - PageSize; in allocate()
653 CommitBase = roundUp(MapBase + PageSize + 1, Alignment) - PageSize; in allocate()
654 const uptr NewMapBase = CommitBase - PageSize; in allocate()
656 // We only trim the extra memory on 32-bit platforms: 64-bit platforms in allocate()
659 MemMap.unmap(MapBase, NewMapBase - MapBase); in allocate()
666 MemMap.unmap(NewMapEnd, MapEnd - NewMapEnd); in allocate()
671 const uptr CommitSize = MapEnd - PageSize - CommitBase; in allocate()
672 const uptr AllocPos = roundDown(CommitBase + CommitSize - Size, Alignment); in allocate()
678 const uptr HeaderPos = AllocPos - getHeadersSize(); in allocate()
684 H->CommitBase = CommitBase; in allocate()
685 H->CommitSize = CommitSize; in allocate()
686 H->MemMap = MemMap; in allocate()
693 FragmentedBytes += H->MemMap.getCapacity() - CommitSize; in allocate()
698 Stats.add(StatMapped, H->MemMap.getCapacity()); in allocate()
707 const uptr CommitSize = H->CommitSize; in deallocate()
712 FragmentedBytes -= H->MemMap.getCapacity() - CommitSize; in deallocate()
715 Stats.sub(StatMapped, H->MemMap.getCapacity()); in deallocate()
723 Str->append("Stats: MapAllocator: allocated %u times (%zuK), freed %u times " in getStats()
726 FreedBytes >> 10, NumberOfAllocs - NumberOfFrees, in getStats()
727 (AllocatedBytes - FreedBytes) >> 10, LargestSize >> 20, in getStats()