This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Support dumping fragmentation data in SizeClassAllocator64
ClosedPublic

Authored by Chia-hungDuan on Aug 17 2023, 3:26 PM.

Details

Summary

This tells the number of pages that still have blocks in-used, i.e.,
those pages can't do releaseToOSMaybe(). Along with the information of
getStats() and RSS usage from the system (like smaps), we can tell if
the heuristic in releaseToOSMaybe() works well in certain scenarios.

Here's the sample output:

Fragmentation Stats: SizeClassAllocator64: page size = 4096
  01 (    32): inuse/total blocks:    275/   416 inuse/total pages:      4/     4 inuse bytes:     16K
  02 (    48): inuse/total blocks:    182/   312 inuse/total pages:      4/     4 inuse bytes:     16K
  03 (    64): inuse/total blocks:    169/   312 inuse/total pages:      5/     5 inuse bytes:     20K
  ...
  32 (  1040): inuse/total blocks:     90/   152 inuse/total pages:     37/    39 inuse bytes:    148K
  33 (  1168): inuse/total blocks:    136/   232 inuse/total pages:     64/    67 inuse bytes:    256K
  34 (  1296): inuse/total blocks:    138/   226 inuse/total pages:     68/    72 inuse bytes:    272K
  35 (  1424): inuse/total blocks:    140/   232 inuse/total pages:     78/    81 inuse bytes:    312K
  36 (  1552): inuse/total blocks:    157/   248 inuse/total pages:     89/    94 inuse bytes:    356K
  ...

SizeClassAllocator32 requires further refactoring to support this.

Diff Detail

Event Timeline

Chia-hungDuan created this revision.Aug 17 2023, 3:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 3:26 PM
Herald added subscribers: yaneury, Enna1. · View Herald Transcript
Chia-hungDuan requested review of this revision.Aug 17 2023, 3:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 3:26 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Add in-used bytes data

Chia-hungDuan edited the summary of this revision. (Show Details)Aug 17 2023, 3:42 PM

One minor comment suggestion.

compiler-rt/lib/scudo/standalone/primary32.h
316

which

Chia-hungDuan marked an inline comment as done.

Address review comment

Also dump fragmentation data when calling mallopt(M_LOG_STATS)

cferris accepted this revision.Aug 18 2023, 12:53 PM

LGTM.

This revision is now accepted and ready to land.Aug 18 2023, 12:53 PM