← Documents Documentation/trace/coresight/coresight-config.rst GitHub 원문 ↗

Linux 6.18.37 · Tracing

CoreSight System Configuration Manager

CoreSight feature·parameter·configuration·preset 계층을 정의하고, autofdo와 strobing을 configfs·perf·sysfs에서 조회·조정·활성화하며 custom module을 안전하게 로드하는 방법을 설명합니다.

Source pathDocumentation/trace/coresight/coresight-config.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

coresight-config.rst:1-294

CoreSight feature·parameter·configuration·preset 계층을 정의하고, autofdo와 strobing을 configfs·perf·sysfs에서 조회·조정·활성화하며 custom module을 안전하게 로드하는 방법을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ======================================
4 CoreSight System Configuration Manager
5 ======================================
6
7 :Author: Mike Leach <[email protected]>
8 :Date: October 2020
9
10 Introduction
11 ============
12
13 The CoreSight System Configuration manager is an API that allows the
14 programming of the CoreSight system with pre-defined configurations that
15 can then be easily enabled from sysfs or perf.
16
17 Many CoreSight components can be programmed in complex ways - especially ETMs.
18 In addition, components can interact across the CoreSight system, often via
19 the cross trigger components such as CTI and CTM. These system settings can
20 be defined and enabled as named configurations.
21
22
23 Basic Concepts
24 ==============
25
26 This section introduces the basic concepts of a CoreSight system configuration.
27
28
29 Features
30 --------
31
32 A feature is a named set of programming for a CoreSight device. The programming
33 is device dependent, and can be defined in terms of absolute register values,
34 resource usage and parameter values.
35
36 The feature is defined using a descriptor. This descriptor is used to load onto
37 a matching device, either when the feature is loaded into the system, or when the
38 CoreSight device is registered with the configuration manager.
39
40 The load process involves interpreting the descriptor into a set of register
41 accesses in the driver - the resource usage and parameter descriptions
42 translated into appropriate register accesses. This interpretation makes it easy
43 and efficient for the feature to be programmed onto the device when required.
44
45 The feature will not be active on the device until the feature is enabled, and
46 the device itself is enabled. When the device is enabled then enabled features
47 will be programmed into the device hardware.
48
49 A feature is enabled as part of a configuration being enabled on the system.
50
51
52 Parameter Value
53 ~~~~~~~~~~~~~~~
54
55 A parameter value is a named value that may be set by the user prior to the
56 feature being enabled that can adjust the behaviour of the operation programmed
57 by the feature.
58
59 For example, this could be a count value in a programmed operation that repeats
60 at a given rate. When the feature is enabled then the current value of the
61 parameter is used in programming the device.
62
63 The feature descriptor defines a default value for a parameter, which is used
64 if the user does not supply a new value.
65
66 Users can update parameter values using the configfs API for the CoreSight
67 system - which is described below.
68
69 The current value of the parameter is loaded into the device when the feature
70 is enabled on that device.
71
72
73 Configurations
74 --------------
75
76 A configuration defines a set of features that are to be used in a trace
77 session where the configuration is selected. For any trace session only one
78 configuration may be selected.
79
80 The features defined may be on any type of device that is registered
81 to support system configuration. A configuration may select features to be
82 enabled on a class of devices - i.e. any ETMv4, or specific devices, e.g. a
83 specific CTI on the system.
84
85 As with the feature, a descriptor is used to define the configuration.
86 This will define the features that must be enabled as part of the configuration
87 as well as any preset values that can be used to override default parameter
88 values.
89
90
91 Preset Values
92 ~~~~~~~~~~~~~
93
94 Preset values are easily selectable sets of parameter values for the features
95 that the configuration uses. The number of values in a single preset set, equals
96 the sum of parameter values in the features used by the configuration.
97
98 e.g. a configuration consists of 3 features, one has 2 parameters, one has
99 a single parameter, and another has no parameters. A single preset set will
100 therefore have 3 values.
101
102 Presets are optionally defined by the configuration, up to 15 can be defined.
103 If no preset is selected, then the parameter values defined in the feature
104 are used as normal.
105
106
107 Operation
108 ~~~~~~~~~
109
110 The following steps take place in the operation of a configuration.
111
112 1) In this example, the configuration is 'autofdo', which has an
113 associated feature 'strobing' that works on ETMv4 CoreSight Devices.
114
115 2) The configuration is enabled. For example 'perf' may select the
116 configuration as part of its command line::
117
118 perf record -e cs_etm/autofdo/ myapp
119
120 which will enable the 'autofdo' configuration.
121
122 3) perf starts tracing on the system. As each ETMv4 that perf uses for
123 trace is enabled, the configuration manager will check if the ETMv4
124 has a feature that relates to the currently active configuration.
125 In this case 'strobing' is enabled & programmed into the ETMv4.
126
127 4) When the ETMv4 is disabled, any registers marked as needing to be
128 saved will be read back.
129
130 5) At the end of the perf session, the configuration will be disabled.
131
132
133 Viewing Configurations and Features
134 ===================================
135
136 The set of configurations and features that are currently loaded into the
137 system can be viewed using the configfs API.
138
139 Mount configfs as normal and the 'cs-syscfg' subsystem will appear::
140
141 $ ls /config
142 cs-syscfg stp-policy
143
144 This has two sub-directories::
145
146 $ cd cs-syscfg/
147 $ ls
148 configurations features
149
150 The system has the configuration 'autofdo' built in. It may be examined as
151 follows::
152
153 $ cd configurations/
154 $ ls
155 autofdo
156 $ cd autofdo/
157 $ ls
158 description feature_refs preset1 preset3 preset5 preset7 preset9
159 enable preset preset2 preset4 preset6 preset8
160 $ cat description
161 Setup ETMs with strobing for autofdo
162 $ cat feature_refs
163 strobing
164
165 Each preset declared has a 'preset<n>' subdirectory declared. The values for
166 the preset can be examined::
167
168 $ cat preset1/values
169 strobing.window = 0x1388 strobing.period = 0x2
170 $ cat preset2/values
171 strobing.window = 0x1388 strobing.period = 0x4
172
173 The 'enable' and 'preset' files allow the control of a configuration when
174 using CoreSight with sysfs.
175
176 The features referenced by the configuration can be examined in the features
177 directory::
178
179 $ cd ../../features/strobing/
180 $ ls
181 description matches nr_params params
182 $ cat description
183 Generate periodic trace capture windows.
184 parameter 'window': a number of CPU cycles (W)
185 parameter 'period': trace enabled for W cycles every period x W cycles
186 $ cat matches
187 SRC_ETMV4
188 $ cat nr_params
189 2
190
191 Move to the params directory to examine and adjust parameters::
192
193 cd params
194 $ ls
195 period window
196 $ cd period
197 $ ls
198 value
199 $ cat value
200 0x2710
201 # echo 15000 > value
202 # cat value
203 0x3a98
204
205 Parameters adjusted in this way are reflected in all device instances that have
206 loaded the feature.
207
208
209 Using Configurations in perf
210 ============================
211
212 The configurations loaded into the CoreSight configuration management are
213 also declared in the perf 'cs_etm' event infrastructure so that they can
214 be selected when running trace under perf::
215
216 $ ls /sys/devices/cs_etm
217 cpu0 cpu2 events nr_addr_filters power subsystem uevent
218 cpu1 cpu3 format perf_event_mux_interval_ms sinks type
219
220 The key directory here is 'events' - a generic perf directory which allows
221 selection on the perf command line. As with the sinks entries, this provides
222 a hash of the configuration name.
223
224 The entry in the 'events' directory uses perfs built in syntax generator
225 to substitute the syntax for the name when evaluating the command::
226
227 $ ls events/
228 autofdo
229 $ cat events/autofdo
230 configid=0xa7c3dddd
231
232 The 'autofdo' configuration may be selected on the perf command line::
233
234 $ perf record -e cs_etm/autofdo/u --per-thread <application>
235
236 A preset to override the current parameter values can also be selected::
237
238 $ perf record -e cs_etm/autofdo,preset=1/u --per-thread <application>
239
240 When configurations are selected in this way, then the trace sink used is
241 automatically selected.
242
243 Using Configurations in sysfs
244 =============================
245
246 Coresight can be controlled using sysfs. When this is in use then a configuration
247 can be made active for the devices that are used in the sysfs session.
248
249 In a configuration there are 'enable' and 'preset' files.
250
251 To enable a configuration for use with sysfs::
252
253 $ cd configurations/autofdo
254 $ echo 1 > enable
255
256 This will then use any default parameter values in the features - which can be
257 adjusted as described above.
258
259 To use a preset<n> set of parameter values::
260
261 $ echo 3 > preset
262
263 This will select preset3 for the configuration.
264 The valid values for preset are 0 - to deselect presets, and any value of
265 <n> where a preset<n> sub-directory is present.
266
267 Note that the active sysfs configuration is a global parameter, therefore
268 only a single configuration can be active for sysfs at any one time.
269 Attempting to enable a second configuration will result in an error.
270 Additionally, attempting to disable the configuration while in use will
271 also result in an error.
272
273 The use of the active configuration by sysfs is independent of the configuration
274 used in perf.
275
276
277 Creating and Loading Custom Configurations
278 ==========================================
279
280 Custom configurations and / or features can be dynamically loaded into the
281 system by using a loadable module.
282
283 An example of a custom configuration is found in ./samples/coresight.
284
285 This creates a new configuration that uses the existing built in
286 strobing feature, but provides a different set of presets.
287
288 When the module is loaded, then the configuration appears in the configfs
289 file system and is selectable in the same way as the built in configuration
290 described above.
291
292 Configurations can use previously loaded features. The system will ensure
293 that it is not possible to unload a feature that is currently in use, by
294 enforcing the unload order as the strict reverse of the load order.
295

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

소개: 이름 있는 시스템 구성

1-22

이 문서는 GPL-2.0 라이선스를 사용하며 Mike Leach가 2020년 10월에 작성했다. CoreSight System Configuration Manager는 미리 정의한 configuration으로 CoreSight 시스템을 프로그래밍하고, 이후 sysfs 또는 perf에서 간단히 활성화할 수 있게 하는 API다.

많은 CoreSight component, 특히 ETM은 복잡한 방식으로 프로그래밍할 수 있다. component들은 CTI와 CTM 같은 cross-trigger component를 통해 시스템 전체에서 상호작용하기도 한다. 이런 시스템 설정을 이름 있는 configuration으로 정의하고 활성화할 수 있다.

Configuration Manager 역할
CoreSight devicesFeature descriptors
Cross-trigger interactionNamed configuration
sysfs or perfEnable trace setup

복잡한 장치별 programming을 재사용 가능한 이름으로 묶어 사용자 인터페이스에 노출한다.

구성 대상
대상특징
ETM복잡한 trace source programming
CTI / CTMcomponent 사이 cross-trigger 연동
Configuration Manager이름 있는 시스템 설정 정의와 활성화

configuration으로 함께 다룰 수 있는 CoreSight 요소다.

.. SPDX-License-Identifier: GPL-2.0

======================================
CoreSight System Configuration Manager
======================================

    :Author:   Mike Leach <[email protected]>
    :Date:     October 2020

Introduction
============

The CoreSight System Configuration manager is an API that allows the
programming of the CoreSight system with pre-defined configurations that
can then be easily enabled from sysfs or perf.

Many CoreSight components can be programmed in complex ways - especially ETMs.
In addition, components can interact across the CoreSight system, often via
the cross trigger components such as CTI and CTM. These system settings can
be defined and enabled as named configurations.

기본 개념의 계층

23-28

CoreSight 시스템 configuration의 기본 단위는 feature, parameter value, configuration, preset value다. 뒤 절에서 각 단위의 정의와 수명 주기를 설명한다.

기본 개념 계층
FeatureParameter values
FeaturesConfiguration
ConfigurationPreset values
Trace sessionOne selected configuration

장치 programming에서 trace session 선택까지 단계적으로 조합한다.

Basic Concepts
==============

This section introduces the basic concepts of a CoreSight system configuration.

Feature descriptor와 장치 programming

29-51

feature는 CoreSight 장치를 위한 이름 있는 programming 집합이다. 내용은 장치에 의존하며 절대 register 값, resource 사용, parameter 값으로 정의할 수 있다.

feature descriptor는 일치하는 장치에 feature를 로드하는 데 사용된다. 로드는 feature가 시스템에 들어올 때 이미 등록된 장치에 수행되거나, 나중에 CoreSight 장치가 Configuration Manager에 등록될 때 수행될 수 있다.

driver는 descriptor의 resource 사용과 parameter 설명을 실제 register access 집합으로 해석한다. 이 사전 해석 덕분에 필요할 때 장치에 feature를 쉽고 효율적으로 프로그래밍할 수 있다.

feature는 feature 자체와 장치가 모두 활성화되기 전에는 장치에서 동작하지 않는다. 장치가 켜질 때 활성화된 feature가 hardware에 기록된다. feature의 활성화는 시스템에서 configuration을 활성화하는 과정의 일부다.

Feature 수명 주기
Feature descriptorMatch registered device
Driver interpretationRegister accesses
Enable configurationEnable feature
Enable deviceProgram hardware

descriptor가 장치별 register programming으로 변환되고 configuration 선택 시 적용된다.

Feature 정의 요소
요소역할
Absolute register values고정 register programming
Resource usage장치 resource 요구량
Parameter values사용자가 조정할 수 있는 동작 값
Matching devicedescriptor를 해석할 driver와 장치

장치 의존 programming을 descriptor에 표현하는 방법이다.

Features
--------

A feature is a named set of programming for a CoreSight device. The programming
is device dependent, and can be defined in terms of absolute register values,
resource usage and parameter values.

The feature is defined using a descriptor. This descriptor is used to load onto
a matching device, either when the feature is loaded into the system, or when the
CoreSight device is registered with the configuration manager.

The load process involves interpreting the descriptor into a set of register
accesses in the driver - the resource usage and parameter descriptions
translated into appropriate register accesses. This interpretation makes it easy
and efficient for the feature to be programmed onto the device when required.

The feature will not be active on the device until the feature is enabled, and
the device itself is enabled. When the device is enabled then enabled features
will be programmed into the device hardware.

A feature is enabled as part of a configuration being enabled on the system.

사용자 조정 parameter 값

52-72

parameter value는 feature를 활성화하기 전에 사용자가 설정할 수 있는 이름 있는 값이며, feature가 프로그래밍하는 동작을 조정한다. 예를 들어 일정 비율로 반복되는 작업의 count 값이 될 수 있다.

feature가 활성화될 때 parameter의 현재 값으로 장치를 프로그래밍한다. descriptor는 사용자가 새 값을 주지 않았을 때 쓸 default를 정의한다.

사용자는 아래에서 설명하는 CoreSight configfs API로 parameter 값을 갱신한다. 갱신된 현재 값은 해당 장치에서 feature를 활성화할 때 로드된다.

Parameter 적용 시점
Feature descriptor defaultCurrent parameter value
configfs user updateCurrent parameter value
Enable feature on deviceLoad value into device

사용자 값 또는 default가 feature enable 시 hardware programming에 들어간다.

Parameter 속성
속성설명
Namefeature 동작에서 참조하는 이름
Defaultdescriptor가 제공하는 초기값
Current valueconfigfs로 조정한 현재값
Load time장치에서 feature를 활성화할 때

값의 정의·변경·적용 시점을 구분한다.

Parameter Value
~~~~~~~~~~~~~~~

A parameter value is a named value that may be set by the user prior to the
feature being enabled that can adjust the behaviour of the operation programmed
by the feature.

For example, this could be a count value in a programmed operation that repeats
at a given rate. When the feature is enabled then the current value of the
parameter is used in programming the device.

The feature descriptor defines a default value for a parameter, which is used
if the user does not supply a new value.

Users can update parameter values using the configfs API for the CoreSight
system - which is described below.

The current value of the parameter is loaded into the device when the feature
is enabled on that device.

Trace session의 feature 집합

73-90

configuration은 선택된 trace session에서 사용할 feature 집합을 정의한다. 하나의 trace session에는 configuration 하나만 선택할 수 있다.

feature는 system configuration을 지원하도록 등록된 어떤 장치 유형에도 속할 수 있다. configuration은 모든 ETMv4 같은 장치 class에 feature를 활성화하거나, 시스템의 특정 CTI처럼 개별 장치를 지정할 수 있다.

configuration도 descriptor로 정의한다. descriptor는 configuration과 함께 활성화할 feature와 feature의 default parameter를 덮어쓸 preset 값을 정의한다.

Configuration 선택 범위
범위
Device class모든 ETMv4
Specific device시스템의 특정 CTI
Session constrainttrace session당 configuration 하나

feature를 적용할 장치 집합을 두 수준으로 지정할 수 있다.

Configuration descriptor
Configuration descriptorRequired features
Configuration descriptorPreset overrides
Trace session selects configurationEnable matching device features

trace session 선택이 feature와 parameter override를 결합한다.

Configurations
--------------

A configuration defines a set of features that are to be used in a trace
session where the configuration is selected. For any trace session only one
configuration may be selected.

The features defined may be on any type of device that is registered
to support system configuration. A configuration may select features to be
enabled on a class of devices - i.e. any ETMv4, or specific devices, e.g. a
specific CTI on the system.

As with the feature, a descriptor is used to define the configuration.
This will define the features that must be enabled as part of the configuration
as well as any preset values that can be used to override default parameter
values.

Preset 값 집합

91-106

preset은 configuration이 사용하는 feature들의 parameter 값을 한 번에 선택할 수 있는 집합이다. preset 하나의 값 개수는 configuration에 포함된 모든 feature parameter 수의 합과 같다.

예를 들어 세 feature의 parameter 수가 각각 2개, 1개, 0개라면 preset 하나는 값 3개를 가진다. configuration은 preset을 선택적으로 최대 15개까지 정의할 수 있다. preset을 선택하지 않으면 feature에 정의된 일반 parameter 값을 사용한다.

Preset 값 수 계산
FeatureParameter 수
Feature A2
Feature B1
Feature C0
Preset 한 세트3 values

feature별 parameter 수를 합산한다.

Preset 선택
No presetFeature current/default values
Preset 1..15Preset parameter overrides
Selected valuesConfiguration enable

선택 여부에 따라 configuration이 사용할 parameter 출처가 달라진다.

Preset Values
~~~~~~~~~~~~~

Preset values are easily selectable sets of parameter values for the features
that the configuration uses. The number of values in a single preset set, equals
the sum of parameter values in the features used by the configuration.

e.g. a configuration consists of 3 features, one has 2 parameters, one has
a single parameter, and another has no parameters. A single preset set will
therefore have 3 values.

Presets are optionally defined by the configuration, up to 15 can be defined.
If no preset is selected, then the parameter values defined in the feature
are used as normal.

autofdo configuration 동작 순서

107-132

예제 configuration은 `autofdo`이며 ETMv4 CoreSight 장치에서 동작하는 `strobing` feature와 연결된다.

`perf record -e cs_etm/autofdo/ myapp`처럼 perf 명령줄에서 configuration을 선택하면 `autofdo`가 활성화된다. perf가 시스템 추적을 시작하고 사용할 ETMv4를 하나씩 활성화할 때 Configuration Manager는 현재 configuration과 관련된 feature가 있는지 검사한다. 이 경우 `strobing`을 활성화해 ETMv4에 프로그래밍한다.

ETMv4가 비활성화될 때 저장 필요 표시가 있는 register를 다시 읽는다. perf session이 끝나면 configuration도 비활성화된다.

autofdo 5단계
단계동작
1autofdo와 ETMv4용 strobing feature 연결
2perf 명령에서 autofdo configuration 활성화
3각 ETMv4 enable 시 strobing programming
4ETMv4 disable 시 save 표시 register readback
5perf session 종료 시 configuration 비활성화

원문의 operation 순서를 trace session 수명 주기에 맞춰 정리한다.

Trace session 적용
perf selects autofdoConfiguration active
Enable ETMv4Find strobing featureProgram hardware
Disable ETMv4Read back saved registers
End perf sessionDisable configuration

perf 선택에서 장치 programming과 register 저장까지 이어진다.

Operation
~~~~~~~~~

The following steps take place in the operation of a configuration.

1) In this example, the configuration is 'autofdo', which has an
   associated feature 'strobing' that works on ETMv4 CoreSight Devices.

2) The configuration is enabled. For example 'perf' may select the
   configuration as part of its command line::

    perf record -e cs_etm/autofdo/ myapp

   which will enable the 'autofdo' configuration.

3) perf starts tracing on the system. As each ETMv4 that perf uses for
   trace is enabled,  the configuration manager will check if the ETMv4
   has a feature that relates to the currently active configuration.
   In this case 'strobing' is enabled & programmed into the ETMv4.

4) When the ETMv4 is disabled, any registers marked as needing to be
   saved will be read back.

5) At the end of the perf session, the configuration will be disabled.

configfs에서 configuration·feature 조회와 변경

133-208

현재 시스템에 로드된 configuration과 feature는 configfs API에서 볼 수 있다. configfs를 mount하면 `/config` 아래에 `cs-syscfg` subsystem이 나타나며 그 안에는 `configurations`와 `features` 두 디렉터리가 있다.

내장 `autofdo` configuration 디렉터리에는 `description`, `feature_refs`, `enable`, `preset`, 그리고 선언된 preset마다 `preset<n>` 디렉터리가 있다. 설명은 ETM의 autofdo strobing 설정임을 밝히고 `feature_refs`는 `strobing`을 가리킨다.

`preset1/values`와 `preset2/values`는 각각 `strobing.window = 0x1388`을 공유하고 period를 `0x2`, `0x4`로 설정한다. `enable`과 `preset` 파일은 CoreSight를 sysfs로 사용할 때 configuration을 제어한다.

`features/strobing`에는 `description`, `matches`, `nr_params`, `params`가 있다. 이 feature는 주기적 trace capture window를 만들고 `window`를 CPU cycle 수 W로, `period`를 W cycle을 추적하는 반복 배수로 사용한다. `matches`는 `SRC_ETMV4`, parameter 수는 2다.

`params/period/value`의 현재값은 예제에서 `0x2710`이다. `echo 15000 > value`로 바꾸면 `0x3a98`로 표시된다. 이렇게 조정한 parameter는 feature를 로드한 모든 장치 instance에 반영된다.

cs-syscfg 트리
경로내용
cs-syscfg/configurations/autofdo설명, feature_refs, enable, preset, preset<n>
configurations/autofdo/preset<n>/valuespreset별 feature.parameter 값
cs-syscfg/features/strobing설명, matches, nr_params, params
features/strobing/params/{period,window}/value현재 parameter 값

configuration과 feature를 configfs 경로로 구분한다.

strobing 예제 값
항목
matchesSRC_ETMV4
nr_params2
preset1window=0x1388, period=0x2
preset2window=0x1388, period=0x4
period 변경0x2710 -> decimal 15000 -> 0x3a98

configfs에서 확인되는 built-in feature와 preset이다.

Parameter 변경 전파
Write params/period/valueUpdate current feature parameter
All device instances with strobing loadedSee adjusted value
Next feature enableProgram updated value

configfs 현재값 변경이 feature를 로드한 장치들에 공통으로 반영된다.

Viewing Configurations and Features
===================================

The set of configurations and features that are currently loaded into the
system can be viewed using the configfs API.

Mount configfs as normal and the 'cs-syscfg' subsystem will appear::

    $ ls /config
    cs-syscfg  stp-policy

This has two sub-directories::

    $ cd cs-syscfg/
    $ ls
    configurations  features

The system has the configuration 'autofdo' built in. It may be examined as
follows::

    $ cd configurations/
    $ ls
    autofdo
    $ cd autofdo/
    $ ls
    description  feature_refs  preset1  preset3  preset5  preset7  preset9
    enable       preset        preset2  preset4  preset6  preset8
    $ cat description
    Setup ETMs with strobing for autofdo
    $ cat feature_refs
    strobing

Each preset declared has a 'preset<n>' subdirectory declared. The values for
the preset can be examined::

    $ cat preset1/values
    strobing.window = 0x1388 strobing.period = 0x2
    $ cat preset2/values
    strobing.window = 0x1388 strobing.period = 0x4

The 'enable' and 'preset' files allow the control of a configuration when
using CoreSight with sysfs.

The features referenced by the configuration can be examined in the features
directory::

    $ cd ../../features/strobing/
    $ ls
    description  matches  nr_params  params
    $ cat description
    Generate periodic trace capture windows.
    parameter 'window': a number of CPU cycles (W)
    parameter 'period': trace enabled for W cycles every period x W cycles
    $ cat matches
    SRC_ETMV4
    $ cat nr_params
    2

Move to the params directory to examine and adjust parameters::

    cd params
    $ ls
    period  window
    $ cd period
    $ ls
    value
    $ cat value
    0x2710
    # echo 15000 > value
    # cat value
    0x3a98

Parameters adjusted in this way are reflected in all device instances that have
loaded the feature.

perf cs_etm event에서 configuration 선택

209-242

CoreSight Configuration Manager에 로드된 configuration은 perf의 `cs_etm` event infrastructure에도 선언되므로 perf 추적에서 선택할 수 있다.

`/sys/devices/cs_etm/events`는 perf 명령줄 선택을 제공하는 일반 perf 디렉터리다. sink entry와 마찬가지로 configuration 이름의 hash를 제공한다. `events/autofdo`는 perf 내장 syntax generator가 이름을 평가할 때 `configid=0xa7c3dddd`로 치환하도록 한다.

`perf record -e cs_etm/autofdo/u --per-thread <application>`은 `autofdo`를 선택한다. 현재 parameter를 preset으로 덮어쓰려면 `cs_etm/autofdo,preset=1/u`처럼 지정한다. 이 방식으로 configuration을 선택하면 사용할 trace sink도 자동 선택된다.

perf 선택 문법
Command fragment동작
cs_etm/autofdo/uautofdo configuration 선택
cs_etm/autofdo,preset=1/upreset1 값으로 현재 parameter override
events/autofdoconfigid=0xa7c3dddd syntax mapping
Configuration selectedtrace sink 자동 선택

configuration 이름과 preset을 cs_etm event 표현에 넣는다.

perf event 해석
perf cs_etm/autofdo/events/autofdo
configid=0xa7c3ddddConfiguration Manager
Enable trace devicesProgram autofdo features

이름 있는 configuration을 configid와 장치 programming으로 연결한다.

Using Configurations in perf
============================

The configurations loaded into the CoreSight configuration management are
also declared in the perf 'cs_etm' event infrastructure so that they can
be selected when running trace under perf::

    $ ls /sys/devices/cs_etm
    cpu0  cpu2  events  nr_addr_filters		power  subsystem  uevent
    cpu1  cpu3  format  perf_event_mux_interval_ms	sinks  type

The key directory here is 'events' - a generic perf directory which allows
selection on the perf command line. As with the sinks entries, this provides
a hash of the configuration name.

The entry in the 'events' directory uses perfs built in syntax generator
to substitute the syntax for the name when evaluating the command::

    $ ls events/
    autofdo
    $ cat events/autofdo
    configid=0xa7c3dddd

The 'autofdo' configuration may be selected on the perf command line::

    $ perf record -e cs_etm/autofdo/u --per-thread <application>

A preset to override the current parameter values can also be selected::

    $ perf record -e cs_etm/autofdo,preset=1/u --per-thread <application>

When configurations are selected in this way, then the trace sink used is
automatically selected.

sysfs session의 단일 전역 configuration

243-276

CoreSight를 sysfs로 제어할 때도 session에 사용되는 장치를 위한 configuration을 활성화할 수 있다. configuration에는 `enable`과 `preset` 파일이 있다.

`configurations/autofdo`에서 `echo 1 > enable`을 실행하면 sysfs용 configuration을 켠다. 이때 feature의 default parameter를 사용하며 앞서 설명한 configfs 경로에서 값을 조정할 수 있다.

`echo 3 > preset`은 configuration의 `preset3`를 선택한다. 유효값은 preset 선택을 해제하는 0과 실제 `preset<n>` 하위 디렉터리가 존재하는 n이다.

활성 sysfs configuration은 전역 parameter이므로 동시에 하나만 활성화할 수 있다. 두 번째 configuration을 켜거나 사용 중인 configuration을 끄면 오류가 난다. sysfs의 활성 configuration 사용은 perf에서 사용하는 configuration과 독립적이다.

sysfs 제어 파일
Write결과
echo 1 > enableautofdo를 sysfs용으로 활성화
echo 3 > presetpreset3 선택
echo 0 > presetpreset 선택 해제
없는 preset 번호유효하지 않음

configuration 활성화와 preset 선택을 분리한다.

sysfs 전역 제약
No active sysfs configurationEnable one configuration
One active configurationEnable secondError
Configuration in useDisableError
perf configurationIndependent selection

활성 configuration 하나를 보호하는 오류 조건이다.

Using Configurations in sysfs
=============================

Coresight can be controlled using sysfs. When this is in use then a configuration
can be made active for the devices that are used in the sysfs session.

In a configuration there are 'enable' and 'preset' files.

To enable a configuration for use with sysfs::

    $ cd configurations/autofdo
    $ echo 1 > enable

This will then use any default parameter values in the features - which can be
adjusted as described above.

To use a preset<n> set of parameter values::

    $ echo 3 > preset

This will select preset3 for the configuration.
The valid values for preset are 0 - to deselect presets, and any value of
<n> where a preset<n> sub-directory is present.

Note that the active sysfs configuration is a global parameter, therefore
only a single configuration can be active for sysfs at any one time.
Attempting to enable a second configuration will result in an error.
Additionally, attempting to disable the configuration while in use will
also result in an error.

The use of the active configuration by sysfs is independent of the configuration
used in perf.

Loadable module로 custom configuration 로드

277-294

custom configuration과 feature는 loadable module로 시스템에 동적으로 로드할 수 있다. 예제 custom configuration은 `./samples/coresight`에 있다.

이 예제는 기존 built-in `strobing` feature를 재사용하면서 다른 preset 집합을 제공하는 새 configuration을 만든다. module을 로드하면 configuration이 configfs에 나타나며 built-in configuration과 같은 방법으로 선택할 수 있다.

configuration은 이전에 로드된 feature를 사용할 수 있다. 시스템은 사용 중인 feature가 먼저 unload되지 않도록 load 순서의 정확한 역순으로 unload하도록 강제한다.

Custom configuration 생명 주기
Load strobing featureLoad custom module
New configuration in configfsSelect like built-in
Unload custom configurationThen unload strobing feature

기존 feature 재사용과 역순 unload 규칙을 함께 적용한다.

동적 로드 규칙
항목규칙
예제 경로./samples/coresight
재사용 featurebuilt-in strobing
사용자 차이별도의 preset 집합
Unload 순서load 순서의 strict reverse

module 예제와 의존성 보호 조건이다.

Creating and Loading Custom Configurations
==========================================

Custom configurations and / or features can be dynamically loaded into the
system by using a loadable module.

An example of a custom configuration is found in ./samples/coresight.

This creates a new configuration that uses the existing built in
strobing feature, but provides a different set of presets.

When the module is loaded, then the configuration appears in the configfs
file system and is selectable in the same way as the built in configuration
described above.

Configurations can use previously loaded features. The system will ensure
that it is not possible to unload a feature that is currently in use, by
enforcing the unload order as the strict reverse of the load order.