1// Copyright (C) 2022 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import m from 'mithril'; 16 17import {Probe, ProbeAttrs, Slider, SliderAttrs} from '../record_widgets'; 18import {POLL_INTERVAL_MS, RecordingSectionAttrs} from './recording_sections'; 19 20export class CpuSettings implements m.ClassComponent<RecordingSectionAttrs> { 21 view({attrs}: m.CVnode<RecordingSectionAttrs>) { 22 return m( 23 `.record-section${attrs.cssClass}`, 24 m( 25 Probe, 26 { 27 title: 'Coarse CPU usage counter', 28 img: 'rec_cpu_coarse.png', 29 descr: `Lightweight polling of CPU usage counters via /proc/stat. 30 Allows to periodically monitor CPU usage.`, 31 setEnabled: (cfg, val) => (cfg.cpuCoarse = val), 32 isEnabled: (cfg) => cfg.cpuCoarse, 33 } as ProbeAttrs, 34 m(Slider, { 35 title: 'Poll interval', 36 cssClass: '.thin', 37 values: POLL_INTERVAL_MS, 38 unit: 'ms', 39 set: (cfg, val) => (cfg.cpuCoarsePollMs = val), 40 get: (cfg) => cfg.cpuCoarsePollMs, 41 } as SliderAttrs), 42 ), 43 m(Probe, { 44 title: 'Scheduling details', 45 img: 'rec_cpu_fine.png', 46 descr: 'Enables high-detailed tracking of scheduling events', 47 setEnabled: (cfg, val) => (cfg.cpuSched = val), 48 isEnabled: (cfg) => cfg.cpuSched, 49 } as ProbeAttrs), 50 m( 51 Probe, 52 { 53 title: 'CPU frequency and idle states', 54 img: 'rec_cpu_freq.png', 55 descr: 56 'Records cpu frequency and idle state changes via ftrace and sysfs', 57 setEnabled: (cfg, val) => (cfg.cpuFreq = val), 58 isEnabled: (cfg) => cfg.cpuFreq, 59 } as ProbeAttrs, 60 m(Slider, { 61 title: 'Sysfs poll interval', 62 cssClass: '.thin', 63 values: POLL_INTERVAL_MS, 64 unit: 'ms', 65 set: (cfg, val) => (cfg.cpuFreqPollMs = val), 66 get: (cfg) => cfg.cpuFreqPollMs, 67 } as SliderAttrs), 68 ), 69 m(Probe, { 70 title: 'Syscalls', 71 img: 'rec_syscalls.png', 72 descr: `Tracks the enter and exit of all syscalls. On Android 73 requires a userdebug or eng build.`, 74 setEnabled: (cfg, val) => (cfg.cpuSyscall = val), 75 isEnabled: (cfg) => cfg.cpuSyscall, 76 } as ProbeAttrs), 77 ); 78 } 79} 80