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

Side by Side Diff: gpu/command_buffer/client/mapped_memory.cc

Issue 2382573002: Add BACKGROUND dump mode to various GPU/CC MemoryDumpProviders (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "gpu/command_buffer/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 iter = chunks_.erase(iter); 162 iter = chunks_.erase(iter);
163 } else { 163 } else {
164 ++iter; 164 ++iter;
165 } 165 }
166 } 166 }
167 } 167 }
168 168
169 bool MappedMemoryManager::OnMemoryDump( 169 bool MappedMemoryManager::OnMemoryDump(
170 const base::trace_event::MemoryDumpArgs& args, 170 const base::trace_event::MemoryDumpArgs& args,
171 base::trace_event::ProcessMemoryDump* pmd) { 171 base::trace_event::ProcessMemoryDump* pmd) {
172 const uint64_t tracing_process_id = 172 using base::trace_event::MemoryAllocatorDump;
173 base::trace_event::MemoryDumpManager::GetInstance() 173 using base::trace_event::MemoryDumpLevelOfDetail;
174 ->GetTracingProcessId();
175 174
176 for (const auto& chunk : chunks_) { 175 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
177 std::string dump_name = base::StringPrintf( 176 std::string dump_name =
178 "gpu/mapped_memory/manager_%d/chunk_%d", tracing_id_, chunk->shm_id()); 177 base::StringPrintf("gpu/mapped_memory/manager_%d", tracing_id_);
179 base::trace_event::MemoryAllocatorDump* dump = 178 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
180 pmd->CreateAllocatorDump(dump_name); 179 dump->AddScalar(MemoryAllocatorDump::kNameSize,
180 MemoryAllocatorDump::kUnitsBytes, allocated_memory_);
ssid 2016/10/07 00:07:21 return here?
ericrk 2016/10/13 23:58:13 Done.
181 } else {
182 const uint64_t tracing_process_id =
183 base::trace_event::MemoryDumpManager::GetInstance()
184 ->GetTracingProcessId();
185 for (const auto& chunk : chunks_) {
186 std::string dump_name =
187 base::StringPrintf("gpu/mapped_memory/manager_%d/chunk_%d",
188 tracing_id_, chunk->shm_id());
189 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
181 190
182 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 191 dump->AddScalar(MemoryAllocatorDump::kNameSize,
183 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 192 MemoryAllocatorDump::kUnitsBytes, chunk->GetSize());
184 chunk->GetSize()); 193 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes,
185 dump->AddScalar("free_size", 194 chunk->GetFreeSize());
186 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
187 chunk->GetFreeSize());
188 195
189 auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id()); 196 auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id());
190 197
191 const int kImportance = 2; 198 const int kImportance = 2;
192 pmd->CreateSharedGlobalAllocatorDump(guid); 199 pmd->CreateSharedGlobalAllocatorDump(guid);
193 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 200 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
201 }
194 } 202 }
195
196 return true; 203 return true;
197 } 204 }
198 205
199 void ScopedMappedMemoryPtr::Release() { 206 void ScopedMappedMemoryPtr::Release() {
200 if (buffer_) { 207 if (buffer_) {
201 mapped_memory_manager_->FreePendingToken(buffer_, helper_->InsertToken()); 208 mapped_memory_manager_->FreePendingToken(buffer_, helper_->InsertToken());
202 buffer_ = nullptr; 209 buffer_ = nullptr;
203 size_ = 0; 210 size_ = 0;
204 shm_id_ = 0; 211 shm_id_ = 0;
205 shm_offset_ = 0; 212 shm_offset_ = 0;
206 213
207 if (flush_after_release_) 214 if (flush_after_release_)
208 helper_->CommandBufferHelper::Flush(); 215 helper_->CommandBufferHelper::Flush();
209 } 216 }
210 } 217 }
211 218
212 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) { 219 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) {
213 Release(); 220 Release();
214 221
215 if (new_size) { 222 if (new_size) {
216 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_); 223 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_);
217 size_ = buffer_ ? new_size : 0; 224 size_ = buffer_ ? new_size : 0;
218 } 225 }
219 } 226 }
220 227
221 } // namespace gpu 228 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698