Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: Source/wtf/PartitionAlloc.cpp

Issue 1315113006: Add partitionsOutOfMemoryUsingXXX to know Blink memory usage from OOM crash reports (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/wtf/PartitionAlloc.h ('k') | Source/wtf/Partitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Check that some of our zanier calculations worked out as expected. 52 // Check that some of our zanier calculations worked out as expected.
53 static_assert(WTF::kGenericSmallestBucket == 8, "generic smallest bucket"); 53 static_assert(WTF::kGenericSmallestBucket == 8, "generic smallest bucket");
54 static_assert(WTF::kGenericMaxBucketed == 983040, "generic max bucketed"); 54 static_assert(WTF::kGenericMaxBucketed == 983040, "generic max bucketed");
55 55
56 namespace WTF { 56 namespace WTF {
57 57
58 int PartitionRootBase::gInitializedLock = 0; 58 int PartitionRootBase::gInitializedLock = 0;
59 bool PartitionRootBase::gInitialized = false; 59 bool PartitionRootBase::gInitialized = false;
60 PartitionPage PartitionRootBase::gSeedPage; 60 PartitionPage PartitionRootBase::gSeedPage;
61 PartitionBucket PartitionRootBase::gPagedBucket; 61 PartitionBucket PartitionRootBase::gPagedBucket;
62 void (*PartitionRootBase::gOomHandlingFunction)() = nullptr;
62 63
63 static uint16_t partitionBucketNumSystemPages(size_t size) 64 static uint16_t partitionBucketNumSystemPages(size_t size)
64 { 65 {
65 // This works out reasonably for the current bucket sizes of the generic 66 // This works out reasonably for the current bucket sizes of the generic
66 // allocator, and the current values of partition page size and constants. 67 // allocator, and the current values of partition page size and constants.
67 // Specifically, we have enough room to always pack the slots perfectly into 68 // Specifically, we have enough room to always pack the slots perfectly into
68 // some number of system pages. The only waste is the waste associated with 69 // some number of system pages. The only waste is the waste associated with
69 // unfaulted pages (i.e. wasted address space). 70 // unfaulted pages (i.e. wasted address space).
70 // TODO: we end up using a lot of system pages for very small sizes. For 71 // TODO: we end up using a lot of system pages for very small sizes. For
71 // example, we'll use 12 system pages for slot size 24. The slot size is 72 // example, we'll use 12 system pages for slot size 24. The slot size is
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 132
132 static void partitionBucketInitBase(PartitionBucket* bucket, PartitionRootBase* root) 133 static void partitionBucketInitBase(PartitionBucket* bucket, PartitionRootBase* root)
133 { 134 {
134 bucket->activePagesHead = &PartitionRootGeneric::gSeedPage; 135 bucket->activePagesHead = &PartitionRootGeneric::gSeedPage;
135 bucket->emptyPagesHead = 0; 136 bucket->emptyPagesHead = 0;
136 bucket->decommittedPagesHead = 0; 137 bucket->decommittedPagesHead = 0;
137 bucket->numFullPages = 0; 138 bucket->numFullPages = 0;
138 bucket->numSystemPagesPerSlotSpan = partitionBucketNumSystemPages(bucket->sl otSize); 139 bucket->numSystemPagesPerSlotSpan = partitionBucketNumSystemPages(bucket->sl otSize);
139 } 140 }
140 141
142 void partitionAllocGlobalInit(void (*oomHandlingFunction)())
143 {
144 ASSERT(oomHandlingFunction);
145 PartitionRootBase::gOomHandlingFunction = oomHandlingFunction;
146 }
147
141 void partitionAllocInit(PartitionRoot* root, size_t numBuckets, size_t maxAlloca tion) 148 void partitionAllocInit(PartitionRoot* root, size_t numBuckets, size_t maxAlloca tion)
142 { 149 {
143 partitionAllocBaseInit(root); 150 partitionAllocBaseInit(root);
144 151
145 root->numBuckets = numBuckets; 152 root->numBuckets = numBuckets;
146 root->maxAllocation = maxAllocation; 153 root->maxAllocation = maxAllocation;
147 size_t i; 154 size_t i;
148 for (i = 0; i < root->numBuckets; ++i) { 155 for (i = 0; i < root->numBuckets; ++i) {
149 PartitionBucket* bucket = &root->buckets()[i]; 156 PartitionBucket* bucket = &root->buckets()[i];
150 if (!i) 157 if (!i)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 308
302 static NEVER_INLINE void partitionOutOfMemory(const PartitionRootBase* root) 309 static NEVER_INLINE void partitionOutOfMemory(const PartitionRootBase* root)
303 { 310 {
304 #if !CPU(64BIT) 311 #if !CPU(64BIT)
305 // Check whether this OOM is due to a lot of super pages that are allocated 312 // Check whether this OOM is due to a lot of super pages that are allocated
306 // but not committed, probably due to http://crbug.com/421387. 313 // but not committed, probably due to http://crbug.com/421387.
307 if (root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages - root- >totalSizeOfCommittedPages > kReasonableSizeOfUnusedPages) { 314 if (root->totalSizeOfSuperPages + root->totalSizeOfDirectMappedPages - root- >totalSizeOfCommittedPages > kReasonableSizeOfUnusedPages) {
308 partitionOutOfMemoryWithLotsOfUncommitedPages(); 315 partitionOutOfMemoryWithLotsOfUncommitedPages();
309 } 316 }
310 #endif 317 #endif
318 if (PartitionRootBase::gOomHandlingFunction)
319 (*PartitionRootBase::gOomHandlingFunction)();
311 IMMEDIATE_CRASH(); 320 IMMEDIATE_CRASH();
312 } 321 }
313 322
314 static NEVER_INLINE void partitionExcessiveAllocationSize() 323 static NEVER_INLINE void partitionExcessiveAllocationSize()
315 { 324 {
316 IMMEDIATE_CRASH(); 325 IMMEDIATE_CRASH();
317 } 326 }
318 327
319 static NEVER_INLINE void partitionBucketFull() 328 static NEVER_INLINE void partitionBucketFull()
320 { 329 {
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 partitionStats.totalDiscardableBytes += memoryStats[i].discardableBy tes; 1405 partitionStats.totalDiscardableBytes += memoryStats[i].discardableBy tes;
1397 if (!isLightDump) 1406 if (!isLightDump)
1398 partitionStatsDumper->partitionsDumpBucketStats(partitionName, & memoryStats[i]); 1407 partitionStatsDumper->partitionsDumpBucketStats(partitionName, & memoryStats[i]);
1399 } 1408 }
1400 } 1409 }
1401 partitionStatsDumper->partitionDumpTotals(partitionName, &partitionStats); 1410 partitionStatsDumper->partitionDumpTotals(partitionName, &partitionStats);
1402 } 1411 }
1403 1412
1404 } // namespace WTF 1413 } // namespace WTF
1405 1414
OLDNEW
« no previous file with comments | « Source/wtf/PartitionAlloc.h ('k') | Source/wtf/Partitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698