|
19 | 19 | #include "stats.h"
|
20 | 20 | #include "string_utils.h"
|
21 | 21 | #include "thread_annotations.h"
|
| 22 | +#include "tracing.h" |
22 | 23 | #include "vector.h"
|
23 | 24 |
|
24 | 25 | namespace scudo {
|
@@ -118,7 +119,7 @@ template <typename Config> class MapAllocatorNoCache {
|
118 | 119 | bool canCache(UNUSED uptr Size) { return false; }
|
119 | 120 | void disable() {}
|
120 | 121 | void enable() {}
|
121 |
| - void releaseToOS() {} |
| 122 | + void releaseToOS(ReleaseToOS) {} |
122 | 123 | void disableMemoryTagging() {}
|
123 | 124 | void unmapTestOnly() {}
|
124 | 125 | bool setOption(Option O, UNUSED sptr Value) {
|
@@ -351,6 +352,9 @@ class MapAllocatorCache {
|
351 | 352 | // same time will not actually release any extra elements. Therefore,
|
352 | 353 | // let any other thread continue, skipping the release.
|
353 | 354 | if (Mutex.tryLock()) {
|
| 355 | + SCUDO_SCOPED_TRACE( |
| 356 | + GetSecondaryReleaseToOSTraceName(ReleaseToOS::Normal)); |
| 357 | + |
354 | 358 | // TODO: Add ReleaseToOS logic to LRU algorithm
|
355 | 359 | releaseOlderThan(Time - static_cast<u64>(Interval) * 1000000);
|
356 | 360 | Mutex.unlock();
|
@@ -499,7 +503,9 @@ class MapAllocatorCache {
|
499 | 503 | return true;
|
500 | 504 | }
|
501 | 505 |
|
502 |
| - void releaseToOS() EXCLUDES(Mutex) { |
| 506 | + void releaseToOS([[maybe_unused]] ReleaseToOS ReleaseType) EXCLUDES(Mutex) { |
| 507 | + SCUDO_SCOPED_TRACE(GetSecondaryReleaseToOSTraceName(ReleaseType)); |
| 508 | + |
503 | 509 | // Since this is a request to release everything, always wait for the
|
504 | 510 | // lock so that we guarantee all entries are released after this call.
|
505 | 511 | ScopedLock L(Mutex);
|
@@ -574,6 +580,8 @@ class MapAllocatorCache {
|
574 | 580 | }
|
575 | 581 |
|
576 | 582 | void releaseOlderThan(u64 Time) REQUIRES(Mutex) {
|
| 583 | + SCUDO_SCOPED_TRACE(GetSecondaryReleaseOlderThanTraceName()); |
| 584 | + |
577 | 585 | if (!LRUEntries.size() || OldestTime == 0 || OldestTime > Time)
|
578 | 586 | return;
|
579 | 587 | OldestTime = 0;
|
@@ -669,7 +677,7 @@ template <typename Config> class MapAllocator {
|
669 | 677 |
|
670 | 678 | bool setOption(Option O, sptr Value) { return Cache.setOption(O, Value); }
|
671 | 679 |
|
672 |
| - void releaseToOS() { Cache.releaseToOS(); } |
| 680 | + void releaseToOS(ReleaseToOS ReleaseType) { Cache.releaseToOS(ReleaseType); } |
673 | 681 |
|
674 | 682 | void disableMemoryTagging() { Cache.disableMemoryTagging(); }
|
675 | 683 |
|
|
0 commit comments