OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/allocator/partition_allocator/partition_alloc.h" | 5 #include "base/allocator/partition_allocator/partition_alloc.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/allocator/partition_allocator/oom.h" | 9 #include "base/allocator/partition_allocator/oom.h" |
10 #include "base/allocator/partition_allocator/spin_lock.h" | 10 #include "base/allocator/partition_allocator/spin_lock.h" |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 | 1389 |
1390 stats.total_resident_bytes += direct_mapped_allocations_total_size; | 1390 stats.total_resident_bytes += direct_mapped_allocations_total_size; |
1391 stats.total_active_bytes += direct_mapped_allocations_total_size; | 1391 stats.total_active_bytes += direct_mapped_allocations_total_size; |
1392 dumper->PartitionDumpTotals(partition_name, &stats); | 1392 dumper->PartitionDumpTotals(partition_name, &stats); |
1393 } | 1393 } |
1394 | 1394 |
1395 void PartitionDumpStats(PartitionRoot* partition, | 1395 void PartitionDumpStats(PartitionRoot* partition, |
1396 const char* partition_name, | 1396 const char* partition_name, |
1397 bool is_light_dump, | 1397 bool is_light_dump, |
1398 PartitionStatsDumper* dumper) { | 1398 PartitionStatsDumper* dumper) { |
1399 static const size_t kMaxReportableBuckets = 4096 / sizeof(void*); | |
1400 PartitionBucketMemoryStats memory_stats[kMaxReportableBuckets]; | |
1401 const size_t partitionNumBuckets = partition->num_buckets; | |
1402 DCHECK(partitionNumBuckets <= kMaxReportableBuckets); | |
1403 | 1399 |
1404 for (size_t i = 0; i < partitionNumBuckets; ++i) | |
1405 PartitionDumpBucketStats(&memory_stats[i], &partition->buckets()[i]); | |
1406 | |
1407 // PartitionsDumpBucketStats is called after collecting stats because it | |
1408 // can use PartitionAlloc to allocate and this can affect the statistics. | |
1409 PartitionMemoryStats stats = {0}; | 1400 PartitionMemoryStats stats = {0}; |
1410 stats.total_mmapped_bytes = partition->total_size_of_super_pages; | 1401 stats.total_mmapped_bytes = partition->total_size_of_super_pages; |
1411 stats.total_committed_bytes = partition->total_size_of_committed_pages; | 1402 stats.total_committed_bytes = partition->total_size_of_committed_pages; |
1412 DCHECK(!partition->total_size_of_direct_mapped_pages); | 1403 DCHECK(!partition->total_size_of_direct_mapped_pages); |
| 1404 |
| 1405 static const size_t kMaxReportableBuckets = 4096 / sizeof(void*); |
| 1406 std::unique_ptr<PartitionBucketMemoryStats[]> memory_stats; |
| 1407 if (!is_light_dump) |
| 1408 memory_stats = std::unique_ptr<PartitionBucketMemoryStats[]>( |
| 1409 new PartitionBucketMemoryStats[kMaxReportableBuckets]); |
| 1410 |
| 1411 const size_t partitionNumBuckets = partition->num_buckets; |
| 1412 DCHECK(partitionNumBuckets <= kMaxReportableBuckets); |
| 1413 |
1413 for (size_t i = 0; i < partitionNumBuckets; ++i) { | 1414 for (size_t i = 0; i < partitionNumBuckets; ++i) { |
1414 if (memory_stats[i].is_valid) { | 1415 PartitionBucketMemoryStats bucket_stats = {0}; |
1415 stats.total_resident_bytes += memory_stats[i].resident_bytes; | 1416 PartitionDumpBucketStats(&bucket_stats, &partition->buckets()[i]); |
1416 stats.total_active_bytes += memory_stats[i].active_bytes; | 1417 if (bucket_stats.is_valid) { |
1417 stats.total_decommittable_bytes += memory_stats[i].decommittable_bytes; | 1418 stats.total_resident_bytes += bucket_stats.resident_bytes; |
1418 stats.total_discardable_bytes += memory_stats[i].discardable_bytes; | 1419 stats.total_active_bytes += bucket_stats.active_bytes; |
1419 if (!is_light_dump) | 1420 stats.total_decommittable_bytes += bucket_stats.decommittable_bytes; |
| 1421 stats.total_discardable_bytes += bucket_stats.discardable_bytes; |
| 1422 } |
| 1423 if (!is_light_dump) { |
| 1424 if (bucket_stats.is_valid) |
| 1425 memory_stats[i] = bucket_stats; |
| 1426 else |
| 1427 memory_stats[i].is_valid = false; |
| 1428 } |
| 1429 } |
| 1430 if (!is_light_dump) { |
| 1431 // PartitionsDumpBucketStats is called after collecting stats because it |
| 1432 // can use PartitionAlloc to allocate and this can affect the statistics. |
| 1433 for (size_t i = 0; i < partitionNumBuckets; ++i) { |
| 1434 if (memory_stats[i].is_valid) |
1420 dumper->PartitionsDumpBucketStats(partition_name, &memory_stats[i]); | 1435 dumper->PartitionsDumpBucketStats(partition_name, &memory_stats[i]); |
1421 } | 1436 } |
1422 } | 1437 } |
1423 dumper->PartitionDumpTotals(partition_name, &stats); | 1438 dumper->PartitionDumpTotals(partition_name, &stats); |
1424 } | 1439 } |
1425 | 1440 |
1426 } // namespace base | 1441 } // namespace base |
OLD | NEW |