Commit 0b7197a2 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

[gpu] Add trace events and thread priority assertion in GpuChannelHost.

Traces collected through Slow Reports show that acquiring the
GpuChannelHost lock from threads running at different priorities can
cause priority inversions. In particular, it can cause jank on the
renderer main thread through this chain of dependency:

> Main thread: cc::ProxyMain::BeginMainFrame
  > Compositor Thread: TileManager::FlushAndIssueSignals
    > CompositorTileWorkerBackground (slow):
        OneCopyRasterBuffer::Playback

This CL adds trace events to make contention on the GpuChannelHost lock
more obvious in traces, and an assertion to ensure that the
GpuChannelHost lock is never acquired at background thread priority.

Bug: 1072756
Change-Id: I2a25efe2e3f6e9bf5d980ca351a990f9c7d256b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157659
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarVictor Miura <vmiura@chromium.org>
Auto-Submit: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823744}
parent a483b6f5
......@@ -31,6 +31,19 @@ using base::AutoLock;
namespace gpu {
namespace {
// The |context_lock_| of the GpuChannelHost should only be acquired on
// foreground threads. Otherwise, a normal priority thread could end up waiting
// for a background thread. A background thread may not run for a long time when
// the system is busy.
void AssertForegroundThreadForGpuChannelHostLock() {
DCHECK_NE(base::ThreadPriority::BACKGROUND,
base::PlatformThread::GetCurrentThreadPriority());
}
} // namespace
GpuChannelHost::GpuChannelHost(int channel_id,
const gpu::GPUInfo& gpu_info,
const gpu::GpuFeatureInfo& gpu_feature_info,
......@@ -122,6 +135,9 @@ uint32_t GpuChannelHost::OrderingBarrier(
int32_t route_id,
int32_t put_offset,
std::vector<SyncToken> sync_token_fences) {
TRACE_EVENT0("ipc", "GpuChannelHost::OrderingBarrier");
AssertForegroundThreadForGpuChannelHostLock();
AutoLock lock(context_lock_);
if (pending_ordering_barrier_ &&
......@@ -143,6 +159,9 @@ uint32_t GpuChannelHost::OrderingBarrier(
uint32_t GpuChannelHost::EnqueueDeferredMessage(
const IPC::Message& message,
std::vector<SyncToken> sync_token_fences) {
TRACE_EVENT0("ipc", "GpuChannelHost::EnqueueDeferredMessage");
AssertForegroundThreadForGpuChannelHostLock();
AutoLock lock(context_lock_);
EnqueuePendingOrderingBarrier();
......@@ -155,11 +174,17 @@ uint32_t GpuChannelHost::EnqueueDeferredMessage(
}
void GpuChannelHost::EnsureFlush(uint32_t deferred_message_id) {
TRACE_EVENT0("ipc", "GpuChannelHost::EnsureFlush");
AssertForegroundThreadForGpuChannelHostLock();
AutoLock lock(context_lock_);
InternalFlush(deferred_message_id);
}
void GpuChannelHost::VerifyFlush(uint32_t deferred_message_id) {
TRACE_EVENT0("ipc", "GpuChannelHost::VerifyFlush");
AssertForegroundThreadForGpuChannelHostLock();
AutoLock lock(context_lock_);
InternalFlush(deferred_message_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment