github.com/bugraaydogar/snapd@v0.0.0-20210315170335-8c70bb858939/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 # https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html#policy-interface-in-sysfs 40 /sys/devices/system/cpu/cpufreq/{,**} r, 41 /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference w, 42 /sys/devices/system/cpu/cpufreq/policy*/scaling_governor w, 43 /sys/devices/system/cpu/cpufreq/policy*/scaling_max_freq w, 44 /sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq w, 45 /sys/devices/system/cpu/cpufreq/policy*/scaling_setspeed w, 46 /sys/devices/system/cpu/cpufreq/boost w, 47 48 # https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_pstate.html#user-space-interface-in-sysfs 49 /sys/devices/system/cpu/intel_pstate/{,*} r, 50 /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost w, 51 /sys/devices/system/cpu/intel_pstate/max_perf_pct w, 52 /sys/devices/system/cpu/intel_pstate/min_perf_pct w, 53 /sys/devices/system/cpu/intel_pstate/no_turbo w, 54 /sys/devices/system/cpu/intel_pstate/status w, 55 ` 56 57 func init() { 58 registerIface(&commonInterface{ 59 name: "cpu-control", 60 summary: cpuControlSummary, 61 implicitOnCore: true, 62 implicitOnClassic: true, 63 baseDeclarationSlots: cpuControlBaseDeclarationSlots, 64 connectedPlugAppArmor: cpuControlConnectedPlugAppArmor, 65 }) 66 }