gitee.com/mysnapcore/mysnapd@v0.1.0/interfaces/builtin/cpu_control.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2018 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package builtin 21 22 const cpuControlSummary = `allows setting CPU tunables` 23 24 const cpuControlBaseDeclarationSlots = ` 25 cpu-control: 26 allow-installation: 27 slot-snap-type: 28 - core 29 deny-auto-connection: true 30 ` 31 32 const cpuControlConnectedPlugAppArmor = ` 33 # Description: This interface allows for setting CPU tunables 34 /sys/devices/system/cpu/**/ r, 35 /sys/devices/system/cpu/cpu*/online rw, 36 /sys/devices/system/cpu/smt/* r, 37 /sys/devices/system/cpu/smt/control w, 38 39 /sys/module/cpu_boost/parameters/input_boost_freq rw, 40 /sys/module/cpu_boost/parameters/input_boost_ms rw, 41 /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_min_freq rw, 42 /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_max_freq rw, 43 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/min_cpus rw, 44 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/busy_up_thres rw, 45 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/busy_down_thres rw, 46 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/offline_delay_ms rw, 47 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/task_thres rw, 48 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/nr_prev_assist_thresh rw, 49 /sys/devices/system/cpu/cpu[0-9]*/core_ctl/enable rw, 50 51 # https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html#policy-interface-in-sysfs 52 /sys/devices/system/cpu/cpufreq/{,**} r, 53 /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference w, 54 /sys/devices/system/cpu/cpufreq/policy*/scaling_governor w, 55 /sys/devices/system/cpu/cpufreq/policy*/scaling_max_freq w, 56 /sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq w, 57 /sys/devices/system/cpu/cpufreq/policy*/scaling_setspeed w, 58 /sys/devices/system/cpu/cpufreq/policy*/schedutil/up_rate_limit_us rw, 59 /sys/devices/system/cpu/cpufreq/policy*/schedutil/down_rate_limit_us rw, 60 /sys/devices/system/cpu/cpufreq/policy*/schedutil/hispeed_freq rw, 61 /sys/devices/system/cpu/cpufreq/policy*/schedutil/pl rw, 62 /sys/devices/system/cpu/cpufreq/boost w, 63 64 # https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_pstate.html#user-space-interface-in-sysfs 65 /sys/devices/system/cpu/intel_pstate/{,*} r, 66 /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost w, 67 /sys/devices/system/cpu/intel_pstate/max_perf_pct w, 68 /sys/devices/system/cpu/intel_pstate/min_perf_pct w, 69 /sys/devices/system/cpu/intel_pstate/no_turbo w, 70 /sys/devices/system/cpu/intel_pstate/status w, 71 72 /proc/sys/kernel/sched_upmigrate rw, 73 /proc/sys/kernel/sched_downmigrate rw, 74 /proc/sys/kernel/sched_group_upmigrate rw, 75 /proc/sys/kernel/sched_group_downmigrate rw, 76 /proc/sys/kernel/sched_walt_rotate_big_tasks rw, 77 /proc/sys/kernel/sched_boost rw, 78 79 # see https://www.osadl.org/monitoring/add-on-patches/4.16.7-rt1...4.16.15-rt7/sched-add-per-cpu-load-measurement.patch.html 80 /proc/idleruntime/{all,cpu[0-9]*}/data r, 81 /proc/idleruntime/{all,cpu[0-9]*}/reset w, 82 ` 83 84 func init() { 85 registerIface(&commonInterface{ 86 name: "cpu-control", 87 summary: cpuControlSummary, 88 implicitOnCore: true, 89 implicitOnClassic: true, 90 baseDeclarationSlots: cpuControlBaseDeclarationSlots, 91 connectedPlugAppArmor: cpuControlConnectedPlugAppArmor, 92 }) 93 }