• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
18  Dropdown,
19  DropdownAttrs,
20  Probe,
21  ProbeAttrs,
22  Slider,
23  SliderAttrs,
24  Textarea,
25  TextareaAttrs,
26  Toggle,
27  ToggleAttrs,
28} from '../record_widgets';
29import {RecordingSectionAttrs} from './recording_sections';
30
31const FTRACE_CATEGORIES = new Map<string, string>();
32FTRACE_CATEGORIES.set('binder/*', 'binder');
33FTRACE_CATEGORIES.set('block/*', 'block');
34FTRACE_CATEGORIES.set('clk/*', 'clk');
35FTRACE_CATEGORIES.set('ext4/*', 'ext4');
36FTRACE_CATEGORIES.set('f2fs/*', 'f2fs');
37FTRACE_CATEGORIES.set('i2c/*', 'i2c');
38FTRACE_CATEGORIES.set('irq/*', 'irq');
39FTRACE_CATEGORIES.set('kmem/*', 'kmem');
40FTRACE_CATEGORIES.set('memory_bus/*', 'memory_bus');
41FTRACE_CATEGORIES.set('mmc/*', 'mmc');
42FTRACE_CATEGORIES.set('oom/*', 'oom');
43FTRACE_CATEGORIES.set('power/*', 'power');
44FTRACE_CATEGORIES.set('regulator/*', 'regulator');
45FTRACE_CATEGORIES.set('sched/*', 'sched');
46FTRACE_CATEGORIES.set('sync/*', 'sync');
47FTRACE_CATEGORIES.set('task/*', 'task');
48FTRACE_CATEGORIES.set('task/*', 'task');
49FTRACE_CATEGORIES.set('vmscan/*', 'vmscan');
50FTRACE_CATEGORIES.set('fastrpc/*', 'fastrpc');
51
52export class AdvancedSettings implements
53    m.ClassComponent<RecordingSectionAttrs> {
54  view({attrs}: m.CVnode<RecordingSectionAttrs>) {
55    return m(
56        `.record-section${attrs.cssClass}`,
57        m(Probe,
58          {
59            title: 'Advanced ftrace config',
60            img: 'rec_ftrace.png',
61            descr:
62                `Enable individual events and tune the kernel-tracing (ftrace)
63                  module. The events enabled here are in addition to those from
64                  enabled by other probes.`,
65            setEnabled: (cfg, val) => cfg.ftrace = val,
66            isEnabled: (cfg) => cfg.ftrace,
67          } as ProbeAttrs,
68          m(Toggle, {
69            title: 'Resolve kernel symbols',
70            cssClass: '.thin',
71            descr: `Enables lookup via /proc/kallsyms for workqueue,
72              sched_blocked_reason and other events
73              (userdebug/eng builds only).`,
74            setEnabled: (cfg, val) => cfg.symbolizeKsyms = val,
75            isEnabled: (cfg) => cfg.symbolizeKsyms,
76          } as ToggleAttrs),
77          m(Slider, {
78            title: 'Buf size',
79            cssClass: '.thin',
80            values: [0, 512, 1024, 2 * 1024, 4 * 1024, 16 * 1024, 32 * 1024],
81            unit: 'KB',
82            zeroIsDefault: true,
83            set: (cfg, val) => cfg.ftraceBufferSizeKb = val,
84            get: (cfg) => cfg.ftraceBufferSizeKb,
85          } as SliderAttrs),
86          m(Slider, {
87            title: 'Drain rate',
88            cssClass: '.thin',
89            values: [0, 100, 250, 500, 1000, 2500, 5000],
90            unit: 'ms',
91            zeroIsDefault: true,
92            set: (cfg, val) => cfg.ftraceDrainPeriodMs = val,
93            get: (cfg) => cfg.ftraceDrainPeriodMs,
94          } as SliderAttrs),
95          m(Dropdown, {
96            title: 'Event groups',
97            cssClass: '.multicolumn.ftrace-events',
98            options: FTRACE_CATEGORIES,
99            set: (cfg, val) => cfg.ftraceEvents = val,
100            get: (cfg) => cfg.ftraceEvents,
101          } as DropdownAttrs),
102          m(Textarea, {
103            placeholder: 'Add extra events, one per line, e.g.:\n' +
104                'sched/sched_switch\n' +
105                'kmem/*',
106            set: (cfg, val) => cfg.ftraceExtraEvents = val,
107            get: (cfg) => cfg.ftraceExtraEvents,
108          } as TextareaAttrs)));
109  }
110}
111