Skip to content
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

xtest: stats: report heap fragmentation metric #781

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jenswi-linaro
Copy link
Contributor

A new field is added to struct pta_stats_alloc, free2_sum, the sum of size^2 of each free chunk. This can be used to calculate a fragmentation metric for the heap [1]. Some examples with xtest --stats --alloc:

When booted:
Pool: Heap
Bytes allocated: 21376
Fragmentation: 3 %
Max bytes allocated: 21488
Size of pool: 202608

At some point during xtest:
Pool: Heap
Bytes allocated: 31616
Fragmentation: 54 %
Max bytes allocated: 101312
Size of pool: 202608

When xtest has completed:
Pool: Heap
Bytes allocated: 25824
Fragmentation: 33 %
Max bytes allocated: 101312
Size of pool: 202608

Link: [1] https://asawicki.info/news_1757_a_metric_for_memory_fragmentation

AristoChen and others added 2 commits March 5, 2025 18:26
There is a typo 'Unkown' in the error message, should be
changed to 'Unknown' instead.

Signed-off-by: Aristo Chen <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
A new field is added to struct pta_stats_alloc, free2_sum, the sum of
size^2 of each free chunk. This can be used to calculate a fragmentation
metric for the heap [1]. Some examples with xtest --stats --alloc:

When booted:
Pool:                Heap
Bytes allocated:                       21376
Fragmentation:			       3 %
Max bytes allocated:                   21488
Size of pool:                          202608

At some point during xtest:
Pool:                Heap
Bytes allocated:                       31616
Fragmentation:			       54 %
Max bytes allocated:                   101312
Size of pool:                          202608

When xtest has completed:
Pool:                Heap
Bytes allocated:                       25824
Fragmentation:			       33 %
Max bytes allocated:                   101312
Size of pool:                          202608

Link: [1] https://asawicki.info/news_1757_a_metric_for_memory_fragmentation
Signed-off-by: Jens Wiklander <[email protected]>
@jenswi-linaro
Copy link
Contributor Author

Depends on OP-TEE/optee_os#7302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants