blob: 8112b2e52dce1c42799bd9a002b85cabaaecc13f [file] [log] [blame]
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "configure rt runtime limits"
author "chromium-os-dev@chromium.org"
# This job depends on two other jobs: 1) cgroups.conf that creates
# session_manager_containers/ and 2) ui.conf that creates ui/. Because of the
# dependency, this job uses 'start on started ui' to wait for ui.conf's
# pre-start script to finish. This job doesn't have to wait for cgroups.conf
# because ui.conf already does that. 'on started boot-services' is also added
# to prevent the job from being started again on logout. The job should run
# only once shortly after device boot.
start on started boot-services and started ui
task
script
write_log() {
logger -t "${UPSTART_JOB}" "failed to write $1"
}
# set cgroup based limits.
echo 1000000 > /sys/fs/cgroup/cpu/cpu.rt_period_us || write_log cpu.rt_period_us
echo 800000 > /sys/fs/cgroup/cpu/cpu.rt_runtime_us || write_log cpu.rt_runtime_us
# Assign most of the RT times to ui group.
echo 1000000 > /sys/fs/cgroup/cpu/ui/cpu.rt_period_us || write_log ui/cpu.rt_period_us
echo 600000 > /sys/fs/cgroup/cpu/ui/cpu.rt_runtime_us || write_log ui/cpu.rt_runtime_us
# Assign RT times to session_manager_containers group.
echo 1000000 > /sys/fs/cgroup/cpu/session_manager_containers/cpu.rt_period_us || \
write_log session_manager_containers/cpu.rt_period_us
echo 200000 > /sys/fs/cgroup/cpu/session_manager_containers/cpu.rt_runtime_us || \
write_log session_manager_containers/cpu.rt_runtime_us
# set system-wide limit
echo 1000000 > /proc/sys/kernel/sched_rt_period_us || write_log sched_rt_period_us
echo 800000 > /proc/sys/kernel/sched_rt_runtime_us || write_log sched_rt_runtime_us
end script