@@ -14,7 +14,7 @@ tracing_map.c.
14
14
Note: All the ftrace histogram command examples assume the working
15
15
directory is the ftrace /tracing directory. For example::
16
16
17
- # cd /sys/kernel/debug/tracing
17
+ # cd /sys/kernel/debug/tracing
18
18
19
19
Also, the histogram output displayed for those commands will be
20
20
generally be truncated - only enough to make the point is displayed.
@@ -107,7 +107,7 @@ for the hitcount and one key field for the pid key.
107
107
Below that is a diagram of a run-time snapshot of what the tracing_map
108
108
might look like for a given run. It attempts to show the
109
109
relationships between the hist_data fields and the tracing_map
110
- elements for a couple hypothetical keys and values.
110
+ elements for a couple hypothetical keys and values.::
111
111
112
112
+------------------+
113
113
| hist_data |
@@ -141,20 +141,20 @@ elements for a couple hypothetical keys and values.
141
141
| | | |
142
142
+--------------+ | |
143
143
n_keys = n_fields - n_vals | |
144
- | |
144
+
145
145
The hist_data n_vals and n_fields delineate the extent of the fields[] | |
146
146
array and separate keys from values for the rest of the code. | |
147
- | |
147
+
148
148
Below is a run-time representation of the tracing_map part of the | |
149
149
histogram, with pointers from various parts of the fields[] array | |
150
150
to corresponding parts of the tracing_map. | |
151
- | |
151
+
152
152
The tracing_map consists of an array of tracing_map_entrys and a set | |
153
153
of preallocated tracing_map_elts (abbreviated below as map_entry and | |
154
154
map_elt). The total number of map_entrys in the hist_data.map array = | |
155
155
map->max_elts (actually map->map_size but only max_elts of those are | |
156
156
used. This is a property required by the map_insert() algorithm). | |
157
- | |
157
+
158
158
If a map_entry is unused, meaning no key has yet hashed into it, its | |
159
159
.key value is 0 and its .val pointer is NULL. Once a map_entry has | |
160
160
been claimed, the .key value contains the key's hash value and the | |
@@ -163,11 +163,11 @@ for each key or value in the map_elt.fields[] array. There is an | |
163
163
entry in the map_elt.fields[] array corresponding to each hist_field | |
164
164
in the histogram, and this is where the continually aggregated sums | |
165
165
corresponding to each histogram value are kept. | |
166
- | |
166
+
167
167
The diagram attempts to show the relationship between the | |
168
168
hist_data.fields[] and the map_elt.fields[] with the links drawn | |
169
- between diagrams:: | |
170
- | |
169
+ between diagrams::
170
+
171
171
+-----------+ | |
172
172
| hist_data | | |
173
173
+-----------+ | |
@@ -380,7 +380,7 @@ entry, ts0, corresponding to the ts0 variable in the sched_waking
380
380
trigger above.
381
381
382
382
sched_waking histogram
383
- ----------------------
383
+ ----------------------::
384
384
385
385
+------------------+
386
386
| hist_data |<-------------------------------------------------------+
@@ -439,34 +439,34 @@ sched_waking histogram
439
439
+-----------------+ | | |
440
440
n_keys = n_fields - n_vals | | |
441
441
| | |
442
- | | |
442
+
443
443
This is very similar to the basic case. In the above diagram, we can | | |
444
444
see a new .flags member has been added to the struct hist_field | | |
445
445
struct, and a new entry added to hist_data.fields representing the ts0 | | |
446
446
variable. For a normal val hist_field, .flags is just 0 (modulo | | |
447
447
modifier flags), but if the value is defined as a variable, the .flags | | |
448
448
contains a set FL_VAR bit. | | |
449
- | | |
449
+
450
450
As you can see, the ts0 entry's .var.idx member contains the index | | |
451
451
into the tracing_map_elts' .vars[] array containing variable values. | | |
452
452
This idx is used whenever the value of the variable is set or read. | | |
453
453
The map_elt.vars idx assigned to the given variable is assigned and | | |
454
454
saved in .var.idx by create_tracing_map_fields() after it calls | | |
455
455
tracing_map_add_var(). | | |
456
- | | |
456
+
457
457
Below is a representation of the histogram at run-time, which | | |
458
458
populates the map, along with correspondence to the above hist_data and | | |
459
459
hist_field data structures. | | |
460
- | | |
460
+
461
461
The diagram attempts to show the relationship between the | | |
462
462
hist_data.fields[] and the map_elt.fields[] and map_elt.vars[] with | | |
463
463
the links drawn between diagrams. For each of the map_elts, you can | | |
464
464
see that the .fields[] members point to the .sum or .offset of a key | | |
465
465
or val and the .vars[] members point to the value of a variable. The | | |
466
466
arrows between the two diagrams show the linkages between those | | |
467
467
tracing_map members and the field definitions in the corresponding | | |
468
- hist_data fields[] members. | | |
469
- | | |
468
+ hist_data fields[] members.::
469
+
470
470
+-----------+ | | |
471
471
| hist_data | | | |
472
472
+-----------+ | | |
@@ -564,27 +564,27 @@ hist_data fields[] members. | | |
564
564
| unused | | |
565
565
| | | |
566
566
+---------------+ | |
567
- | |
567
+
568
568
For each used map entry, there's a map_elt pointing to an array of | |
569
569
.vars containing the current value of the variables associated with | |
570
570
that histogram entry. So in the above, the timestamp associated with | |
571
571
pid 999 is 113345679876, and the timestamp variable in the same | |
572
572
.var.idx for pid 4444 is 213499240729. | |
573
- | |
573
+
574
574
sched_switch histogram | |
575
575
---------------------- | |
576
- | |
576
+
577
577
The sched_switch histogram paired with the above sched_waking | |
578
578
histogram is shown below. The most important aspect of the | |
579
579
sched_switch histogram is that it references a variable on the | |
580
580
sched_waking histogram above. | |
581
- | |
581
+
582
582
The histogram diagram is very similar to the others so far displayed, | |
583
583
but it adds variable references. You can see the normal hitcount and | |
584
584
key fields along with a new wakeup_lat variable implemented in the | |
585
585
same way as the sched_waking ts0 variable, but in addition there's an | |
586
586
entry with the new FL_VAR_REF (short for HIST_FIELD_FL_VAR_REF) flag. | |
587
- | |
587
+
588
588
Associated with the new var ref field are a couple of new hist_field | |
589
589
members, var.hist_data and var_ref_idx. For a variable reference, the | |
590
590
var.hist_data goes with the var.idx, which together uniquely identify | |
@@ -593,10 +593,10 @@ just the index into the var_ref_vals[] array that caches the values of | |
593
593
each variable whenever a hist trigger is updated. Those resulting | |
594
594
values are then finally accessed by other code such as trace action | |
595
595
code that uses the var_ref_idx values to assign param values. | |
596
- | |
596
+
597
597
The diagram below describes the situation for the sched_switch | |
598
- histogram referred to before: | |
599
- | |
598
+ histogram referred to before::
599
+
600
600
# echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0' >> | |
601
601
events/sched/sched_switch/trigger | |
602
602
| |
0 commit comments