Commit 033c69e3 authored by Ikjoon Jang's avatar Ikjoon Jang Committed by Chromium LUCI CQ

base/thread: Add a new switch for chromeos scheduler tunings

For urgent threads, Chrome is now using uclamp util_min value(20)
to boost the performance instead of schedtune settings from external
upstart scripts.

This patch adds a new 'scheduler-boost-urgent=xxx' switch which makes
those urgent threads can have more aggressive boost values (0~100).

This might be needed for some ChromeOS platforms who can get better
performance from higher boosting value (e.g. Trogdor's power_VideoCall).

Additionally, existing Feature parameter names for uclamp changed to
have more general meanings:
  { MinUrgent, MaxNonUrgent, LatencySensitive } -->
  { BoostUrgent, LimitNonUrgent, LatencyTune }

BUG=1041117,b:159370915
TEST=check /proc/*/sched for all urgent threads
Signed-off-by: default avatarIkjoon Jang <ikjn@chromium.org>
Change-Id: I07b19ed748ffba9d9a45c76310635dc359e557af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2477712Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837001}
parent 03bea837
......@@ -164,4 +164,13 @@ const char kForceFieldTrialParams[] = "force-fieldtrial-params";
const char kEnableThreadInstructionCount[] = "enable-thread-instruction-count";
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
// Override the default scheduling boosting value for urgent tasks.
// This can be adjusted if a specific chromeos device shows better perf/power
// ratio (e.g. by running video conference tests).
// Currently, this values directs to linux scheduler's utilization min clamp.
// Range is 0(no biased load) ~ 100(mamximum load value).
const char kSchedulerBoostUrgent[] = "scheduler-boost-urgent";
#endif
} // namespace switches
......@@ -62,6 +62,10 @@ extern const char kForceFieldTrialParams[];
extern const char kEnableThreadInstructionCount[];
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
extern const char kSchedulerBoostUrgent[];
#endif
} // namespace switches
#endif // BASE_BASE_SWITCHES_H_
......@@ -10,6 +10,8 @@
#include <cstdint>
#include <atomic>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
......@@ -42,7 +44,15 @@ namespace {
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
std::atomic<bool> g_use_sched_util(true);
std::atomic<bool> g_feature_checked(false);
std::atomic<bool> g_scheduler_hints_adjusted(false);
const int kSchedulerBoostDef = 20;
const int kSchedulerLimitDef = 100;
const bool kSchedulerUseLatencyTuneDef = true;
int g_scheduler_boost_adj;
int g_scheduler_limit_adj;
bool g_scheduler_use_latency_tune_adj;
#if !defined(OS_NACL) && !defined(OS_AIX)
// sched_attr is used to set scheduler attributes for Linux. It is not a POSIX
......@@ -161,18 +171,14 @@ void SetThreadLatencySensitivity(ProcessId process_id,
return;
// FieldTrial API can be called only once features were parsed.
if (g_feature_checked.load()) {
uclamp_min_urgent =
GetFieldTrialParamByFeatureAsInt(kSchedUtilHints, "MinUrgent", 20);
uclamp_max_non_urgent = GetFieldTrialParamByFeatureAsInt(
kSchedUtilHints, "MaxNonUrgent", 100);
latency_sensitive_urgent = GetFieldTrialParamByFeatureAsBool(
kSchedUtilHints, "LatencySensitive", true);
if (g_scheduler_hints_adjusted.load()) {
uclamp_min_urgent = g_scheduler_boost_adj;
uclamp_max_non_urgent = g_scheduler_limit_adj;
latency_sensitive_urgent = g_scheduler_use_latency_tune_adj;
} else {
// Use defaults if features were not parsed yet...
uclamp_min_urgent = 20;
uclamp_max_non_urgent = 100;
latency_sensitive_urgent = true;
uclamp_min_urgent = kSchedulerBoostDef;
uclamp_max_non_urgent = kSchedulerLimitDef;
latency_sensitive_urgent = kSchedulerUseLatencyTuneDef;
}
// The thread_id passed in here is either 0 (in which case we ste for current
......@@ -369,8 +375,34 @@ void PlatformThread::InitThreadPostFieldTrial() {
DCHECK(FeatureList::GetInstance());
if (!FeatureList::IsEnabled(kSchedUtilHints)) {
g_use_sched_util.store(false);
return;
}
g_feature_checked.store(true);
int boost_def = kSchedulerBoostDef;
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSchedulerBoostUrgent)) {
std::string boost_switch_str =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kSchedulerBoostUrgent);
int boost_switch_val;
if (!StringToInt(boost_switch_str, &boost_switch_val) ||
boost_switch_val < 0 || boost_switch_val > 100) {
DVPLOG(1) << "Invalid input for " << switches::kSchedulerBoostUrgent;
} else {
boost_def = boost_switch_val;
}
}
g_scheduler_boost_adj = GetFieldTrialParamByFeatureAsInt(
kSchedUtilHints, "BoostUrgent", boost_def);
g_scheduler_limit_adj = GetFieldTrialParamByFeatureAsInt(
kSchedUtilHints, "LimitNonUrgent", kSchedulerLimitDef);
g_scheduler_use_latency_tune_adj = GetFieldTrialParamByFeatureAsBool(
kSchedUtilHints, "LatencyTune", kSchedulerUseLatencyTuneDef);
g_scheduler_hints_adjusted.store(true);
}
#endif
......
......@@ -129,6 +129,7 @@ void DeriveCommandLine(const GURL& start_url,
::switches::kPpapiInProcess,
::switches::kRemoteDebuggingPort,
::switches::kRendererStartupDialog,
::switches::kSchedulerBoostUrgent,
::switches::kSchedulerConfigurationDefault,
::switches::kTouchDevices,
::switches::kTouchEventFeatureDetection,
......
......@@ -305,6 +305,9 @@ static const char* const kSwitchNames[] = {
#if BUILDFLAG(IS_CHROMEOS_ASH)
switches::kPlatformDisallowsChromeOSDirectVideoDecoder,
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
switches::kSchedulerBoostUrgent,
#endif
};
// These values are persisted to logs. Entries should not be renumbered and
......
......@@ -3355,6 +3355,9 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
#endif
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
switches::kEnableClearHevcForTesting,
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
switches::kSchedulerBoostUrgent,
#endif
};
renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames,
......
......@@ -287,6 +287,9 @@ bool UtilityProcessHost::StartProcess() {
sandbox::policy::switches::kAddXrAppContainerCaps,
#endif
network::switches::kUseFirstPartySet,
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
switches::kSchedulerBoostUrgent,
#endif
};
cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
base::size(kSwitchNames));
......
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