Commit 98131ca1 authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Remove the GPU watchdog V1 code

GPU watchdog V2 has been enabled for months. It's time to clean up V1.

Merge class GpuWatchdogThreadImplV2 and class GpuWatchdogThread, and use
GpuWatchdogThread as default.

Bug: 949839
Change-Id: Ic0d784bf4f3bcf79e60b71389c42a824429f83e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2455366Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814743}
parent 0d3b1f9c
...@@ -69,14 +69,6 @@ const base::Feature kGpuUseDisplayThreadPriority{ ...@@ -69,14 +69,6 @@ const base::Feature kGpuUseDisplayThreadPriority{
#endif #endif
}; };
// Gpu watchdog V2 to simplify the logic and reduce GPU hangs
const base::Feature kGpuWatchdogV2{"GpuWatchdogV2",
base::FEATURE_ENABLED_BY_DEFAULT};
// Use a different set of watchdog timeouts on V1
const base::Feature kGpuWatchdogV1NewTimeout{"GpuWatchdogV1NewTimeout",
base::FEATURE_ENABLED_BY_DEFAULT};
// Use a different set of watchdog timeouts on V2 // Use a different set of watchdog timeouts on V2
const base::Feature kGpuWatchdogV2NewTimeout{"GpuWatchdogV2NewTimeout", const base::Feature kGpuWatchdogV2NewTimeout{"GpuWatchdogV2NewTimeout",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -34,10 +34,6 @@ GPU_EXPORT extern const base::Feature kDirectCompositionUseOverlayDamageList; ...@@ -34,10 +34,6 @@ GPU_EXPORT extern const base::Feature kDirectCompositionUseOverlayDamageList;
GPU_EXPORT extern const base::Feature kGpuUseDisplayThreadPriority; GPU_EXPORT extern const base::Feature kGpuUseDisplayThreadPriority;
GPU_EXPORT extern const base::Feature kGpuWatchdogV2;
GPU_EXPORT extern const base::Feature kGpuWatchdogV1NewTimeout;
GPU_EXPORT extern const base::Feature kGpuWatchdogV2NewTimeout; GPU_EXPORT extern const base::Feature kGpuWatchdogV2NewTimeout;
#if defined(OS_MAC) #if defined(OS_MAC)
......
...@@ -37,8 +37,6 @@ component("service") { ...@@ -37,8 +37,6 @@ component("service") {
"gpu_memory_buffer_factory.h", "gpu_memory_buffer_factory.h",
"gpu_watchdog_thread.cc", "gpu_watchdog_thread.cc",
"gpu_watchdog_thread.h", "gpu_watchdog_thread.h",
"gpu_watchdog_thread_v2.cc",
"gpu_watchdog_thread_v2.h",
"image_decode_accelerator_stub.cc", "image_decode_accelerator_stub.cc",
"image_decode_accelerator_stub.h", "image_decode_accelerator_stub.h",
"image_decode_accelerator_worker.h", "image_decode_accelerator_worker.h",
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "gpu/config/gpu_switching.h" #include "gpu/config/gpu_switching.h"
#include "gpu/config/gpu_util.h" #include "gpu/config/gpu_util.h"
#include "gpu/ipc/service/gpu_watchdog_thread.h" #include "gpu/ipc/service/gpu_watchdog_thread.h"
#include "gpu/ipc/service/gpu_watchdog_thread_v2.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/gfx/switches.h" #include "ui/gfx/switches.h"
#include "ui/gl/buildflags.h" #include "ui/gl/buildflags.h"
...@@ -275,14 +274,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -275,14 +274,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
// Start the GPU watchdog only after anything that is expected to be time // Start the GPU watchdog only after anything that is expected to be time
// consuming has completed, otherwise the process is liable to be aborted. // consuming has completed, otherwise the process is liable to be aborted.
if (enable_watchdog && !delayed_watchdog_enable) { if (enable_watchdog && !delayed_watchdog_enable) {
if (base::FeatureList::IsEnabled(features::kGpuWatchdogV2)) { watchdog_thread_ = GpuWatchdogThread::Create(
watchdog_thread_ = GpuWatchdogThreadImplV2::Create( gpu_preferences_.watchdog_starts_backgrounded);
gpu_preferences_.watchdog_starts_backgrounded); watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get());
watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get());
} else {
watchdog_thread_ = GpuWatchdogThreadImplV1::Create(
gpu_preferences_.watchdog_starts_backgrounded);
}
#if defined(OS_WIN) #if defined(OS_WIN)
// This is a workaround for an occasional deadlock between watchdog and // This is a workaround for an occasional deadlock between watchdog and
...@@ -569,14 +563,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -569,14 +563,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
watchdog_thread_ = nullptr; watchdog_thread_ = nullptr;
watchdog_init.SetGpuWatchdogPtr(nullptr); watchdog_init.SetGpuWatchdogPtr(nullptr);
} else if (enable_watchdog && delayed_watchdog_enable) { } else if (enable_watchdog && delayed_watchdog_enable) {
if (base::FeatureList::IsEnabled(features::kGpuWatchdogV2)) { watchdog_thread_ = GpuWatchdogThread::Create(
watchdog_thread_ = GpuWatchdogThreadImplV2::Create( gpu_preferences_.watchdog_starts_backgrounded);
gpu_preferences_.watchdog_starts_backgrounded); watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get());
watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get());
} else {
watchdog_thread_ = GpuWatchdogThreadImplV1::Create(
gpu_preferences_.watchdog_starts_backgrounded);
}
} }
UMA_HISTOGRAM_ENUMERATION("GPU.GLImplementation", gl::GetGLImplementation()); UMA_HISTOGRAM_ENUMERATION("GPU.GLImplementation", gl::GetGLImplementation());
......
This diff is collapsed.
This diff is collapsed.
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "gpu/ipc/service/gpu_watchdog_thread.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "gpu/ipc/service/gpu_watchdog_thread_v2.h"
#include "base/power_monitor/power_monitor.h" #include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_source.h" #include "base/power_monitor/power_monitor_source.h"
...@@ -70,7 +70,7 @@ void GpuWatchdogTest::SetUp() { ...@@ -70,7 +70,7 @@ void GpuWatchdogTest::SetUp() {
ASSERT_TRUE(base::CurrentThread::IsSet()); ASSERT_TRUE(base::CurrentThread::IsSet());
// Set watchdog timeout to 1000 milliseconds // Set watchdog timeout to 1000 milliseconds
watchdog_thread_ = gpu::GpuWatchdogThreadImplV2::Create( watchdog_thread_ = gpu::GpuWatchdogThread::Create(
/*start_backgrounded*/ false, /*start_backgrounded*/ false,
/*timeout*/ kGpuWatchdogTimeoutForTesting, /*timeout*/ kGpuWatchdogTimeoutForTesting,
/*init_factor*/ kInitFactor, /*init_factor*/ kInitFactor,
......
This diff is collapsed.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_V2_H_
#define GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_V2_H_
#include "build/build_config.h"
#include "gpu/ipc/service/gpu_watchdog_thread.h"
namespace gpu {
#if defined(OS_WIN)
// If the actual time the watched GPU thread spent doing actual work is less
// than the wathdog timeout, the GPU thread can continue running through
// OnGPUWatchdogTimeout for at most 4 times before the gpu thread is killed.
constexpr int kMaxCountOfMoreGpuThreadTimeAllowed = 3;
#endif
constexpr int kMaxExtraCyclesBeforeKill = 0;
class GPU_IPC_SERVICE_EXPORT GpuWatchdogThreadImplV2
: public GpuWatchdogThread,
public base::TaskObserver {
public:
static std::unique_ptr<GpuWatchdogThreadImplV2> Create(
bool start_backgrounded);
static std::unique_ptr<GpuWatchdogThreadImplV2> Create(
bool start_backgrounded,
base::TimeDelta timeout,
int init_factor,
int restart_factor,
int max_extra_cycles_before_kill,
bool test_mode);
~GpuWatchdogThreadImplV2() override;
// Implements GpuWatchdogThread.
void AddPowerObserver() override;
void OnBackgrounded() override;
void OnForegrounded() override;
void OnInitComplete() override;
void OnGpuProcessTearDown() override;
void ResumeWatchdog() override;
void PauseWatchdog() override;
bool IsGpuHangDetectedForTesting() override;
void WaitForPowerObserverAddedForTesting() override;
// Implements base::Thread.
void Init() override;
void CleanUp() override;
// Implements gl::ProgressReporter.
void ReportProgress() override;
// Implements TaskObserver.
void WillProcessTask(const base::PendingTask& pending_task,
bool was_blocked_or_low_priority) override;
void DidProcessTask(const base::PendingTask& pending_task) override;
// Implements base::PowerObserver.
void OnSuspend() override;
void OnResume() override;
private:
enum PauseResumeSource {
kAndroidBackgroundForeground = 0,
kPowerSuspendResume = 1,
kGeneralGpuFlow = 2,
};
GpuWatchdogThreadImplV2(base::TimeDelta timeout,
int init_factor,
int restart_factor,
int max_extra_cycles_before_kill,
bool test_mode);
void OnAddPowerObserver();
void RestartWatchdogTimeoutTask(PauseResumeSource source_of_request);
void StopWatchdogTimeoutTask(PauseResumeSource source_of_request);
void UpdateInitializationFlag();
void Arm();
void Disarm();
void InProgress();
bool IsArmed();
base::subtle::Atomic32 ReadArmDisarmCounter();
void OnWatchdogTimeout();
bool SlowWatchdogThread();
bool WatchedThreadNeedsMoreThreadTime(bool no_gpu_hang_detected);
#if defined(OS_WIN)
base::ThreadTicks GetWatchedThreadTime();
#endif
bool WatchedThreadGetsExtraTimeout(bool no_gpu_hang);
// Do not change the function name. It is used for [GPU HANG] carsh reports.
void DeliberatelyTerminateToRecoverFromHang();
// Records "GPU.WatchdogThread.Event".
void GpuWatchdogHistogram(GpuWatchdogThreadEvent thread_event);
// Histogram recorded in OnWatchdogTimeout()
// Records "GPU.WatchdogThread.Timeout"
void GpuWatchdogTimeoutHistogram(GpuWatchdogTimeoutEvent timeout_event);
#if defined(OS_WIN)
// The extra thread time the GPU main thread needs to make a progress.
// Records "GPU.WatchdogThread.ExtraThreadTime".
void RecordExtraThreadTimeHistogram();
// The number of users per timeout stay in Chrome after giving extra thread
// time. Records "GPU.WatchdogThread.ExtraThreadTime.NumOfUsers" and
// "GPU.WatchdogThread.Timeout".
void RecordNumOfUsersWaitingWithExtraThreadTimeHistogram(int count);
// Histograms recorded for WatchedThreadNeedsMoreThreadTime() function.
void WatchedThreadNeedsMoreThreadTimeHistogram(
bool no_gpu_hang_detected,
bool start_of_more_thread_time);
#endif
// The number of users stay in Chrome after the extra timeout wait cycles.
// Records "GPU.WatchdogThread.WaitTime.ProgressAfterWait",
// "GPU.WatchdogThread.WaitTime.NumOfUsers" and "GPU.WatchdogThread.Timeout".
void WatchedThreadGetsExtraTimeoutHistogram(bool no_gpu_hang);
// Used for metrics. It's 1 minute after the event.
bool WithinOneMinFromPowerResumed();
bool WithinOneMinFromForegrounded();
#if defined(USE_X11)
void UpdateActiveTTY();
#endif
// The watchdog continues when it's not on the TTY of our host X11 server.
bool ContinueOnNonHostX11ServerTty();
// This counter is only written on the gpu thread, and read on both threads.
volatile base::subtle::Atomic32 arm_disarm_counter_ = 0;
// The counter number read in the last OnWatchdogTimeout() on the watchdog
// thread.
int32_t last_arm_disarm_counter_ = 0;
// Timeout on the watchdog thread to check if gpu hangs.
base::TimeDelta watchdog_timeout_;
// The one-time watchdog timeout multiplier in the gpu initialization.
int watchdog_init_factor_;
// The one-time watchdog timeout multiplier after the watchdog pauses and
// restarts.
int watchdog_restart_factor_;
// The time the gpu watchdog was created.
base::TimeTicks watchdog_start_timeticks_;
// The time the last OnSuspend and OnResume was called.
base::TimeTicks power_suspend_timeticks_;
base::TimeTicks power_resume_timeticks_;
// The time the last OnBackgrounded and OnForegrounded was called.
base::TimeTicks backgrounded_timeticks_;
base::TimeTicks foregrounded_timeticks_;
// The time PauseWatchdog and ResumeWatchdog was called.
base::TimeTicks watchdog_pause_timeticks_;
base::TimeTicks watchdog_resume_timeticks_;
// TimeTicks: Tracking the amount of time a task runs. Executing delayed
// tasks at the right time.
// ThreadTicks: Use this timer to (approximately) measure how much time the
// calling thread spent doing actual work vs. being de-scheduled.
// The time the last OnWatchdogTimeout() was called.
base::TimeTicks last_on_watchdog_timeout_timeticks_;
// The wall-clock time the next OnWatchdogTimeout() will be called.
base::Time next_on_watchdog_timeout_time_;
#if defined(OS_WIN)
base::ThreadTicks last_on_watchdog_timeout_thread_ticks_;
// The difference between the timeout and the actual time the watched thread
// spent doing actual work.
base::TimeDelta remaining_watched_thread_ticks_;
// The Windows thread hanndle of the watched GPU main thread.
void* watched_thread_handle_ = nullptr;
// After GPU hang detected, how many times has the GPU thread been allowed to
// continue due to not enough thread time.
int count_of_more_gpu_thread_time_allowed_ = 0;
// The total timeout, up to 60 seconds, the watchdog thread waits for the GPU
// main thread to get full thread time.
base::TimeDelta time_in_wait_for_full_thread_time_;
// After detecting GPU hang and continuing running through
// OnGpuWatchdogTimeout for the max cycles, the GPU main thread still cannot
// get the full thread time.
bool less_than_full_thread_time_after_capped_ = false;
#endif
#if defined(USE_X11)
FILE* tty_file_ = nullptr;
int host_tty_ = -1;
int active_tty_ = -1;
int last_active_tty_ = -1;
#endif
// The system has entered the power suspension mode.
bool in_power_suspension_ = false;
// The GPU process has started tearing down. Accessed only in the gpu process.
bool in_gpu_process_teardown_ = false;
// Chrome is running on the background on Android. Gpu is probably very slow
// or stalled.
bool is_backgrounded_ = false;
// The GPU watchdog is paused. The timeout task is temporarily stopped.
bool is_paused_ = false;
// Whether the watchdog thread has been called and added to the power monitor
// observer.
bool is_add_power_observer_called_ = false;
bool is_power_observer_added_ = false;
// whether GpuWatchdogThreadEvent::kGpuWatchdogStart has been recorded.
bool is_watchdog_start_histogram_recorded = false;
// Read/Write by the watchdog thread only after initialized in the
// constructor.
bool in_gpu_initialization_ = false;
// The number of logical processors/cores on the current machine.
int num_of_processors_ = 0;
// Don't kill the GPU process immediately after a gpu hang is detected. Wait
// for extra cycles of timeout. Kill it, if the GPU still doesn't respond
// after wait.
const int max_extra_cycles_before_kill_;
// how many cycles of timeout since we detect a hang.
int count_of_extra_cycles_ = 0;
// For the experiment and the debugging purpose
size_t num_of_timeout_after_power_resume_ = 0;
size_t num_of_timeout_after_foregrounded_ = 0;
bool foregrounded_event_ = false;
bool power_resumed_event_ = false;
// For gpu testing only.
const bool is_test_mode_;
// Set by the watchdog thread and Read by the test thread.
base::AtomicFlag test_result_timeout_and_gpu_hang_;
scoped_refptr<base::SingleThreadTaskRunner> watched_gpu_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> watchdog_thread_task_runner_;
base::WeakPtr<GpuWatchdogThreadImplV2> weak_ptr_;
base::WeakPtrFactory<GpuWatchdogThreadImplV2> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThreadImplV2);
};
} // namespace gpu
#endif // GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_V2_H_
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