Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / agl-systemd / tool_9E_SI / set_cgroup_rt_runtime_us.sh
1 #!/bin/bash
2 #
3 # @copyright Copyright (c) 2019 TOYOTA MOTOR CORPORATION.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 desired_rt_runtime_us=$1
19 mygroup=${2:-$(awk -F: '$2 == "cpu,cpuacct" {print $3}' /proc/self/cgroup)}
20
21 [[ $desired_rt_runtime_us -gt 0 ]] || exit
22 [[ $mygroup ]] || exit
23 [[ $mygroup = / ]] && exit
24
25 echo "${0##*/}: setting cpu.rt_runtime_us for $mygroup" >&2
26
27 cgpath=
28 IFS=/ read -ra cgroups <<< "${mygroup:1}"
29 for cg in "${cgroups[@]}"; do
30   cgpath="${cgpath}/${cg}"
31   echo "${0##*/}: $desired_rt_runtime_us -> /sys/fs/cgroup/cpu,cpuacct${cgpath}" >&2
32   echo "$desired_rt_runtime_us" > /sys/fs/cgroup/cpu,cpuacct${cgpath}/cpu.rt_runtime_us
33 done