| # 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 |
| |
| # Controlled by ebuild to assign rt_runtime_us to the correct ARC. |
| env IS_ARCVM=0 |
| |
| 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 850000 > /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 |
| |
| if [ ${IS_ARCVM} -eq 1 ]; then |
| # Assign RT times to vms group. |
| echo 1000000 > /sys/fs/cgroup/cpu/vms/cpu.rt_period_us || \ |
| write_log vms/cpu.rt_period_us |
| echo 250000 > /sys/fs/cgroup/cpu/vms/cpu.rt_runtime_us || \ |
| write_log vms/cpu.rt_runtime_us |
| |
| # Assign RT times to vmc/arc group. |
| echo 1000000 > /sys/fs/cgroup/cpu/vms/arc/cpu.rt_period_us || \ |
| write_log vms/arc/cpu.rt_period_us |
| echo 200000 > /sys/fs/cgroup/cpu/vms/arc/cpu.rt_runtime_us || \ |
| write_log vms/arc/cpu.rt_runtime_us |
| else |
| # 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 |
| |
| # Assign RT times to vms group. |
| echo 1000000 > /sys/fs/cgroup/cpu/vms/cpu.rt_period_us || \ |
| write_log vms/cpu.rt_period_us |
| echo 50000 > /sys/fs/cgroup/cpu/vms/cpu.rt_runtime_us || \ |
| write_log vms/cpu.rt_runtime_us |
| fi |
| |
| # Assign RT times to vmc/termina group. |
| echo 1000000 > /sys/fs/cgroup/cpu/vms/termina/cpu.rt_period_us || \ |
| write_log vms/termina/cpu.rt_period_us |
| echo 50000 > /sys/fs/cgroup/cpu/vms/termina/cpu.rt_runtime_us || \ |
| write_log vms/termina/cpu.rt_runtime_us |
| |
| # set system-wide limit |
| echo 1000000 > /proc/sys/kernel/sched_rt_period_us || write_log sched_rt_period_us |
| echo 850000 > /proc/sys/kernel/sched_rt_runtime_us || write_log sched_rt_runtime_us |
| end script |
| |