• 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
53  implements m.ClassComponent<RecordingSectionAttrs>
54{
55  view({attrs}: m.CVnode<RecordingSectionAttrs>) {
56    return m(
57      `.record-section${attrs.cssClass}`,
58      m(
59        Probe,
60        {
61          title: 'Advanced ftrace config',
62          img: 'rec_ftrace.png',
63          descr: `Enable individual events and tune the kernel-tracing (ftrace)
64                  module. The events enabled here are in addition to those from
65                  enabled by other probes.`,
66          setEnabled: (cfg, val) => (cfg.ftrace = val),
67          isEnabled: (cfg) => cfg.ftrace,
68        } as ProbeAttrs,
69        m(Toggle, {
70          title: 'Resolve kernel symbols',
71          cssClass: '.thin',
72          descr: `Enables lookup via /proc/kallsyms for workqueue,
73              sched_blocked_reason and other events
74              (userdebug/eng builds only).`,
75          setEnabled: (cfg, val) => (cfg.symbolizeKsyms = val),
76          isEnabled: (cfg) => cfg.symbolizeKsyms,
77        } as ToggleAttrs),
78        m(Slider, {
79          title: 'Buf size',
80          cssClass: '.thin',
81          values: [0, 512, 1024, 2 * 1024, 4 * 1024, 16 * 1024, 32 * 1024],
82          unit: 'KB',
83          zeroIsDefault: true,
84          set: (cfg, val) => (cfg.ftraceBufferSizeKb = val),
85          get: (cfg) => cfg.ftraceBufferSizeKb,
86        } as SliderAttrs),
87        m(Slider, {
88          title: 'Drain rate',
89          cssClass: '.thin',
90          values: [0, 100, 250, 500, 1000, 2500, 5000],
91          unit: 'ms',
92          zeroIsDefault: true,
93          set: (cfg, val) => (cfg.ftraceDrainPeriodMs = val),
94          get: (cfg) => cfg.ftraceDrainPeriodMs,
95        } as SliderAttrs),
96        m(Dropdown, {
97          title: 'Event groups',
98          cssClass: '.multicolumn.ftrace-events',
99          options: FTRACE_CATEGORIES,
100          set: (cfg, val) => (cfg.ftraceEvents = val),
101          get: (cfg) => cfg.ftraceEvents,
102        } as DropdownAttrs),
103        m(Textarea, {
104          placeholder:
105            'Add extra events, one per line, e.g.:\n' +
106            'sched/sched_switch\n' +
107            'kmem/*',
108          set: (cfg, val) => (cfg.ftraceExtraEvents = val),
109          get: (cfg) => cfg.ftraceExtraEvents,
110        } as TextareaAttrs),
111      ),
112    );
113  }
114}
115