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

Side by Side Diff: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc

Issue 2725813005: ozone: drm: Add fd number to crash keys when dmabuf mmap fails. (Closed)
Patch Set: ozone: drm: Add fd number to crash keys when dmabuf mmap fails. Created 3 years, 9 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
« chrome/common/crash_keys.cc ('K') | « chrome/common/crash_keys.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" 5 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/version.h> 8 #include <linux/version.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/mman.h> 10 #include <sys/mman.h>
11 #include <xf86drm.h> 11 #include <xf86drm.h>
12 12
13 #include "base/debug/crash_logging.h" 13 #include "base/debug/crash_logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/process/memory.h" 15 #include "base/process/memory.h"
16 #include "base/process/process_metrics.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
18 19
19 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) 20 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
20 #include <linux/types.h> 21 #include <linux/types.h>
21 22
22 struct local_dma_buf_sync { 23 struct local_dma_buf_sync {
23 __u64 flags; 24 __u64 flags;
24 }; 25 };
25 26
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (data_ == MAP_FAILED) { 85 if (data_ == MAP_FAILED) {
85 // TODO(dcastagna): Remove the following diagnostic information and the 86 // TODO(dcastagna): Remove the following diagnostic information and the
86 // associated crash keys once crbug.com/629521 is fixed. 87 // associated crash keys once crbug.com/629521 is fixed.
87 logging::SystemErrorCode mmap_error = logging::GetLastSystemErrorCode(); 88 logging::SystemErrorCode mmap_error = logging::GetLastSystemErrorCode();
88 bool fd_valid = fcntl(dmabuf_fd_.get(), F_GETFD) != -1 || 89 bool fd_valid = fcntl(dmabuf_fd_.get(), F_GETFD) != -1 ||
89 logging::GetLastSystemErrorCode() != EBADF; 90 logging::GetLastSystemErrorCode() != EBADF;
90 std::string mmap_params = base::StringPrintf( 91 std::string mmap_params = base::StringPrintf(
91 "(addr=nullptr, length=%zu, prot=(PROT_READ | PROT_WRITE), " 92 "(addr=nullptr, length=%zu, prot=(PROT_READ | PROT_WRITE), "
92 "flags=MAP_SHARED, fd=%d[valid=%d], offset=0)", 93 "flags=MAP_SHARED, fd=%d[valid=%d], offset=0)",
93 map_size, dmabuf_fd_.get(), fd_valid); 94 map_size, dmabuf_fd_.get(), fd_valid);
95 std::string errno_str = logging::SystemErrorCodeToString(mmap_error);
96 std::unique_ptr<base::ProcessMetrics> process_metrics(
97 base::ProcessMetrics::CreateCurrentProcessMetrics());
Daniele Castagna 2017/03/02 02:05:04 CreateCurrentProcessMetrics calls base::GetCurrent
dshwang 2017/03/02 19:59:31 That's good point. By the way, it's base::GetCurre
Daniele Castagna 2017/03/02 20:08:52 Are you sure this works in the GPU process and the
dshwang 2017/03/02 20:15:12 I run this code in chromeos, and it works in only
98 std::string number_of_fds =
99 base::StringPrintf("%d", process_metrics->GetOpenFdCount());
Daniele Castagna 2017/03/02 02:05:04 This would report -1 in case we're out of fds sinc
dshwang 2017/03/02 19:59:31 OH, that's good point. I didn't think about it. Fo
Daniele Castagna 2017/03/02 20:08:52 We were thinking of addding a UMA stat for openfds
dshwang 2017/03/02 20:15:12 good to know. do you want to wait for UMA stat cha
94 base::debug::ScopedCrashKey params_crash_key("mmap_params", mmap_params); 100 base::debug::ScopedCrashKey params_crash_key("mmap_params", mmap_params);
95 base::debug::ScopedCrashKey size_crash_key("buffer_size", size.ToString()); 101 base::debug::ScopedCrashKey size_crash_key("buffer_size", size.ToString());
96 base::debug::ScopedCrashKey errno_crash_key( 102 base::debug::ScopedCrashKey errno_crash_key("errno", errno_str);
97 "errno", logging::SystemErrorCodeToString(mmap_error)); 103 base::debug::ScopedCrashKey number_of_fds_crash_key("number_of_fds",
104 number_of_fds);
105 LOG(ERROR) << "Failed to mmap dmabuf; mmap_params: " << mmap_params
106 << ", buffer_size: (" << size.ToString()
107 << "), errno: " << errno_str
108 << " , number_of_fds: " << number_of_fds;
98 if (mmap_error == ENOMEM) 109 if (mmap_error == ENOMEM)
99 base::TerminateBecauseOutOfMemory(map_size); 110 base::TerminateBecauseOutOfMemory(map_size);
100 CHECK(false) << "Failed to mmap dmabuf."; 111 CHECK(false);
112 ;
Daniele Castagna 2017/03/02 02:05:04 Why did you remove a useful log and just left a fl
dshwang 2017/03/02 19:59:31 Done.
101 } 113 }
102 } 114 }
103 115
104 ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() { 116 ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
105 TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf"); 117 TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf");
106 size_t map_size = 118 size_t map_size =
107 pixmap_handle_.planes.back().offset + pixmap_handle_.planes.back().size; 119 pixmap_handle_.planes.back().offset + pixmap_handle_.planes.back().size;
108 int ret = munmap(data_, map_size); 120 int ret = munmap(data_, map_size);
109 DCHECK(!ret); 121 DCHECK(!ret);
110 } 122 }
(...skipping 17 matching lines...) Expand all
128 uint8_t* address = reinterpret_cast<uint8_t*>(data_); 140 uint8_t* address = reinterpret_cast<uint8_t*>(data_);
129 return address + pixmap_handle_.planes[plane].offset; 141 return address + pixmap_handle_.planes[plane].offset;
130 } 142 }
131 143
132 int ClientNativePixmapDmaBuf::GetStride(size_t plane) const { 144 int ClientNativePixmapDmaBuf::GetStride(size_t plane) const {
133 DCHECK_LT(plane, pixmap_handle_.planes.size()); 145 DCHECK_LT(plane, pixmap_handle_.planes.size());
134 return pixmap_handle_.planes[plane].stride; 146 return pixmap_handle_.planes[plane].stride;
135 } 147 }
136 148
137 } // namespace ui 149 } // namespace ui
OLDNEW
« chrome/common/crash_keys.cc ('K') | « chrome/common/crash_keys.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698